@Test public void testSolveFToD() { double[][] data = { new double[] {1.0,2.0}, new double[] {3.0,5.0}}; RealMatrix M = new Array2DRowRealMatrix(data, false); LinearSystemSolver cmLinearSystemSolver = new CommonsMathLinearSystemSolver(); Solver solver = cmLinearSystemSolver.getSolver(M); assertArrayEquals(new double[] {-12.0,7.0}, solver.solveFToD(new float[] {2.0f, -1.0f})); }
@Override public Solver getSolver(RealMatrix M) { if (M == null) { return null; } RRQRDecomposition decomposition = new RRQRDecomposition(M, SINGULARITY_THRESHOLD); DecompositionSolver solver = decomposition.getSolver(); if (solver.isNonSingular()) { return new CommonsMathSolver(solver); } int apparentRank = decomposition.getRank(0.01); log.warn("{} x {} matrix is near-singular (threshold {}). Add more data or decrease the value of model.features, " + "to <= about {}", M.getRowDimension(), M.getColumnDimension(), SINGULARITY_THRESHOLD, apparentRank); throw new SingularMatrixSolverException(apparentRank, "Apparent rank: " + apparentRank); }
CommonsMathLinearSystemSolver implements LinearSystemSolver { @Override public Solver getSolver(RealMatrix M) { if (M == null) { return null; } RRQRDecomposition decomposition = new RRQRDecomposition(M, SINGULARITY_THRESHOLD); DecompositionSolver solver = decomposition.getSolver(); if (solver.isNonSingular()) { return new CommonsMathSolver(solver); } int apparentRank = decomposition.getRank(0.01); log.warn("{} x {} matrix is near-singular (threshold {}). Add more data or decrease the value of model.features, " + "to <= about {}", M.getRowDimension(), M.getColumnDimension(), SINGULARITY_THRESHOLD, apparentRank); throw new SingularMatrixSolverException(apparentRank, "Apparent rank: " + apparentRank); } }
CommonsMathLinearSystemSolver implements LinearSystemSolver { @Override public Solver getSolver(RealMatrix M) { if (M == null) { return null; } RRQRDecomposition decomposition = new RRQRDecomposition(M, SINGULARITY_THRESHOLD); DecompositionSolver solver = decomposition.getSolver(); if (solver.isNonSingular()) { return new CommonsMathSolver(solver); } int apparentRank = decomposition.getRank(0.01); log.warn("{} x {} matrix is near-singular (threshold {}). Add more data or decrease the value of model.features, " + "to <= about {}", M.getRowDimension(), M.getColumnDimension(), SINGULARITY_THRESHOLD, apparentRank); throw new SingularMatrixSolverException(apparentRank, "Apparent rank: " + apparentRank); }  }
CommonsMathLinearSystemSolver implements LinearSystemSolver { @Override public Solver getSolver(RealMatrix M) { if (M == null) { return null; } RRQRDecomposition decomposition = new RRQRDecomposition(M, SINGULARITY_THRESHOLD); DecompositionSolver solver = decomposition.getSolver(); if (solver.isNonSingular()) { return new CommonsMathSolver(solver); } int apparentRank = decomposition.getRank(0.01); log.warn("{} x {} matrix is near-singular (threshold {}). Add more data or decrease the value of model.features, " + "to <= about {}", M.getRowDimension(), M.getColumnDimension(), SINGULARITY_THRESHOLD, apparentRank); throw new SingularMatrixSolverException(apparentRank, "Apparent rank: " + apparentRank); }  @Override Solver getSolver(RealMatrix M); @Override boolean isNonSingular(RealMatrix M); }
CommonsMathLinearSystemSolver implements LinearSystemSolver { @Override public Solver getSolver(RealMatrix M) { if (M == null) { return null; } RRQRDecomposition decomposition = new RRQRDecomposition(M, SINGULARITY_THRESHOLD); DecompositionSolver solver = decomposition.getSolver(); if (solver.isNonSingular()) { return new CommonsMathSolver(solver); } int apparentRank = decomposition.getRank(0.01); log.warn("{} x {} matrix is near-singular (threshold {}). Add more data or decrease the value of model.features, " + "to <= about {}", M.getRowDimension(), M.getColumnDimension(), SINGULARITY_THRESHOLD, apparentRank); throw new SingularMatrixSolverException(apparentRank, "Apparent rank: " + apparentRank); }  @Override Solver getSolver(RealMatrix M); @Override boolean isNonSingular(RealMatrix M);  }