我正在开发一个关于矩阵的小应用程序,并且正在使用 class jama。我在打印LU分解时遇到了一个小问题,希望对您有所帮助。这是我的应用程序的代码我错过了显示 LU 分解的部分
import java.util.Scanner;
import Jama.*;
public class autovalori {
public static void main(String[] args) {
double[][] matrix;
int n;
Scanner scanner = new Scanner(System.in);
System.out.println("Matrix size");
n = scanner.nextInt();
matrix = new double[n][n];
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
System.out.printf("Value: " + i + " - " + j);
System.out.printf("\n");
matrix[i][j] = scanner.nextInt();
}
}
Matrix A = new Matrix(matrix);
EigenvalueDecomposition E = new EigenvalueDecomposition(A);
double[] d = E.getRealEigenvalues();
System.out.println("Rango " + A.rank());
for (int i = 0; i < n; i++){
System.out.println("Eigenvalue " + d[i]);
}
LUDecomposition LU = new LUDecomposition(A);
Matrix L = LU.getL();
Matrix U = LU.getU();
int[] p = LU.getPivot();
}
}