Example usage for org.apache.commons.math.linear CholeskyDecompositionImpl CholeskyDecompositionImpl

List of usage examples for org.apache.commons.math.linear CholeskyDecompositionImpl CholeskyDecompositionImpl

Introduction

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

Prototype

public CholeskyDecompositionImpl(final RealMatrix matrix)
        throws NonSquareMatrixException, NotSymmetricMatrixException, NotPositiveDefiniteMatrixException 

Source Link

Document

Calculates the Cholesky decomposition of the given matrix.

Usage

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

/**
 * {@inheritDoc}/*from w  w w .java2 s.  co  m*/
 */
@Override
public CholeskyDecompositionResult evaluate(final DoubleMatrix2D x) {
    Validate.notNull(x);
    final RealMatrix temp = CommonsMathWrapper.wrap(x);
    CholeskyDecomposition cholesky;
    try {
        cholesky = new CholeskyDecompositionImpl(temp);
    } catch (Exception e) {
        throw new MathException(e.toString());
    }
    return new CholeskyDecompositionCommonsResult(cholesky);
}

From source file:edu.cudenver.bios.matrixsvc.resource.MatrixDecompositionCholeskyResource.java

/**
* This operation takes a single square matrix (p x p) 
* and produces two matrices: the matrix representing its 
* square root (L), and its transpose.  Please see 
* Matrix Services REST API documentation for details on
* the entity body format.//from w  w  w  .  j ava2 s  .c o m
* 
* @param entity HTTP entity body for the request
* @throws NotPositiveDefiniteMatrixException 
* @throws NotSymmetricMatrixException 
* @throws NonSquareMatrixException 
*/
@Post
public Representation acceptRepresentation(Representation entity) throws ResourceException,
        NonSquareMatrixException, NotSymmetricMatrixException, NotPositiveDefiniteMatrixException {
    if (entity == null) {
        throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST,
                "No Input- Matrix Decomposition not possible");
    }
    DomRepresentation rep = new DomRepresentation(entity);
    NamedRealMatrix matrixInput = null;

    try {
        // parse the parameters from the entity body
        matrixInput = MatrixParamParser
                .getDecompCholeskyParamsFromDomNode(rep.getDocument().getDocumentElement());

        if (matrixInput == null || !matrixInput.getName().equalsIgnoreCase("A")) {
            throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST,
                    "Couldn't retrieve the matrix for Cholesky Decomposition.");
        }

        // perform Cholesky Decomposition
        CholeskyDecompositionImpl cdImpl = new CholeskyDecompositionImpl(matrixInput);

        //create our response representation
        CholeskyDecompositionXmlRepresentation response = new CholeskyDecompositionXmlRepresentation(cdImpl);
        /* getResponse().setEntity(response); 
         getResponse().setStatus(Status.SUCCESS_CREATED);*/
        return response;
    } catch (IllegalArgumentException iae) {
        MatrixLogger.getInstance().error(iae.getMessage());
        throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, iae.getMessage());

    } catch (IOException ioe) {
        MatrixLogger.getInstance().error(ioe.getMessage());
        throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, ioe.getMessage());

    }
}