【问题标题】:Jama How to Shuffle Matrix?Jama 如何洗牌?
【发布时间】:2013-03-04 09:12:57
【问题描述】:

我在 Java 中使用 Jama 进行矩阵操作。但是我看不到足够的文档。

如何在 Jama 洗牌矩阵?

还有类似的:

Matrix(:,end)

像在 Matlab 中一样只获取最后一列?

【问题讨论】:

    标签: java matrix jama


    【解决方案1】:

    文档(嗯,至少是类的文档)是herehttp://math.nist.gov/javanumerics/jama/doc/

    Matrix 类有一个方法getMatrix() 来提取子矩阵:

    /** Get a submatrix.
       @param r    Array of row indices.
       @param c    Array of column indices.
       @return     A(r(:),c(:))
       @exception  ArrayIndexOutOfBoundsException Submatrix indices
       */
    
       public Matrix getMatrix (int[] r, int[] c) {
          Matrix X = new Matrix(r.length,c.length);
          double[][] B = X.getArray();
          try {
             for (int i = 0; i < r.length; i++) {
                for (int j = 0; j < c.length; j++) {
                   B[i][j] = A[r[i]][c[j]];
                }
             }
          } catch(ArrayIndexOutOfBoundsException e) {
             throw new ArrayIndexOutOfBoundsException("Submatrix indices");
          }
          return X;
       }
    

    Jama 并不过分复杂。在Matrix.java 中添加getColumn() 方法应该很容易。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-28
      • 2011-10-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-14
      相关资源
      最近更新 更多