我正在尝试为过度确定的系统计算最小二乘法。
DenseMatrix64F D_dense = RandomMatrices.createRandom(dimension, 3 * dimension, -1, 1, r);
D1 = SimpleMatrix.wrap(D1).transpose().getMatrix();
LinearSolver<DenseMatrix64F> x2 = LinearSolverFactory.leastSquares(D1.numRows, D1.numCols);
x2.setA(D1);
DenseMatrix64F D_i = new DenseMatrix64F(D1.numRows, D1.numCols);
x2.invert(D_i);
但后来我收到了错误
Exception in thread "main" java.lang.IllegalArgumentException: Unexpected dimensions for X: X rows = 9 expected = 3
我需要调用哪些内容才能返回Matrix D1的最小方块?
答案 0 :(得分:0)
看起来你正试图反转一个矩形矩阵。您只能反转方阵。这也不是最好的解决方法。请参阅手册中的以下链接:
https://code.google.com/p/efficient-java-matrix-library/wiki/SolvingLinearSystems