2013-10-13 21 views

回答

1

1D矩陣不包含有關他們如何定向的任何信息。因此,您需要提供這些信息才能進行轉置。例如,如果您使用的是行向量,則您有一個1xm矩陣,因此您需要一個mx1列向量來包含轉置。

試試這個:

DoubleMatrix2D transpose = new DenseDoubleMatrix2D(4,1); 
for (int i=0; i<4; i++) { 
    transpose.setQuick(i,0,array.getQuick(i)); 
} 

相反,如果你有一列向量,轉置將是一個行向量:

DoubleMatrix2D transpose = new DenseDoubleMatrix2D(1,4); 
for (int i=0; i<4; i++) { 
    transpose.setQuick(0,i,array.getQuick(i)); 
} 
0

這意味着在DoubleMatrix1D類中,方法viewDice()不存在!所以你幾乎不能使用它:)。

根據文檔,你可以這樣做:

double[] toArray() 
      Constructs and returns a 1-dimensional array containing the cell values. 

或者,也許這樣的:

DoubleMatrix1D copy() 
      Constructs and returns a deep copy of the receiver. 
相關問題