@Test public void testSolve() { System.out.println("solve"); NLMatrix a = new NLMatrix(A); QR result = a.qr(); result.solve(b.clone(), b); for (int i = 0; i < x.length; i++) { assertEquals(x[i], b[i], 1E-7); } }
@Override public void solve(double[] b, double[] x) { if (b.length != qr.nrows()) { throw new IllegalArgumentException(String.format("Row dimensions do not agree: A is %d x %d, but B is %d x 1", qr.nrows(), qr.nrows(), b.length)); } if (x.length != qr.ncols()) { throw new IllegalArgumentException("A and x dimensions don't match."); } if (singular) { throw new RuntimeException("Matrix is rank deficient."); } double[] B = b.clone(); solve(Matrix.of(B)); System.arraycopy(B, 0, x, 0, x.length); }
QR extends smile.math.matrix.QR { @Override public void solve(double[] b, double[] x) { if (b.length != qr.nrows()) { throw new IllegalArgumentException(String.format("Row dimensions do not agree: A is %d x %d, but B is %d x 1", qr.nrows(), qr.nrows(), b.length)); } if (x.length != qr.ncols()) { throw new IllegalArgumentException("A and x dimensions don't match."); } if (singular) { throw new RuntimeException("Matrix is rank deficient."); } double[] B = b.clone(); solve(Matrix.of(B)); System.arraycopy(B, 0, x, 0, x.length); } }
QR extends smile.math.matrix.QR { @Override public void solve(double[] b, double[] x) { if (b.length != qr.nrows()) { throw new IllegalArgumentException(String.format("Row dimensions do not agree: A is %d x %d, but B is %d x 1", qr.nrows(), qr.nrows(), b.length)); } if (x.length != qr.ncols()) { throw new IllegalArgumentException("A and x dimensions don't match."); } if (singular) { throw new RuntimeException("Matrix is rank deficient."); } double[] B = b.clone(); solve(Matrix.of(B)); System.arraycopy(B, 0, x, 0, x.length); } QR(NLMatrix qr, double[] tau, boolean singular); }
QR extends smile.math.matrix.QR { @Override public void solve(double[] b, double[] x) { if (b.length != qr.nrows()) { throw new IllegalArgumentException(String.format("Row dimensions do not agree: A is %d x %d, but B is %d x 1", qr.nrows(), qr.nrows(), b.length)); } if (x.length != qr.ncols()) { throw new IllegalArgumentException("A and x dimensions don't match."); } if (singular) { throw new RuntimeException("Matrix is rank deficient."); } double[] B = b.clone(); solve(Matrix.of(B)); System.arraycopy(B, 0, x, 0, x.length); } QR(NLMatrix qr, double[] tau, boolean singular); @Override Cholesky CholeskyOfAtA(); @Override DenseMatrix getR(); @Override DenseMatrix getQ(); @Override void solve(double[] b, double[] x); @Override void solve(DenseMatrix B); }
QR extends smile.math.matrix.QR { @Override public void solve(double[] b, double[] x) { if (b.length != qr.nrows()) { throw new IllegalArgumentException(String.format("Row dimensions do not agree: A is %d x %d, but B is %d x 1", qr.nrows(), qr.nrows(), b.length)); } if (x.length != qr.ncols()) { throw new IllegalArgumentException("A and x dimensions don't match."); } if (singular) { throw new RuntimeException("Matrix is rank deficient."); } double[] B = b.clone(); solve(Matrix.of(B)); System.arraycopy(B, 0, x, 0, x.length); } QR(NLMatrix qr, double[] tau, boolean singular); @Override Cholesky CholeskyOfAtA(); @Override DenseMatrix getR(); @Override DenseMatrix getQ(); @Override void solve(double[] b, double[] x); @Override void solve(DenseMatrix B);  }