当前位置: 首页>>代码示例>>C#>>正文


C# Vector.Clone方法代码示例

本文整理汇总了C#中Vector.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Vector.Clone方法的具体用法?C# Vector.Clone怎么用?C# Vector.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vector的用法示例。


在下文中一共展示了Vector.Clone方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RecognizeAsynchronously

 public static Matrix RecognizeAsynchronously(Matrix weights, Vector input)
 {
     Random rand = new Random(DateTime.Now.Millisecond);
     Vector oldOutput = input.Clone();
     Vector newOutput = input.Clone();
     int iterations = 0;
     int equalTimes = 0;
     while (true)
     {
         Console.WriteLine("iteration: {0}", iterations++);
         Console.WriteLine(oldOutput);
         for (int i = 0; i < input.Length; ++i)
         {
             newOutput[i] = weights.GetRowVector(i).ArrayMultiply(newOutput).Sum() >= 0 ? +1 : -1;
         }
         Console.WriteLine(newOutput);
         if (newOutput.SequenceEqual(oldOutput)) //equalTimes += 1;
         //else equalTimes -= 1;
         //if (equalTimes >= 5)
         {
             Console.WriteLine("Old and new are equal");
             Matrix recognized = newOutput.ToMatrixByColumns(columnSize: (int)Math.Sqrt(input.Length));
             return recognized;
         }
         oldOutput = newOutput.Clone();
     }
 }
开发者ID:smilingjb12,项目名称:Hopfield,代码行数:27,代码来源:Recognizer.cs

示例2: TransformedGrid

        public TransformedGrid (Vector grid) {
            grid_ = (Vector)grid.Clone();
            transformedGrid_ = (Vector)grid.Clone();
            dxm_= new Vector(grid.size());
            dxp_ = new Vector(grid.size());
            dx_ = new Vector(grid.size());

            for (int i=1; i < transformedGrid_.size() -1 ; i++) {
                dxm_[i] = transformedGrid_[i] - transformedGrid_[i-1];
                dxp_[i] = transformedGrid_[i+1] - transformedGrid_[i];
                dx_[i] = dxm_[i] + dxp_[i];
            }
        }
开发者ID:akasolace,项目名称:qlnet,代码行数:13,代码来源:transformedgrid.cs

示例3: JakobiMatrix

        public static Matrix JakobiMatrix(Vector x, Function[] f, double precision)
        {
            if ((f.Length > 0) && (x.Length > 0) && (precision > 0))
            {

                Matrix J = new Matrix(f.Length, x.Length);
                Vector temp = x.Clone() as Vector;

                for (int counter1 = 0; counter1 < J.Height; counter1++)
                {
                    for (int counter2 = 0; counter2 < J.Width; counter2++)
                    {
                        temp[counter2] += precision;

                        J[counter1][counter2] = (f[counter1](temp) - f[counter1](x)) / precision;

                        temp[counter2] -= precision;
                    }
                }

                return J;
            }
            else
            {
                throw new IncorrectIncomingDataException("Dimensions of delegates or vectors or precision are incorrect.");
            }
        }
开发者ID:rtym,项目名称:Computing-Math,代码行数:27,代码来源:DiffrerntialOperators.cs

示例4: QpProblem

 public QpProblem(Matrix<double> Q, Vector<double> g, Matrix<double> A, Vector<double> b)
 {
     this._Q = Q.Clone();
     this._c = g.Clone();
     this._A = A.Clone();
     this._b = b.Clone();
 }
开发者ID:markiemarkus,项目名称:QuadProg,代码行数:7,代码来源:QpProblem.cs

示例5: Light

 public Light(Vector direction, uint diffuse, uint specular, int highlightSheen, int highlightSpread)
 {
     v=direction.Clone();
     v.Normalize();
     this.diffuse=diffuse;
     this.specular=specular;
     this.highlightSheen=highlightSheen;
     this.highlightSpread=highlightSpread;
 }
开发者ID:tgjones,项目名称:idx3dsharp,代码行数:9,代码来源:Light.cs

示例6: Path

        public Path(TimeGrid timeGrid, Vector values) {
            timeGrid_ = timeGrid;
            values_ = (Vector)values.Clone();
            if (values_.empty())
                values_ = new Vector(timeGrid_.size());

            if (values_.size() != timeGrid_.size())
                throw new ApplicationException("different number of times and asset values");
        }
开发者ID:akasolace,项目名称:qlnet,代码行数:9,代码来源:path.cs

示例7: TridiagonalOperator

        public TridiagonalOperator(Vector low, Vector mid, Vector high) {
            diagonal_ = (Vector)mid.Clone();
            lowerDiagonal_ = (Vector)low.Clone();
            upperDiagonal_ = (Vector)high.Clone();

            if (!(low.Count == mid.Count - 1))
                throw new ApplicationException("wrong size for lower diagonal vector");
            if (!(high.Count == mid.Count - 1))
                throw new ApplicationException("wrong size for upper diagonal vector");
        }
开发者ID:akasolace,项目名称:qlnet,代码行数:10,代码来源:TridiagonalOperator.cs

示例8: GaussianMeasurement

 // Constructor
 public GaussianMeasurement(uint platformID, uint sensorID, 
     Vector creatorUnityReference, GaussianVector gaussianVector,
     Coordinate.Type coordinateType, DateTime dateTime)
 {
     this.platformID = platformID;
     this.sensorID = sensorID;
     this.creatorUnityReference = creatorUnityReference.Clone();
     this.gaussianVector = gaussianVector.Clone();
     this.coordinateType = coordinateType;
     this.dateTime = dateTime;
 }
开发者ID:philiptwu,项目名称:fusion-engine,代码行数:12,代码来源:GaussianMeasurement.cs

示例9: Reflection

        /// <summary>
        /// Householder Reflection: Evaluate symmetric orthogonal Q such that Q*v = -sigma*||v||*e1 
        /// </summary>
        public static Matrix Reflection(Vector v)
        {
            double sigma = v[0] >= 0 ? 1 : -1;

            Vector u = v.Clone();
            u[0] += sigma * v.Norm();

            Matrix m = Matrix.Identity(v.Length, v.Length);
            m.MultiplyAccumulateInplace(u.TensorMultiply(u), -2d / u.ScalarMultiply(u));

            return m;
        }
开发者ID:AdrianCNewman,项目名称:mathnet-iridium,代码行数:15,代码来源:Orthogonal.cs

示例10: Evaluate

        public override Vector Evaluate(Vector state, DateTime stateTime, DateTime targetTime)
        {
            // Compute dt
            TimeSpan ts = targetTime.Subtract(stateTime);
            double dt = ts.TotalSeconds;

            // Create coasted vector
            Vector coasted = state.Clone();
            coasted[0] = state[0] + state[3] * dt;
            coasted[1] = state[1] + state[4] * dt;
            coasted[2] = state[2] + state[5] * dt;

            // Return
            return coasted;
        }
开发者ID:philiptwu,项目名称:fusion-engine,代码行数:15,代码来源:ConstantVelocityModel.cs

示例11: Solve

        public Vector Solve(Vector initialVector, double precision)
        {
            Vector x;

            if (initialVector.Length == this.f.Length)
            {
                bool key = true;
                Vector candidate = new Vector(this.f.Length);
                x = initialVector.Clone() as Vector;
                Vector f = new Vector(this.f.Length);

                while (((candidate - x).Norm() > precision) || (key))
                {
                    if (((candidate - x).Norm() > precision) && (!key))
                    {
                        x = candidate;
                    }

                    key = false;

                    for (int counter = 0; counter < this.f.Length; counter++)
                    {
                        f[counter] = -this.f[counter](x);
                    }

                    try
                    {
                        candidate = x + DirectMethods.GaussMethod(new SquareMatrix(DiffrerntialOperators.JakobiMatrix(x, this.f, precision)), f);
                    }
                    catch (NoSolutionException error)
                    {
                        throw new NoSolutionException("To many solutions or solution does not exists.", error);
                    }
                }
            }
            else
            {
                throw new IncorrectIncomingDataException("Incorrect length of incming vector is set.");
            }

            return x;
        }
开发者ID:rtym,项目名称:Computing-Math,代码行数:42,代码来源:NewtonMethod.cs

示例12: HesseMatrix

        public static SquareMatrix HesseMatrix(Vector x, Function f, double precision)
        {
            if ((x.Length > 0) && (precision > 0))
            {
                SquareMatrix H = new SquareMatrix(x.Length);
                Vector temp = x.Clone() as Vector;

                for (int counter1 = 0; counter1 < H.Height; counter1++)
                {
                    for (int counter2 = 0; counter2 < H.Width; counter2++)
                    {
                        double sum = f(x);

                        temp[counter2] += precision;
                        temp[counter1] += precision;

                        sum += f(temp);

                        temp[counter2] -= precision;

                        sum -= f(temp);

                        temp[counter2] += precision;
                        temp[counter1] -= precision;

                        sum -= f(temp);

                        H[counter1][counter2] = sum / Math.Pow(precision, 2);

                        temp[counter2] -= precision;
                    }
                }

                return H;
            }
            else
            {
                throw new IncorrectIncomingDataException("Dimensions of delegates or vectors or precision are incorrect.");
            }
        }
开发者ID:rtym,项目名称:Computing-Math,代码行数:40,代码来源:DiffrerntialOperators.cs

示例13: RecognizeSynchronously

 public static int RecognizeSynchronously(Matrix weights, Vector input, Vector[] samples)
 {
     Console.WriteLine("Recognize()");
     Console.WriteLine("input:");
     Vector oldOutput = input.Clone();
     int recognizedSampleIndex;
     int iterations = 0;
     while (true)
     {
         iterations += 1;
         Console.WriteLine("iteration: {0}", iterations);
         Vector newOutput = oldOutput.Clone();
         for (int r = 0; r < weights.RowCount; ++r)
         {
             Vector weightsRow = weights.GetRowVector(r);
             newOutput[r] = weightsRow.ArrayMultiply(oldOutput).Sum() >= 0 ? +1 : -1;
         }
         if (newOutput.SequenceEqual(oldOutput))
         {
             for (int j = 0; j < samples.Length; ++j)
             {
                 if (samples[j].SequenceEqual(newOutput))
                 {
                     recognizedSampleIndex = j;
                     Console.WriteLine("Recognized to be {0}", j);
                     return recognizedSampleIndex;
                 }
             }
         }
         //Console.WriteLine("output:");
         //Console.WriteLine(newOutput.ToPrettyString());
         oldOutput = newOutput.Clone();
         if (iterations > 100)
         {
             Console.WriteLine("Coulnd't recognize");
             return -1;
         }
     }
 }
开发者ID:smilingjb12,项目名称:Hopfield,代码行数:39,代码来源:Recognizer.cs

示例14: PutAllPaths

        public static void PutAllPaths(this List<LinkedList<Vector>> allPaths, Vector toPont, Vector position, LinkedList<Vector> path, int[,] maze)
        {
            if (maze[position.Y, position.X] != EmptyCell)
            {
                return;
            }

            maze[position.Y, position.X] = VisitedCell;
            path.AddLast((Vector)position.Clone());

            if (position.CompareTo(toPont) == 0)
            {
                allPaths.Add(new LinkedList<Vector>(path));
            }
            else
            {
                foreach (var direction in Directions)
                {
                    if (IsInRange(
                        position.Y + direction.Y,
                        position.X + direction.X,
                        maze.GetLength(0),
                        maze.GetLength(1)))
                    {
                        allPaths.PutAllPaths(
                            toPont,
                            new Vector(y: position.Y + direction.Y, x: position.X + direction.X),
                            path,
                            maze);
                    }
                }
            }

            path.RemoveLast();
            maze[position.Y, position.X] = EmptyCell;
        }
开发者ID:RuzmanovDev,项目名称:TelerikAcademy,代码行数:36,代码来源:AllPathsBetweenCells.cs

示例15: Solve

        /// <summary>
        /// Solves a system of linear equations, <b>Ax = b</b>, with A QR factorized.
        /// </summary>
        /// <param name="input">The right hand side vector, <b>b</b>.</param>
        /// <param name="result">The left hand side <see cref="Matrix{T}"/>, <b>x</b>.</param>
        public override void Solve(Vector<float> input, Vector<float> result)
        {
            // Ax=b where A is an m x n matrix
            // Check that b is a column vector with m entries
            if (Q.RowCount != input.Count)
            {
                throw new ArgumentException(Resources.ArgumentVectorsSameLength);
            }

            // Check that x is a column vector with n entries
            if (Q.ColumnCount != result.Count)
            {
                throw Matrix.DimensionsDontMatch<ArgumentException>(Q, result);
            }

            var inputCopy = input.Clone();

            // Compute Y = transpose(Q)*B
            var column = new float[Q.RowCount];
            for (var k = 0; k < Q.RowCount; k++)
            {
                column[k] = inputCopy[k];
            }

            for (var i = 0; i < Q.ColumnCount; i++)
            {
                float s = 0;
                for (var k = 0; k < Q.RowCount; k++)
                {
                    s += Q.At(k, i) * column[k];
                }

                inputCopy[i] = s;
            }

            // Solve R*X = Y;
            for (var k = Q.ColumnCount - 1; k >= 0; k--)
            {
                inputCopy[k] /= FullR.At(k, k);
                for (var i = 0; i < k; i++)
                {
                    inputCopy[i] -= inputCopy[k] * FullR.At(i, k);
                }
            }

            for (var i = 0; i < FullR.ColumnCount; i++)
            {
                result[i] = inputCopy[i];
            }
        }
开发者ID:nakamoton,项目名称:mathnet-numerics,代码行数:55,代码来源:UserGramSchmidt.cs


注:本文中的Vector.Clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。