0

過剰に決定されたシステムの最小二乗を計算しようとしています。

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 の leastSquares を返すには、何を呼び出す必要がありますか?

4

1 に答える 1

0

長方形の行列を反転しようとしているようです。正方行列のみを反転できます。それも最善の解決方法ではありません。マニュアルから以下のリンクを参照してください。

https://code.google.com/p/effective-java-matrix-library/wiki/SolvingLinearSystems

于 2014-12-05T00:54:15.077 に答える