简体   繁体   English

在Java中查找2d n * n矩阵的逆?

[英]Finding inverse of 2d n*n matrix in Java?

I have just printed the matrix of size n*n 我刚刚打印了尺寸为n * n的矩阵

Code is (Assume that all matrices are already defined): 代码是(假设已经定义了所有矩阵):

public class ReadContents { 
    public static void main(String args[]) {
        System.out.println();
        System.out.println("The Matrix Is:");
        double mat[][]=new double[col][col];

        for(k=0;k<col;k++) {
            for(p=0;p<col;p++) {
                mat[k][p]=SubMULTIPL_1[k][p]-ADD[k][p];
                System.out.printf("%2.2f  ",mat[k][p]);
            }

            System.out.println();
        }
    }

But, I am having the problem of finding the inverse of n*n square matrix 但是,我遇到了找到n * n方阵的逆的问题
where n=1,2,3..........infinite. 其中n = 1,2,3 ..........无限。

Any help would be appreciated. 任何帮助,将不胜感激。

  • Some Java matrix math libraries can do the job. 一些Java矩阵数学可以完成这项工作。

  • Not every matrix is invertible perhaps you should test if this condition is met. 不是每个矩阵都是可逆的,也许你应该测试是否满足这个条件。

You probably don't want the inverse. 你可能不希望逆。

I'm betting that you really want to know how to solve a system of equations. 我打赌你真的想知道如何解决方程组。 I'd recommend that you look at LU decomposition rather than inverse or Gaussian elimination. 我建议您查看LU分解而不是逆或高斯消除。 It's more stable. 它更稳定。

You'll have a hard time inverting a matrix if the determinant of the matrix is zero or VERY small. 如果矩阵的行列式为零或非常小,您将很难反转矩阵。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM