如何使用JAMA将矩阵乘以向量?

The*_*imp 5 java vector matrix jama matrix-multiplication

我正在尝试从双打数组中创建一个向量.然后我想用矩阵乘以这个向量.有谁知道我怎么能做到这一点?下面是一个非常简单的例子,我想开始工作.

// Create the matrix (using JAMA)
Matrix a = new Matrix( [[1,2,3],[1,2,3],[1,2,3]] );

// Create a vector out of an array
...

// Multiply the vector by the matrix
...
Run Code Online (Sandbox Code Playgroud)

Grz*_*ski 12

这是想要操作的简单示例:

double[][] array = {{1.,2.,3},{1.,2.,3.},{1.,2.,3.}}; 
Matrix a = new Matrix(array);   
Matrix b = new Matrix(new double[]{1., 1., 1.}, 1);     
Matrix c = b.times(a);  
System.out.println(Arrays.deepToString(c.getArray()));
Run Code Online (Sandbox Code Playgroud)

结果:

[[3.0, 6.0, 9.0]]
Run Code Online (Sandbox Code Playgroud)

换句话说就是:

在此输入图像描述