Example usage for org.apache.mahout.math QRDecomposition solve

List of usage examples for org.apache.mahout.math QRDecomposition solve

Introduction

In this page you can find the example usage for org.apache.mahout.math QRDecomposition solve.

Prototype

@Override
public Matrix solve(Matrix B) 

Source Link

Document

Least squares solution of A*X = B; returns X.

Usage

From source file:edu.snu.dolphin.bsp.examples.ml.algorithms.clustering.em.EMMainCmpTask.java

License:Apache License

/**
 * Compute the inverse of a given matrix.
 *///www.  ja  va  2 s.  c o  m
private Matrix inverse(final Matrix matrix) {
    final int dimension = matrix.rowSize();
    final QRDecomposition qr = new QRDecomposition(matrix);
    return qr.solve(DiagonalMatrix.identity(dimension));
}

From source file:org.qcri.pca.SPCADriver.java

private static Matrix inv(Matrix m) {
    // assume m is square
    QRDecomposition qr = new QRDecomposition(m);
    Matrix i = eye(m.numRows());/*from   w  ww . j a va  2s .  co m*/
    Matrix res = qr.solve(i);
    Matrix densRes = toDenseMatrix(res); // to go around sparse matrix bug
    return densRes;
}

From source file:org.qcri.sparkpca.PCAUtils.java

/**
 * Compute the inverse of a Matrix//ww w .  j  a  v a2s  .  c  o  m
*/
public static Matrix inv(Matrix m) {
    // assume m is square
    QRDecomposition qr = new QRDecomposition(m);
    Matrix i = eye(m.numRows());
    Matrix res = qr.solve(i);
    Matrix densRes = toDenseMatrix(res); // to go around sparse matrix bug
    return densRes;
}