java java中矩阵的逆
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10686197/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Inverse of a matrix in java
提问by thetna
I would like to calculate an inverse of matrix in java. Are there any already existing packages which calculate inverse of matrix. I found similar question, but the answers in the questions are not so strongly recommending to use anyof the packages. Even i could not follow the method they are using. I have a large matrix of 10000s of rows and columns. I would like to calculate inverse of it.
我想在java中计算矩阵的逆。是否有任何已经存在的软件包可以计算矩阵的逆。我发现了类似的问题,但问题中的答案并不是强烈建议使用任何软件包。即使我无法遵循他们使用的方法。我有一个由 10000 行和列组成的大矩阵。我想计算它的逆。
采纳答案by jlengrand
I think you should give a shot to JAMA
我认为你应该给JAMA 试一试
The documentation presents an inverse function for matrices http://math.nist.gov/javanumerics/jama/doc/
该文档提供了矩阵的反函数 http://math.nist.gov/javanumerics/jama/doc/
Seeing the size of your matrix though, You WILL have to factorize it first .
但是,看到矩阵的大小,您必须先将其分解。
回答by JustDanyul
Apache Commons Math have support for linear algebra
Apache Commons Math 支持线性代数
回答by Vladimir Kostyukov
The la4j(Linear Algebra for Java) library supports matrix inversion. Here is the short example:
所述la4j(线性代数为Java)库支持矩阵求逆。这是一个简短的例子:
Matrix a = new Basic2DMatrix(new double[][]{
{ 1.0, 2.0, 3.0 },
{ 4.0, 5.0, 6.0 },
{ 7.0, 8.0. 9.0 }
});
Matrix b = a.invert(Matrices.DEFAULT_INVERTOR); // uses Gaussian Elimination
回答by user2068018
there is a example in github used Linear Algebra for Java
github 中有一个例子使用了 Java 的线性代数
Matrix a =
factory.createMatrix(new RandomMatrixSource(SIZE,SIZE));
MatrixInverter inverter = a.withInverter(LinearAlgebra.GAUSS_JORDAN);
Matrix e = inverter.inverse(factory);