0

我总共有 4 个列向量,如下所示:

m1:       m2:        m3:      m4:

0.26      -0.25      0.04     0.43
-0.20     -0.12      0.50     0.47
-0.27      0.79     -0.37     0.29
-0.06     -0.45     -0.71     0.44
-0.23      0.13      0.31     0.52
 0.87      0.29      0.02     0.23

我想组合这 4 个列向量并将它们放在一个 6x4 矩阵中。我如何在 JAMA 中实现这一目标?所有四列矩阵都是矩阵类型。

4

1 回答 1

0

自己想出了答案。基本上,我们使用setMatrix()具有以下签名的方法的变体:

setMatrix(int[] r, int j0, int j1, Matrix X)
where,
r = array of row indices
j0 = initial column index
j1 = final column index
X = matrix you want to insert i.e. m1/m2/m3/m4 in my case

要在我的矩阵(比如)meu 的第一列中设置 m1,我可以将其编码如下:

int[] r = {0, 1, 2, 3, 4, 5) // since each of m1, m2, m3 and m4 have 6 rows
meu.setMatrix(r, 0, 0, m1); //sets submatrix m1 to 1st column (hence j0=j1=0)

要在 meu 的第二列中设置 m2,我会:

meu.setMatrix(r, 1, 1, m2); //sets submatrix m2 to 2nd column

.... 其余的也是如此。

于 2016-11-24T00:03:19.773 回答