/** {@inheritDoc} */ public RealVector solve(RealVector b) { return p.operate(upper.solve(b)); }
/** {@inheritDoc} */ public RealMatrix solve(RealMatrix b) { return p.multiply(upper.solve(b)); }
@Override protected RealVector solve(final RealMatrix jacobian, final RealVector residuals) { return new SingularValueDecomposition(jacobian) .getSolver() .solve(residuals); } };
public double[] solveDToD(double[] b) { RealVector bVec = new ArrayRealVector(b, false); return solver.solve(bVec).toArray(); }
/** * Calculates the regression coefficients using OLS. * * <p>Data for the model must have been successfully loaded using one of * the {@code newSampleData} methods before invoking this method; otherwise * a {@code NullPointerException} will be thrown.</p> * * @return beta * @throws org.apache.commons.math3.linear.SingularMatrixException if the design matrix is singular * @throws NullPointerException if the data for the model have not been loaded */ @Override protected RealVector calculateBeta() { return qr.getSolver().solve(getY()); }
@Override protected RealVector solve(final RealMatrix jacobian, final RealVector residuals) { try { return new QRDecomposition(jacobian, SINGULARITY_THRESHOLD) .getSolver() .solve(residuals); } catch (SingularMatrixException e) { throw new ConvergenceException(LocalizedFormats.UNABLE_TO_SOLVE_SINGULAR_PROBLEM, e); } } },
public float[] solveFToF(float[] b) { RealVector bVec = new ArrayRealVector(b.length); for (int i = 0; i < b.length; i++) { bVec.setEntry(i, b[i]); } RealVector resultVec = solver.solve(bVec); float[] result = new float[resultVec.getDimension()]; for (int i = 0; i < result.length; i++) { result[i] = (float) resultVec.getEntry(i); } return result; }
@Override protected RealVector solve(final RealMatrix jacobian, final RealVector residuals) { try { final Pair<RealMatrix, RealVector> normalEquation = computeNormalMatrix(jacobian, residuals); final RealMatrix normal = normalEquation.getFirst(); final RealVector jTr = normalEquation.getSecond(); return new LUDecomposition(normal, SINGULARITY_THRESHOLD) .getSolver() .solve(jTr); } catch (SingularMatrixException e) { throw new ConvergenceException(LocalizedFormats.UNABLE_TO_SOLVE_SINGULAR_PROBLEM, e); } } },
@Override protected RealVector solve(final RealMatrix jacobian, final RealVector residuals) { try { final Pair<RealMatrix, RealVector> normalEquation = computeNormalMatrix(jacobian, residuals); final RealMatrix normal = normalEquation.getFirst(); final RealVector jTr = normalEquation.getSecond(); return new CholeskyDecomposition( normal, SINGULARITY_THRESHOLD, SINGULARITY_THRESHOLD) .getSolver() .solve(jTr); } catch (NonPositiveDefiniteMatrixException e) { throw new ConvergenceException(LocalizedFormats.UNABLE_TO_SOLVE_SINGULAR_PROBLEM, e); } } },
/** * * @return * @throws Exception */ // LeastSquare use commons-math3 protected List<Double> LeastSquaretrainModel() throws Exception { double[][] myList = getMList(); double[] yList = getYList(); RealMatrix coefficients = new Array2DRowRealMatrix(myList, false); DecompositionSolver solver = new LUDecomposition(coefficients).getSolver(); RealVector constants = new ArrayRealVector(yList, false); RealVector solution = solver.solve(constants); this.weightList = getAlgorithmWeight(solution); return this.weightList; }
/** * Used for computing the actual transformations (A and B matrices). These * are stored in As and Bs. */ private void computeMllrTransforms(double[][][][][] regLs, double[][][][] regRs) { int len; DecompositionSolver solver; RealMatrix coef; RealVector vect, ABloc; for (int c = 0; c < nrOfClusters; c++) { this.As[c] = new float[loader.getNumStreams()][][]; this.Bs[c] = new float[loader.getNumStreams()][]; for (int i = 0; i < loader.getNumStreams(); i++) { len = loader.getVectorLength()[i]; this.As[c][i] = new float[len][len]; this.Bs[c][i] = new float[len]; for (int j = 0; j < len; ++j) { coef = new Array2DRowRealMatrix(regLs[c][i][j], false); solver = new LUDecomposition(coef).getSolver(); vect = new ArrayRealVector(regRs[c][i][j], false); ABloc = solver.solve(vect); for (int k = 0; k < len; ++k) { this.As[c][i][j][k] = (float) ABloc.getEntry(k); } this.Bs[c][i][j] = (float) ABloc.getEntry(len); } } } }
final RealMatrix x = decomposition.getSolver().solve(new Array2DRowRealMatrix(b, false));
.solve(measurementMatrix.multiply(errorCovariance.transpose())) .transpose();
new LUDecomposition(mA).getSolver() : new QRDecomposition(mA).getSolver(); final double[] dX = solver.solve(new ArrayRealVector(b, false)).toArray();
new LUDecomposition(mA).getSolver() : new QRDecomposition(mA).getSolver(); final double[] dX = solver.solve(new ArrayRealVector(b, false)).toArray();
/** * {@inheritDoc} */ @Override public DoubleMatrix solve(DoubleMatrix b) { ArgChecker.notNull(b, "b"); return CommonsMathWrapper.unwrap(_solver.solve(CommonsMathWrapper.wrap(b))); }
/** * {@inheritDoc} */ @Override public double[] solve(double[] b) { ArgChecker.notNull(b, "b"); return _solver.solve(new ArrayRealVector(b)).toArray(); }
/** * {@inheritDoc} */ @Override public DoubleArray solve(DoubleArray b) { ArgChecker.notNull(b, "b"); return CommonsMathWrapper.unwrap(_solver.solve(CommonsMathWrapper.wrap(b))); }
/** * {@inheritDoc} */ @Override public double[] solve(double[] b) { ArgChecker.notNull(b, "b"); return _solver.solve(new ArrayRealVector(b)).toArray(); }
/** * {@inheritDoc} */ @Override public DoubleArray solve(DoubleArray b) { ArgChecker.notNull(b, "b"); return CommonsMathWrapper.unwrap(_solver.solve(CommonsMathWrapper.wrap(b))); }