我是Java的新手, 目前,我正在练习Java的一些代码。所以我正在尝试自己创建一个Matrix类。但是,我指的是来自jama的代码(http://math.nist.gov/javanumerics/jama/doc/Jama/Matrix.html)。 但我觉得很奇怪。这里是后面部分定义的Matrix类的结构。请帮我解释Java转换矩阵机制(代码附后)
有人可以帮我解释为什么转置()返回X(在我的想法中,C数组是X的元素,X的元素是相同的顺序,但为什么jama返回X,以及C-在这个程序中的数组?)。 非常感谢。
public class Matrix
{
private double[][] A;// 2-D array to hold matrix element
private m,n ; // number of column and row.
// Some constructors but I would like to omit
//public methods:
// I don't understand this:
public Matrix transpose() {
Matrix X = new Matrix(n,m);
double[][] C = X.getArray();
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
C[j][i] = A[i][j];
}
}
return X; // While it returns X? seem that X does not transpose but C.
// it seems there is no connection between X and C. what is the role of C here?
}
public double[][] getArray() {
return A;
}
}
[transpose double \ [\] \ [\] matrix with a java function?]的可能的副本(http://stackoverflow.com/questions/15449711/transpose-double-matrix-with-a-java-function ) –