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


C# Vector.At方法代码示例

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


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

示例1: ComputeMappingFucntion

        public override void ComputeMappingFucntion(Vector<double> mapFuncResult)
        {
            int measuredPointsCount = (MeasurementsVector.Count) / 5;
            // exi = lxi / mi, eyi = lyi / mi
            for(int i = 0; i < measuredPointsCount; ++i)
            {
                mapFuncResult.At(2 * i, _Lx.At(i) / _M.At(i));
                mapFuncResult.At(2 * i + 1, _Ly.At(i) / _M.At(i));
            }

            // Compute s:
            _cm[0, 0] = ResultsVector[0];
            _cm[0, 1] = ResultsVector[1];
            _cm[0, 2] = ResultsVector[2];
            _cm[1, 0] = ResultsVector[4];
            _cm[1, 1] = ResultsVector[5];
            _cm[1, 2] = ResultsVector[6];
            _cm[2, 0] = ResultsVector[8];
            _cm[2, 0] = ResultsVector[9];
            _cm[2, 0] = ResultsVector[10];

            var RQ = _cm.QR();

            double s = RQ.R[0, 1];// / RQ.R[1, 1];
            mapFuncResult[mapFuncResult.Count - 1] = s;
        }
开发者ID:KFlaga,项目名称:Cam3D,代码行数:26,代码来源:LMCameraMatrixZeroSkewMini.cs

示例2: OfVector

        /// <summary>
        /// Create a new Vector3DHomogeneous from a Math.NET Numerics vector of length 4.
        /// </summary>
        public static Vector3DHomogeneous OfVector(Vector<double> vector)
        {
            if (vector.Count != 4)
            {
                throw new ArgumentException("The vector length must be 4 in order to convert it to a Vector3D");
            }

            return new Vector3DHomogeneous(vector.At(0), vector.At(1), vector.At(2), vector.At(2));
        }
开发者ID:EMostafaAli,项目名称:mathnet-spatial,代码行数:12,代码来源:Vector3DHomogeneous.cs

示例3: ComputeAt

 public static double ComputeAt(double x, Vector<float> coeffs)
 {
     double val = coeffs.At(coeffs.Count - 1);
     double xn = x;
     for(int c = coeffs.Count - 2; c >= 0; --c)
     {
         val += xn * coeffs.At(c);
         xn *= x;
     }
     return val;
 }
开发者ID:KFlaga,项目名称:Cam3D,代码行数:11,代码来源:Polynomial.cs

示例4: ComputeErrorVector

 public override void ComputeErrorVector(Vector<double> error)
 {
     ComputeMappingFucntion(error);
     int measuredPointsCount = (MeasurementsVector.Count) / 5;
     for(int i = 0; i < measuredPointsCount; ++i)
     {
         error.At(2 * i, MeasurementsVector[3 * measuredPointsCount + 2 * i] - error[2 * i]);
         error.At(2 * i + 1, MeasurementsVector[3 * measuredPointsCount + 2 * i + 1] - error[2 * i + 1]);
     }
     error[error.Count - 1] = _w * error[error.Count - 1];
 }
开发者ID:KFlaga,项目名称:Cam3D,代码行数:11,代码来源:LMCameraMatrixZeroSkewMini.cs

示例5: Vector3

 public Vector3(Vector<double> other)
 {
     if(other.Count == 4)
     {
         // Treat input vector as homogenous 3d vector
         _x = other.At(0) / other.At(3);
         _y = other.At(1) / other.At(3);
         _z = other.At(2) / other.At(3);
     }
     else
     {
         _x = other.At(0);
         _y = other.At(1);
         _z = other.At(2);
     }
 }
开发者ID:KFlaga,项目名称:Cam3D,代码行数:16,代码来源:Vector3.cs

示例6: MatrixToEuler

 // Converts 3x3 rotation matrix to XYZ euler angles (assumes vector is correctly allocated)
 public static void MatrixToEuler(Vector<double> euler, Matrix<double> matrix)
 {
     if(matrix.At(0, 2) < 1.0 - 1e-9)
     {
         if(matrix.At(0, 2) > -1.0 + 1e-9)
         {
             //      t he t aY = a s i n(r 0 2);
             //     t he t aX = a t a n 2(−r12, r 2 2);
             //    t h e t aZ = a t a n 2(−r01, r 0 0);
             euler.At(1, Math.Asin(matrix.At(0, 2)));
             euler.At(0, Math.Atan2(-matrix.At(1, 2), matrix.At(2, 2)));
             euler.At(2, Math.Atan2(-matrix.At(0, 1), matrix.At(0, 0)));
         }
         else // r 0 2 = −1
         {
             // Not a u n i q u e s o l u t i o n : t h e t aZ − t he t aX = a t a n 2 ( r10 , r 1 1 )
             //  t he t aY = −PI / 2;
             // t he t aX = −a t a n 2(r10, r 1 1);
             // t h e t aZ = 0;
             euler.At(1, -Math.PI * 0.5);
             euler.At(0, -Math.Atan2(-matrix.At(1, 0), matrix.At(1, 1)));
             euler.At(2, 0.0);
         }
     }
     else // r 0 2 = +1
     {
         // Not a u n i q u e s o l u t i o n : t h e t aZ + t he t aX = a t a n 2 ( r10 , r 1 1 )
         // t he t aY = +PI / 2;
         // t he t aX = a t a n 2(r10, r 1 1);
         // t h e t aZ = 0;
         euler.At(1, Math.PI * 0.5);
         euler.At(0, -Math.Atan2(-matrix.At(1, 0), matrix.At(1, 1)));
         euler.At(2, 0.0);
     }
 }
开发者ID:KFlaga,项目名称:Cam3D,代码行数:36,代码来源:RotationConverter.cs

示例7: EulerToMatrix

 // Converts XYZ euler angles to 3x3 rotation matrix (assumes matrix is correctly allocated)
 public static void EulerToMatrix(Vector<double> euler, Matrix<double> matrix)
 {
     // | cycz           −cysz           sy    |
     // | czsxsy + cxsz  cxcz − sxsysz   −cysx |
     // | −cxczsy + sxsz czsx + cxsysz   cxcy  |
     //
     double sx = Math.Sin(euler.At(0));
     double cx = Math.Cos(euler.At(0));
     double sy = Math.Sin(euler.At(1));
     double cy = Math.Cos(euler.At(1));
     double sz = Math.Sin(euler.At(2));
     double cz = Math.Cos(euler.At(2));
     matrix.At(0, 0, cy * cz);
     matrix.At(0, 1, -cy * sz);
     matrix.At(0, 2, sy);
     matrix.At(1, 0, cz * sx * sy + cx * sz);
     matrix.At(1, 1, cx * cz - sx * sy * sz);
     matrix.At(1, 2, -cy * sx);
     matrix.At(2, 0, -cx * cz * sy + sz * sz);
     matrix.At(2, 1, cz * sx + cx * sy * sz);
     matrix.At(2, 2, cx * cy);
 }
开发者ID:KFlaga,项目名称:Cam3D,代码行数:23,代码来源:RotationConverter.cs

示例8: DoPointwiseMultiply

 /// <summary>
 /// Pointwise multiplies this vector with another vector and stores the result into the result vector.
 /// </summary>
 /// <param name="other">The vector to pointwise multiply with this one.</param>
 /// <param name="result">The vector to store the result of the pointwise multiplication.</param>
 protected override void DoPointwiseMultiply(Vector<float> other, Vector<float> result)
 {
     if (ReferenceEquals(this, other))
     {
         for (var i = 0; i < _storage.ValueCount; i++)
         {
             _storage.Values[i] *= _storage.Values[i];
         }
     }
     else
     {
         for (var i = 0; i < _storage.ValueCount; i++)
         {
             var index = _storage.Indices[i];
             result.At(index, other.At(index) * _storage.Values[i]);
         }
     }
 }
开发者ID:primebing,项目名称:mathnet-numerics,代码行数:23,代码来源:SparseVector.cs

示例9: DoNegate

        /// <summary>
        /// Negates vector and saves result to <paramref name="result"/>
        /// </summary>
        /// <param name="result">Target vector</param>
        protected override void DoNegate(Vector<float> result)
        {
            var sparseResult = result as SparseVector;
            if (sparseResult == null)
            {
                result.Clear();
                for (var index = 0; index < _storage.ValueCount; index++)
                {
                    result.At(_storage.Indices[index], -_storage.Values[index]);
                }
            }
            else
            {
                if (!ReferenceEquals(this, result))
                {
                    sparseResult._storage.ValueCount = _storage.ValueCount;
                    sparseResult._storage.Indices = new int[_storage.ValueCount];
                    Buffer.BlockCopy(_storage.Indices, 0, sparseResult._storage.Indices, 0, _storage.ValueCount * Constants.SizeOfInt);
                    sparseResult._storage.Values = new float[_storage.ValueCount];
                    Array.Copy(_storage.Values, sparseResult._storage.Values, _storage.ValueCount);
                }

                Control.LinearAlgebraProvider.ScaleArray(-1.0f, sparseResult._storage.Values, sparseResult._storage.Values);
            }
        }
开发者ID:primebing,项目名称:mathnet-numerics,代码行数:29,代码来源:SparseVector.cs

示例10: DoDotProduct

 /// <summary>
 /// Computes the dot product between this vector and another vector.
 /// </summary>
 /// <param name="other">The other vector.</param>
 /// <returns>The sum of a[i]*b[i] for all i.</returns>
 protected override float DoDotProduct(Vector<float> other)
 {
     var result = 0f;
     if (ReferenceEquals(this, other))
     {
         for (var i = 0; i < _storage.ValueCount; i++)
         {
             result += _storage.Values[i] * _storage.Values[i];
         }
     }
     else
     {
         for (var i = 0; i < _storage.ValueCount; i++)
         {
             result += _storage.Values[i] * other.At(_storage.Indices[i]);
         }
     }
     return result;
 }
开发者ID:primebing,项目名称:mathnet-numerics,代码行数:24,代码来源:SparseVector.cs

示例11: FinalizeForPixel

        public override void FinalizeForPixel(IntVector2 pixelBase)
        {
            if(_minIdx == -1)
            {
                // There was no disparity for pixel : set as invalid
                DisparityMap.Set(pixelBase.Y, pixelBase.X,
                    new Disparity(pixelBase, pixelBase, double.PositiveInfinity, 0.0, (int)DisparityFlags.Invalid));
                return;
            }

            Disparity bestDisp = _dispForPixel[_minIdx];
            bestDisp.Confidence = ConfidenceComp.ComputeConfidence(_dispForPixel, _minIdx, _min2Idx);

            if(_minIdx > 0 && _minIdx < _dispForPixel.Count - 1)
            {
                // D'[d-1] = D[d] + c[d-1]/c[d] * (D[d-1] - D[d])
                // D'[d+1] = D[d] + c[d+1]/c[d] * (D[d+1] - D[d])
                // Fit quadratic func. to d,d-1,d+1
                double c_n = _dispForPixel[_minIdx - 1].Cost / _minCost;
                double c_p = _dispForPixel[_minIdx + 1].Cost / _minCost;
                double dx = _dispForPixel[_minIdx].DX;
                double dy = _dispForPixel[_minIdx].DY;
                double dx_n = dx + c_n * (_dispForPixel[_minIdx - 1].DX - dx);
                double dy_n = dy + c_n * (_dispForPixel[_minIdx - 1].DY - dy);
                double dx_p = dx + c_p * (_dispForPixel[_minIdx + 1].DX - dx);
                double dy_p = dy + c_p * (_dispForPixel[_minIdx + 1].DY - dy);

                _D.At(0, 0, (_minIdx - 1) * (_minIdx - 1));
                _D.At(0, 1, _minIdx - 1);
                _D.At(1, 0, _minIdx * _minIdx);
                _D.At(1, 1, _minIdx);
                _D.At(2, 0, (_minIdx + 1) * (_minIdx + 1));
                _D.At(2, 1, (_minIdx + 1));

                _d.At(0, dx_n);
                _d.At(1, dx);
                _d.At(2, dx_p);

                _a = SvdSolver.Solve(_D, _d);
                bestDisp.SubDX = _a.At(0) * _minIdx * _minIdx + _a.At(1) * _minIdx + _a.At(2);

                _d.At(0, dy_n);
                _d.At(1, dy);
                _d.At(2, dy_p);

                _a = SvdSolver.Solve(_D, _d);
                bestDisp.SubDY = _a.At(0) * _minIdx * _minIdx + _a.At(1) * _minIdx + _a.At(2);
            }

            IntVector2 pm = bestDisp.GetMatchedPixel(pixelBase);

            DisparityMap.Set(pm.Y, pm.X, bestDisp);

            _dispForPixel = new List<Disparity>(2 * _dispForPixel.Count);
            _minIdx = 0;
            _min2Idx = 0;
            _minCost = double.PositiveInfinity;
            _min2Cost = double.PositiveInfinity;
        }
开发者ID:KFlaga,项目名称:Cam3D,代码行数:59,代码来源:InterpolationDisparityComputer.cs

示例12: DoConjugate

        /// <summary>
        /// Conjugates vector and save result to <paramref name="result"/>
        /// </summary>
        /// <param name="result">Target vector</param>
        protected override void DoConjugate(Vector<Complex32> result)
        {
            var sparseResult = result as SparseVector;
            if (sparseResult != null)
            {
                if (!ReferenceEquals(this, result))
                {
                    sparseResult._storage.ValueCount = _storage.ValueCount;
                    sparseResult._storage.Indices = new int[_storage.ValueCount];
                    Buffer.BlockCopy(_storage.Indices, 0, sparseResult._storage.Indices, 0, _storage.ValueCount*Constants.SizeOfInt);
                    sparseResult._storage.Values = new Complex32[_storage.ValueCount];
                    Array.Copy(_storage.Values, sparseResult._storage.Values, _storage.ValueCount);
                }

                Control.LinearAlgebraProvider.ConjugateArray(sparseResult._storage.Values, sparseResult._storage.Values);
                return;
            }

            result.Clear();
            for (var index = 0; index < _storage.ValueCount; index++)
            {
                result.At(_storage.Indices[index], _storage.Values[index].Conjugate());
            }
        }
开发者ID:Jungwon,项目名称:mathnet-numerics,代码行数:28,代码来源:SparseVector.cs

示例13: DoConjugateTransposeThisAndMultiply

        /// <summary>
        /// Multiplies the conjugate transpose of this matrix with a vector and places the results into the result vector.
        /// </summary>
        /// <param name="rightSide">The vector to multiply with.</param>
        /// <param name="result">The result of the multiplication.</param>
        protected override void DoConjugateTransposeThisAndMultiply(Vector<Complex32> rightSide, Vector<Complex32> result)
        {
            var d = Math.Min(ColumnCount, RowCount);
            if (d < ColumnCount)
            {
                result.ClearSubVector(RowCount, ColumnCount - RowCount);
            }

            if (d == RowCount)
            {
                var denseOther = rightSide.Storage as DenseVectorStorage<Complex32>;
                var denseResult = result.Storage as DenseVectorStorage<Complex32>;
                if (denseOther != null && denseResult != null)
                {
                    // TODO: merge/MulByConj
                    Control.LinearAlgebraProvider.ConjugateArray(_data, denseResult.Data);
                    Control.LinearAlgebraProvider.PointWiseMultiplyArrays(denseResult.Data, denseOther.Data, denseResult.Data);
                    return;
                }
            }

            for (var i = 0; i < d; i++)
            {
                result.At(i, _data[i].Conjugate()*rightSide.At(i));
            }
        }
开发者ID:rmundy,项目名称:mathnet-numerics,代码行数:31,代码来源:DiagonalMatrix.cs

示例14: FindDisparitiesCosts

        private void FindDisparitiesCosts(IntVector2 pb, Vector<double> epiLine)
        {
            epiLine.DivideThis(epiLine.At(1));
            IntVector2 pm = new IntVector2();
            int xmax = FindXmax(epiLine);
            int x0 = FindX0(epiLine);
            xmax = xmax - 1;

            for(int xm = x0 + 1; xm < xmax; ++xm)
            {
                double ym0 = FindYd(xm, epiLine);
                double ym1 = FindYd(xm + 1, epiLine);
                for(int ym = (int)ym0; ym < (int)ym1; ++ym)
                {
                    if(ImageMatched.HaveValueAt(ym, xm))
                    {
                        pm.X = xm;
                        pm.Y = ym;
                        double cost = CostComp.GetCost_Border(CurrentPixel, pm);
                        DispComp.StoreDisparity(CurrentPixel, pm, cost);
                    }
                }
            }
        }
开发者ID:KFlaga,项目名称:Cam3D,代码行数:24,代码来源:EpilineScanAggregator.cs

示例15: DoSubtract

        /// <summary>
        /// Subtracts another vector to this vector and stores the result into the result vector.
        /// </summary>
        /// <param name="other">
        /// The vector to subtract from this one.
        /// </param>
        /// <param name="result">
        /// The vector to store the result of the subtraction.
        /// </param>
        protected override void DoSubtract(Vector<Complex32> other, Vector<Complex32> result)
        {
            if (ReferenceEquals(this, other))
            {
                result.Clear();
                return;
            }

            var otherSparse = other as SparseVector;
            if (otherSparse == null)
            {
                base.DoSubtract(other, result);
                return;
            }

            var resultSparse = result as SparseVector;
            if (resultSparse == null)
            {
                base.DoSubtract(other, result);
                return;
            }

            // TODO (ruegg, 2011-10-11): Options to optimize?

            if (ReferenceEquals(this, resultSparse))
            {
                int i = 0, j = 0;
                while (i < NonZerosCount || j < otherSparse.NonZerosCount)
                {
                    if (i < NonZerosCount && j < otherSparse.NonZerosCount && _nonZeroIndices[i] == otherSparse._nonZeroIndices[j])
                    {
                        _nonZeroValues[i++] -= otherSparse._nonZeroValues[j++];
                    }
                    else if (j >= otherSparse.NonZerosCount || i < NonZerosCount && _nonZeroIndices[i] < otherSparse._nonZeroIndices[j])
                    {
                        i++;
                    }
                    else
                    {
                        var otherValue = otherSparse._nonZeroValues[j];
                        if (otherValue != Complex32.Zero)
                        {
                            InsertAtUnchecked(i++, otherSparse._nonZeroIndices[j], -otherValue);
                        }
                        j++;
                    }
                }
            }
            else
            {
                result.Clear();
                int i = 0, j = 0, last = -1;
                while (i < NonZerosCount || j < otherSparse.NonZerosCount)
                {
                    if (j >= otherSparse.NonZerosCount || i < NonZerosCount && _nonZeroIndices[i] <= otherSparse._nonZeroIndices[j])
                    {
                        var next = _nonZeroIndices[i];
                        if (next != last)
                        {
                            last = next;
                            result.At(next, _nonZeroValues[i] - otherSparse.At(next));
                        }
                        i++;
                    }
                    else
                    {
                        var next = otherSparse._nonZeroIndices[j];
                        if (next != last)
                        {
                            last = next;
                            result.At(next, At(next) - otherSparse._nonZeroValues[j]);
                        }
                        j++;
                    }
                }
            }
        }
开发者ID:kevkon3,项目名称:mathnet-numerics,代码行数:86,代码来源:SparseVector.cs


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