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


C# Matrix.getArray方法代码示例

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


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

示例1: CholeskyDecomposition

 /* ------------------------
    Constructor
  * ------------------------ */
 /** Cholesky algorithm for symmetric and positive definite matrix.
 @param  A   Square, symmetric matrix.
 @return     Structure to access L and isspd flag.
 */
 public CholeskyDecomposition(Matrix Arg)
 {
     // Initialize.
       double[][] A = Arg.getArray();
       n = Arg.getRowDimension();
       L = new double[n][];
       for(int i = 0; i < n; i++)
       {
       L[n] = new double[n];
       }
       isspd = (Arg.getColumnDimension() == n);
       // Main loop.
       for (int j = 0; j < n; j++) {
      double[] Lrowj = L[j];
      double d = 0.0;
      for (int k = 0; k < j; k++) {
     double[] Lrowk = L[k];
     double s = 0.0;
     for (int i = 0; i < k; i++) {
        s += Lrowk[i]*Lrowj[i];
     }
     Lrowj[k] = s = (A[j][k] - s)/L[k][k];
     d = d + s*s;
     isspd = isspd & (A[k][j] == A[j][k]);
      }
      d = A[j][j] - d;
      isspd = isspd & (d > 0.0);
      L[j][j] = Math.Sqrt(Math.Max(d,0.0));
      for (int k = j+1; k < n; k++) {
     L[j][k] = 0.0;
      }
       }
 }
开发者ID:Edgarwma,项目名称:Reservoir,代码行数:40,代码来源:CholeskyDecomposition.cs

示例2: EigenvalueDecomposition

        /* ------------------------
           Constructor
         * ------------------------ */
        /** Check for symmetry, then construct the eigenvalue decomposition
           @param A    Square matrix
           @return     Structure to access D and V.
           */
        public EigenvalueDecomposition(Matrix Arg)
        {
            double[][] A = Arg.getArray();
              n = Arg.getColumnDimension();
              V = new double[n][];
              for(int i = 0; i < n ; i++)
              {
              V[i]= new double [n];
              }
              d = new double[n];
              e = new double[n];

              issymmetric = true;
              for (int j = 0; (j < n) & issymmetric; j++) {
             for (int i = 0; (i < n) & issymmetric; i++) {
            issymmetric = (A[i][j] == A[j][i]);
             }
              }

              if (issymmetric) {
             for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
               V[i][j] = A[i][j];
            }
             }

             // Tridiagonalize.
             tred2();

             // Diagonalize.
             tql2();

              } else {
             H = new double[n][];
             for(int i = 0; i < n ; i++)
             {
            H[i]= new double [n];
             }
             ort = new double[n];

             for (int j = 0; j < n; j++) {
            for (int i = 0; i < n; i++) {
               H[i][j] = A[i][j];
            }
             }

             // Reduce to Hessenberg form.
             orthes();

             // Reduce Hessenberg to real Schur form.
             hqr2();
              }
        }
开发者ID:Edgarwma,项目名称:Reservoir,代码行数:60,代码来源:EigenvalueDecomposition.cs

示例3: getS

 /** Return the diagonal matrix of singular values
 @return     S
 */
 public Matrix getS()
 {
     Matrix X = new Matrix(n, n);
     double[][] S = X.getArray();
     for (int i = 0; i < n; i++)
     {
         for (int j = 0; j < n; j++)
         {
             S[i][j] = 0.0;
         }
         S[i][i] = this.s[i];
     }
     return X;
 }
开发者ID:Edgarwma,项目名称:Reservoir,代码行数:17,代码来源:SingularValueDecomposition.cs

示例4: getD

 /** Return the block diagonal eigenvalue matrix
    @return     D
    */
 public Matrix getD()
 {
     Matrix X = new Matrix(n,n);
       double[][] D = X.getArray();
       for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
     D[i][j] = 0.0;
      }
      D[i][i] = d[i];
      if (e[i] > 0) {
     D[i][i+1] = e[i];
      } else if (e[i] < 0) {
     D[i][i-1] = e[i];
      }
       }
       return X;
 }
开发者ID:Edgarwma,项目名称:Reservoir,代码行数:20,代码来源:EigenvalueDecomposition.cs

示例5: getU

 /** Return upper triangular factor
 @return     U
 */
 public Matrix getU()
 {
     Matrix X = new Matrix(n, n);
     double[][] U = X.getArray();
     for (int i = 0; i < n; i++)
     {
         for (int j = 0; j < n; j++)
         {
             if (i <= j)
             {
                 U[i][j] = LU[i][j];
             }
             else
             {
                 U[i][j] = 0.0;
             }
         }
     }
     return X;
 }
开发者ID:Edgarwma,项目名称:Reservoir,代码行数:23,代码来源:LUDecomposition.cs

示例6: getL

 /** Return lower triangular factor
 @return     L
 */
 public Matrix getL()
 {
     Matrix X = new Matrix(m, n);
     double[][] L = X.getArray();
     for (int i = 0; i < m; i++)
     {
         for (int j = 0; j < n; j++)
         {
             if (i > j)
             {
                 L[i][j] = LU[i][j];
             }
             else if (i == j)
             {
                 L[i][j] = 1.0;
             }
             else
             {
                 L[i][j] = 0.0;
             }
         }
     }
     return X;
 }
开发者ID:Edgarwma,项目名称:Reservoir,代码行数:27,代码来源:LUDecomposition.cs


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