Example usage for org.apache.commons.math.exception.util LocalizedFormats TOO_LARGE_CUTOFF_SINGULAR_VALUE

List of usage examples for org.apache.commons.math.exception.util LocalizedFormats TOO_LARGE_CUTOFF_SINGULAR_VALUE

Introduction

In this page you can find the example usage for org.apache.commons.math.exception.util LocalizedFormats TOO_LARGE_CUTOFF_SINGULAR_VALUE.

Prototype

LocalizedFormats TOO_LARGE_CUTOFF_SINGULAR_VALUE

To view the source code for org.apache.commons.math.exception.util LocalizedFormats TOO_LARGE_CUTOFF_SINGULAR_VALUE.

Click Source Link

Usage

From source file:jml.matlab.utils.SingularValueDecompositionImpl.java

/** {@inheritDoc} */
public RealMatrix getCovariance(final double minSingularValue) {
    // get the number of singular values to consider
    final int p = s.length;
    int dimension = 0;
    while ((dimension < p) && (s[dimension] >= minSingularValue)) {
        ++dimension;/*from  ww w  .j  ava2 s  .c  om*/
    }

    if (dimension == 0) {
        throw new NumberIsTooLargeException(LocalizedFormats.TOO_LARGE_CUTOFF_SINGULAR_VALUE, minSingularValue,
                s[0], true);
    }

    final double[][] data = new double[dimension][p];
    getVT().walkInOptimizedOrder(new DefaultRealMatrixPreservingVisitor() {

        /** {@inheritDoc} */
        @Override
        public void visit(final int row, final int column, final double value) {
            data[row][column] = value / s[row];
        }
    }, 0, dimension - 1, 0, p - 1);

    RealMatrix jv = new Array2DRowRealMatrix(data, false);
    return jv.transpose().multiply(jv);
}