Example usage for org.apache.commons.math.linear SingularValueDecomposition getSolver

List of usage examples for org.apache.commons.math.linear SingularValueDecomposition getSolver

Introduction

In this page you can find the example usage for org.apache.commons.math.linear SingularValueDecomposition getSolver.

Prototype

DecompositionSolver getSolver();

Source Link

Document

Get a solver for finding the A × X = B solution in least square sense.

Usage

From source file:com.opengamma.analytics.math.matrix.CommonsMatrixAlgebra.java

/**
 * {@inheritDoc}//  w w  w .j  a v  a  2  s.co m
 */
@Override
public DoubleMatrix2D getInverse(final Matrix<?> m) {
    Validate.notNull(m, "matrix was null");
    if (m instanceof DoubleMatrix2D) {
        final RealMatrix temp = CommonsMathWrapper.wrap((DoubleMatrix2D) m);
        final SingularValueDecomposition sv = new SingularValueDecompositionImpl(temp);
        final RealMatrix inv = sv.getSolver().getInverse();
        return CommonsMathWrapper.unwrap(inv);
    }
    throw new IllegalArgumentException("Can only find inverse of DoubleMatrix2D; have " + m.getClass());
}

From source file:com.opengamma.analytics.math.linearalgebra.SVDecompositionCommonsResult.java

/**
 * @param svd The result of the SV decomposition, not null
 *//*from   w  w  w. ja v  a  2s . c o  m*/
public SVDecompositionCommonsResult(final SingularValueDecomposition svd) {
    Validate.notNull(svd);
    _condition = svd.getConditionNumber();
    _norm = svd.getNorm();
    _rank = svd.getRank();
    _s = CommonsMathWrapper.unwrap(svd.getS());
    _singularValues = svd.getSingularValues();
    _u = CommonsMathWrapper.unwrap(svd.getU());
    _uTranspose = CommonsMathWrapper.unwrap(svd.getUT());
    _v = CommonsMathWrapper.unwrap(svd.getV());
    _vTranspose = CommonsMathWrapper.unwrap(svd.getVT());
    _solver = svd.getSolver();
}

From source file:playground.mmoyo.taste_variations.MyLeastSquareSolutionCalculator.java

private double[] getSVDsolution(final RealMatrix matrixA, final double[] arrayB) {
    SingularValueDecomposition svd = new SingularValueDecompositionImpl(matrixA);
    DecompositionSolver svdSolver = svd.getSolver();
    double[] arrayX = svdSolver.solve(arrayB);
    return arrayX;
}