贾马如何改变矩阵?

时间:2013-03-04 09:12:57

标签: java matrix jama

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

如何在Jama洗牌?

也有类似的东西:

Matrix(:,end)

在Matlab上只得到最后一列?

1 个答案:

答案 0 :(得分:0)

文档(至少是类的文档)是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并不过分复杂。将getColumn()方法添加到Matrix.java非常容易。