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


C# MatrixF.Set方法代码示例

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


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

示例1: SetWithListShouldThrowArgumentNullException

 public void SetWithListShouldThrowArgumentNullException()
 {
     var m = new MatrixF();
       m.Set((IList<float>)null, MatrixOrder.RowMajor);
 }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:5,代码来源:MatrixFTest.cs

示例2: SetWith2DJaggedArrayShouldThrowArgumentNullException

 public void SetWith2DJaggedArrayShouldThrowArgumentNullException()
 {
     var m = new MatrixF();
       m.Set((float[][])null);
 }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:5,代码来源:MatrixFTest.cs

示例3: SetWithArrayShouldThrowArgumentNullException

 public void SetWithArrayShouldThrowArgumentNullException()
 {
     var m = new MatrixF();
       m.Set((float[])null, MatrixOrder.ColumnMajor);
 }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:5,代码来源:MatrixFTest.cs

示例4: SetException2

 public void SetException2()
 {
     MatrixF m = null;
       MatrixF n = new MatrixF(1, 1);
       n.Set(m);
 }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:6,代码来源:MatrixFTest.cs

示例5: SetException1

 public void SetException1()
 {
     MatrixF m = new MatrixF(4, 3);
       m.Set(new MatrixF(1, 2, 777));
 }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:5,代码来源:MatrixFTest.cs

示例6: Set

        public void Set()
        {
            MatrixF m = new MatrixF(3, 4);
              MatrixF m2 = new MatrixF(3, 4, rowMajor, MatrixOrder.RowMajor);
              m.Set(m2);
              for (int i = 0; i < 12; i++)
            Assert.AreEqual(rowMajor[i], m[i]);
              m[0] = 10;  // Test if original matrix is unchanged.
              Assert.AreEqual(1, m2[0]);

              m.Set(777);
              for (int i = 0; i < 12; i++)
            Assert.AreEqual(777, m[i]);

              m.Set(0);
              for (int i = 0; i < 12; i++)
            Assert.AreEqual(0, m[i]);
              m.Set(columnMajor, MatrixOrder.ColumnMajor);
              for (int i = 0; i < 12; i++)
            Assert.AreEqual(rowMajor[i], m[i]);

              m.Set(0);
              m.Set(rowMajor, MatrixOrder.RowMajor);
              for (int i = 0; i < 12; i++)
            Assert.AreEqual(rowMajor[i], m[i]);

              m.Set(0);
              m.Set(new List<float>(columnMajor), MatrixOrder.ColumnMajor);
              for (int i = 0; i < 12; i++)
            Assert.AreEqual(rowMajor[i], m[i]);

              m.Set(0);
              m.Set(new List<float>(rowMajor), MatrixOrder.RowMajor);
              for (int i = 0; i < 12; i++)
            Assert.AreEqual(rowMajor[i], m[i]);

              m.Set(0);
              m.Set(new float[3, 4] { { 1, 2, 3, 4 },
                              { 5, 6, 7, 8 },
                              { 9, 10, 11, 12 }});
              for (int i = 0; i < 12; i++)
            Assert.AreEqual(rowMajor[i], m[i]);

              m.Set(0);
              m.Set(new float[3][] { new float[4] { 1, 2, 3, 4 },
                             new float[4] { 5, 6, 7, 8 },
                             new float[4] { 9, 10, 11, 12 }});
              for (int i = 0; i < 12; i++)
            Assert.AreEqual(rowMajor[i], m[i]);
        }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:50,代码来源:MatrixFTest.cs

示例7: SingularValueDecompositionF

        public SingularValueDecompositionF(MatrixF matrixA)
        {
            if (matrixA == null)
            throw new ArgumentNullException("matrixA");

              // Derived from LINPACK code.
              // Initialize.
              _m = matrixA.NumberOfRows;
              _n = matrixA.NumberOfColumns;
              MatrixF matrixAClone = matrixA.Clone();

              if (_m < _n)
            throw new ArgumentException("The number of rows must be greater than or equal to the number of columns.", "matrixA");

              int nu = Math.Min(_m, _n);
              _s = new VectorF(Math.Min(_m + 1, _n));
              _u = new MatrixF(_m, nu);     //Jama getU() returns new Matrix(U,_m,Math.min(_m+1,_n)) ?!
              _v = new MatrixF(_n, _n);
              float[] e = new float[_n];
              float[] work = new float[_m];

              // Abort if A contains NaN values.
              // If we continue with NaN values, we run into an infinite loop.
              for (int i = 0; i < _m; i++)
              {
            for (int j = 0; j < _n; j++)
            {
              if (Numeric.IsNaN(matrixA[i, j]))
              {
            _u.Set(float.NaN);
            _v.Set(float.NaN);
            _s.Set(float.NaN);
            return;
              }
            }
              }

              // By default, we calculate U and V. To calculate only U or V we can set one of the following
              // two constants to false. (This optimization is not yet tested.)
              const bool wantu = true;
              const bool wantv = true;

              // Reduce A to bidiagonal form, storing the diagonal elements
              // in s and the super-diagonal elements in e.

              int nct = Math.Min(_m - 1, _n);
              int nrt = Math.Max(0, Math.Min(_n - 2, _m));
              for (int k = 0; k < Math.Max(nct, nrt); k++)
              {
            if (k < nct)
            {
              // Compute the transformation for the k-th column and
              // place the k-th diagonal in s[k].
              // Compute 2-norm of k-th column without under/overflow.
              _s[k] = 0;
              for (int i = k; i < _m; i++)
            _s[k] = MathHelper.Hypotenuse(_s[k], matrixAClone[i, k]);

              if (_s[k] != 0)
              {
            if (matrixAClone[k, k] < 0)
              _s[k] = -_s[k];

            for (int i = k; i < _m; i++)
              matrixAClone[i, k] /= _s[k];

            matrixAClone[k, k] += 1;
              }

              _s[k] = -_s[k];
            }
            for (int j = k + 1; j < _n; j++)
            {
              if ((k < nct) && (_s[k] != 0))
              {
            // Apply the transformation.
            float t = 0;
            for (int i = k; i < _m; i++)
              t += matrixAClone[i, k] * matrixAClone[i, j];

            t = -t / matrixAClone[k, k];
            for (int i = k; i < _m; i++)
              matrixAClone[i, j] += t * matrixAClone[i, k];
              }

              // Place the k-th row of A into e for the
              // subsequent calculation of the row transformation.

              e[j] = matrixAClone[k, j];
            }

            if (wantu & (k < nct))
            {
              // Place the transformation in U for subsequent back
              // multiplication.
              for (int i = k; i < _m; i++)
            _u[i, k] = matrixAClone[i, k];
            }

            if (k < nrt)
//.........这里部分代码省略.........
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:101,代码来源:SingularValueDecompositionF.cs

示例8: EigenvalueDecompositionF

        //--------------------------------------------------------------
        /// <summary>
        /// Creates the eigenvalue decomposition of the given matrix.
        /// </summary>
        /// <param name="matrixA">The square matrix A.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="matrixA"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// <paramref name="matrixA"/> is non-square (rectangular).
        /// </exception>
        public EigenvalueDecompositionF(MatrixF matrixA)
        {
            if (matrixA == null)
            throw new ArgumentNullException("matrixA");
              if (matrixA.IsSquare == false)
            throw new ArgumentException("The matrix A must be square.", "matrixA");

              _n = matrixA.NumberOfColumns;
              _d = new VectorF(_n);
              _e = new VectorF(_n);

              _isSymmetric = matrixA.IsSymmetric;

              if (_isSymmetric)
              {
            _v = matrixA.Clone();

            // Tridiagonalize.
            ReduceToTridiagonal();

            // Diagonalize.
            TridiagonalToQL();
              }
              else
              {
            _v = new MatrixF(_n, _n);

            // Abort if A contains NaN values.
            // If we continue with NaN values, we run into an infinite loop.
            for (int i = 0; i < _n; i++)
            {
              for (int j = 0; j < _n; j++)
              {
            if (Numeric.IsNaN(matrixA[i, j]))
            {
              _e.Set(float.NaN);
              _v.Set(float.NaN);
              _d.Set(float.NaN);
              return;
            }
              }
            }

            // Storage of nonsymmetric Hessenberg form.
            MatrixF matrixH = matrixA.Clone();
            // Working storage for nonsymmetric algorithm.
            float[] ort = new float[_n];

            // Reduce to Hessenberg form.
            ReduceToHessenberg(matrixH, ort);

            // Reduce Hessenberg to real Schur form.
            HessenbergToRealSchur(matrixH);
              }
        }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:66,代码来源:EigenvalueDecompositionF.cs


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