如何使用 JAMA 将矩阵乘以向量?
我正在尝试从双精度数组创建一个向量。然后我想将该向量乘以一个矩阵。有谁知道我怎样才能实现这一目标?下面是一个非常简单的例子,我想开始工作。
// 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
...
I'm trying to create a vector from an array of doubles. I then want to multiply this vector by a matrix. Does anyone know how I can achieve this? Below is a really simple example that I would like to get working.
// 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
...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下是所需操作的简单示例:
结果:
换句话说,即:
Here is simple example of wanted operation:
Result:
In other words that is:
为什么不能使用Matrix的arrayTimes方法?向量只是一个 1 xn 矩阵(我认为),所以你不能初始化第二个只有 1 维的矩阵并使用 arrayTimes 吗?
我认为通过阅读 doc 可以实现这一点。
Why can't you use Matrix's arrayTimes method? A vector is just a 1 x n matrix (I think) so can't you initialize a second matrix with just 1 dimension and use arrayTimes?
This is what I think would work from reading the doc.
怎么样:
来自 http://math.nist.gov/javanumerics/ jama/doc/Jama/Matrix.html
How about this:
From http://math.nist.gov/javanumerics/jama/doc/Jama/Matrix.html