コード例 #1
0
ファイル: LVDRangeCurve.cs プロジェクト: youdontown/StudioSB
        public override void Read(BinaryReaderExt r)
        {
            base.Read(r);
            r.ReadByte();
            Vector1 = new LVDVector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle());
            r.ReadByte();
            Vector2 = new LVDVector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle());
            r.ReadByte();

            int vec3Count = r.ReadInt32();

            for (int i = 0; i < vec3Count; i++)
            {
                r.ReadByte();
                Vectors.Add(new LVDVector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()));
            }

            r.ReadByte();
            Mat4x4_1 = new float[16];
            for (int i = 0; i < 16; i++)
            {
                Mat4x4_1[i] = r.ReadSingle();
            }

            r.ReadByte();
            Mat4x4_2 = new float[16];
            for (int i = 0; i < 16; i++)
            {
                Mat4x4_2[i] = r.ReadSingle();
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: sev-it/asp.net
 static void Main(string[] args)
 {
     Vectors route = new Vectors (); 
     route.Add(new Vector (2.0, 90.0)); 
     route.Add(new Vector (1.0, 180.0)) ; 
     route.Add(new Vector (0.5, 45.0)); 
     route.Add(new Vector (2.5, 315.0)); 
     Console.WriteLine(route.Sum()); 
     Comparison<Vector> sorter = new Comparison<Vector>(VectorDelegates.Compare); 
     route.Sort(sorter); 
     Console.WriteLine(route.Sum ()); 
     Predicate<Vector> searcher = new Predicate<Vector>(VectorDelegates.TopRightQuadrant); 
     Vectors topRightQuadrantRoute = new Vectors(route.FindAll(searcher)); 
     Console.WriteLine(topRightQuadrantRoute.Sum()); 
     Console.ReadKey(); 
 }
コード例 #3
0
    static void Main(string[] args)
    {
        Vectors route = new Vectors();

        route.Add(new Vector(2.0, 90.0));
        route.Add(new Vector(1.0, 180.0));
        route.Add(new Vector(0.5, 45.0));
        route.Add(new Vector(2.5, 315.0));

        Console.WriteLine(route.Sum());

        Comparison <Vector> sorter = new Comparison <Vector>(VectorDelegates.Compare);

        route.Sort(sorter);
        Console.WriteLine(route.Sum());

        Predicate <Vector> searcher = new Predicate <Vector>(VectorDelegates.TopRightQuadrant);
        Vectors            topRightQuadrantRoute = new Vectors(route.FindAll(searcher));

        Console.WriteLine(topRightQuadrantRoute.Sum());
    }
コード例 #4
0
        public WordsContext CreateNewVector()
        {
            if (Vectors.Count != 0 &&
                CurrentVector.Words.Count == 0)
            {
                log.LogDebug("Ignoring call to create vector - current is empty");
                return(CurrentVector);
            }

            var vector = new WordsContext(Word);

            Vectors.Add(vector);
            return(vector);
        }
コード例 #5
0
 /// <summary>
 /// Adds embedding to embeddings database.
 /// </summary>
 /// <param name="vector">Vector</param>
 /// <param name="label">Label</param>
 public void Add(float[] vector, string label)
 {
     Vectors.Add(vector);
     Labels.Add(label);
 }
コード例 #6
0
        public MainWindow()
        {
            InitializeComponent();

            this.Vectors = new List <VectorModel>();

            BrushesArray = new Brush[80];
            for (int i = 0; i < 80; i++)
            {
                BrushesArray[i] = PickBrush();
            }

            //var path = AppDomain.CurrentDomain.BaseDirectory + @"testfiles\test3.txt";
            var path = (AppDomain.CurrentDomain.BaseDirectory + @"Examples\and.gsa").Replace(@"UI\bin\Debug\netcoreapp3.1\", "");
            var list = TextFileParser.ParseText(path);//.Replace(@"UI\bin\Debug\netcoreapp3.1\", ""));
            var grid = new BlockDistributor(list);

            grid.RemoveEmptyLines();
            grid.PrintGrid();
            grid.SetNodesPositions();

            var       graph = new GraphMaker(grid.GetNodes(), grid.GetGrid());
            Stopwatch sw    = new Stopwatch();

            sw.Start();
            graph.LineCreator();
            sw.Stop();
            Console.WriteLine("ElapsedTotal={0}", sw.Elapsed);

            graph.RemoveMiddlePointsFromLines();

            this.Lines = graph.GetLines();
            this.Nodes = graph.GetNodes();

            int id = 1;

            foreach (var line in Lines)
            {
                var points = line.GetPointsOfLine();
                for (int i = 0; i < points.Count - 1; i++)
                {
                    Vectors.Add(new VectorModel(new Coordinates(points[i].x * _multiplier, points[i].y * _multiplier), new Coordinates(points[i + 1].x * _multiplier, points[i + 1].y * _multiplier), id));
                }
                id++;
            }

            this.Vectors = this.Vectors.Where(x => x.Id <= 100).ToList();
            this.Recheck = new Queue <VectorModel>();
            foreach (var vector in Vectors)
            {
                AddLine(vector);
            }

            while (this.Recheck.Count != 0)
            {
                var recheck = this.Recheck.Dequeue();
                if (recheck.GetChangeNumber() < 5)
                {
                    recheck.AddChange();
                    AddLine(recheck);
                }
            }

            foreach (var vector in Vectors)
            {
                DrawVector(vector);
            }

            foreach (var node in Nodes)
            {
                AddBlock(node.GetPosition().y, node.GetPosition().x, node.GetId(), node.GetType());
            }
        }
コード例 #7
0
ファイル: IntegralImage.cs プロジェクト: arnavdas88/dnn
        /// <summary>
        /// Create a <see cref="IntegralImage"/> from the specified <see cref="Image"/>.
        /// </summary>
        /// <param name="image">The source <see cref="Image"/>.</param>
        /// <returns>
        /// The <see cref="IntegralImage"/> this method creates.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="image"/> is <b>null</b>.
        /// </exception>
        /// <remarks>
        /// <para>The size of resulting integral image is (<paramref name="image"/>.width + 1) * (<paramref name="image"/>.height + 1).</para>
        /// </remarks>
        public static IntegralImage FromImage(Image image)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }

            int bitsPerPixel = image.BitsPerPixel;

            if (image.BitsPerPixel > 16)
            {
                throw new NotSupportedException();
            }

            int width  = image.Width;
            int height = image.Height;

            IntegralImage dst = new IntegralImage(width + 1, height + 1);

#if false
            // IPP version is approximately twice faster
            unsafe
            {
                fixed(ulong *bitssrc = image.Bits)
                {
                    fixed(int *bitsdst = dst.Bits)
                    {
                        byte *ptrsrc = (byte *)bitssrc;
                        uint *ptrdst = (uint *)bitsdst;

                        int stridesrc = image.Stride8;
                        int stridedst = dst.Width;

                        ptrdst += stridedst;
                        for (int iy = 0; iy < height; iy++, ptrsrc += stridesrc, ptrdst += stridedst)
                        {
                            // sum current line
                            Vectors.CumulativeSum(width, ptrsrc, ptrdst + 1);

                            // sum with previous line
                            if (iy > 0)
                            {
                                Vectors.Add(stridedst, ptrdst - stridedst, ptrdst);
                            }
                        }
                    }
                }
            }
#else
            IPP.Execute(() =>
            {
                unsafe
                {
                    fixed(ulong *bitssrc = image.Bits)
                    {
                        fixed(int *bitsdst = dst.Bits)
                        {
                            return(NativeMethods.integral32s(
                                       width,
                                       height,
                                       (byte *)bitssrc,
                                       image.Stride8,
                                       bitsdst,
                                       dst.Width,
                                       0));
                        }
                    }
                }
            });
#endif

            return(dst);
        }
コード例 #8
0
 public void Add(VectorModel vector)
 {
     Vectors.Add(vector);
 }
コード例 #9
0
        /// <summary>
        /// Import member variable declarations.
        /// </summary>
        private void ImportLines()
        {
            _vectors = new Vectors();
            Vector vector = null;
            string line   = string.Empty;
            int    nPos1  = 0;
            int    nPos2  = 0;
            int    nEol   = 0;

            foreach (string inputLine in _inputLines)
            {
                line = inputLine.Trim();
                if (line.Length > 0)
                {
                    if (!line.StartsWith("//"))
                    {
                        vector = new Vector();
                        if (line.Contains(" readonly "))
                        {
                            vector.ReadOnly = true;
                            line            = line.Replace("readonly ", string.Empty);
                        }
                        nPos1 = line.IndexOf(' ');
                        if (nPos1 > -1)
                        {
                            vector.Modifier = line.Substring(0, nPos1).Trim();
                            nPos2           = line.IndexOf(' ', nPos1 + 1);
                            if (nPos2 > -1)
                            {
                                vector.Type = line.Substring(nPos1, nPos2 - nPos1).Trim();
                                nEol        = line.Length;
                                nPos1       = line.IndexOf(' ', nPos2 + 1);
                                if (nPos1 > -1)
                                {
                                    if (nPos1 < nEol)
                                    {
                                        nEol = nPos1;
                                    }
                                }
                                else
                                {
                                    nPos1 = line.IndexOf('=', nPos2 + 1);
                                    if (nPos1 > -1)
                                    {
                                        if (nPos1 < nEol)
                                        {
                                            nEol = nPos1;
                                        }
                                    }
                                    else
                                    {
                                        nPos1 = line.IndexOf(';', nPos2 + 1);
                                        if (nPos1 > -1)
                                        {
                                            if (nPos1 < nEol)
                                            {
                                                nEol = nPos1;
                                            }
                                        }
                                    }
                                }
                                if (nPos1 > -1)
                                {
                                    vector.Variable = line.Substring(nPos2, nPos1 - nPos2).Trim();
                                    if (vector.Variable.Substring(0, 1) == "_")
                                    {
                                        vector.Property = vector.Variable.Substring(1, 1).ToUpper() + vector.Variable.Substring(2);
                                    }
                                    else
                                    {
                                        vector.Property = vector.Variable.Substring(2, 1).ToUpper() + vector.Variable.Substring(3);
                                    }
                                    vector.Summary = TitleFromCamelCase(vector.Property) + ".";
                                }
                            }
                        }
                        _vectors.Add(vector);
                    }
                }
            }
        }