Example usage for org.apache.mahout.math DiagonalMatrix identity

List of usage examples for org.apache.mahout.math DiagonalMatrix identity

Introduction

In this page you can find the example usage for org.apache.mahout.math DiagonalMatrix identity.

Prototype

public static DiagonalMatrix identity(int size) 

Source Link

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.
 *///  w  w w.ja v a2 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:edu.snu.dolphin.bsp.examples.ml.algorithms.clustering.em.EMMainCtrlTask.java

License:Apache License

/**
 * Receive initial centroids from the preprocess task.
 *///from ww  w.j av a  2  s . co  m
@Override
public void initialize() {

    // Load the initial centroids from the previous stage
    centroids = keyValueStore.get(Centroids.class);

    // Initialize cluster summaries
    final int numClusters = centroids.size();
    for (int clusterID = 0; clusterID < numClusters; clusterID++) {
        final Vector vector = centroids.get(clusterID);
        final int dimension = vector.size();
        clusterSummaries.add(new ClusterSummary(1.0, vector, DiagonalMatrix.identity(dimension)));
    }
}