我在Java中使用Jama进行矩阵操作。然而,我看不到关于它的充分文档。
我如何在Jama中对矩阵进行混洗?
还有类似这样的东西吗:
Matrix(:,end)像在Matlab中一样只获取最后一列?
发布于 2013-03-04 20:07:07
文档(好吧,至少是类的文档)是here:http://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()方法应该非常容易。
https://stackoverflow.com/questions/15198016
复制相似问题