Search in sources :

Example 1 with DenseDoubleEigenvalueDecomposition

use of cern.colt.matrix.tdouble.algo.decomposition.DenseDoubleEigenvalueDecomposition in project clusterMaker2 by RBVI.

the class ColtOps method eigenValues.

public double[] eigenValues(boolean nonZero) {
    if (decomp == null) {
        decomp = new DenseDoubleEigenvalueDecomposition(getData());
    }
    double[] allValues = decomp.getRealEigenvalues().toArray();
    if (!nonZero)
        return allValues;
    int size = 0;
    for (double d : allValues) {
        if (Math.abs(d) > EPSILON)
            size++;
    }
    double[] nonZ = new double[size];
    int index = 0;
    for (double d : allValues) {
        if (Math.abs(d) > EPSILON)
            nonZ[index++] = d;
    }
    return nonZ;
}
Also used : DenseDoubleEigenvalueDecomposition(cern.colt.matrix.tdouble.algo.decomposition.DenseDoubleEigenvalueDecomposition)

Example 2 with DenseDoubleEigenvalueDecomposition

use of cern.colt.matrix.tdouble.algo.decomposition.DenseDoubleEigenvalueDecomposition in project clusterMaker2 by RBVI.

the class ColtOps method eigenVectors.

public double[][] eigenVectors() {
    if (decomp == null)
        decomp = new DenseDoubleEigenvalueDecomposition(getData());
    DoubleMatrix2D eigv = decomp.getV();
    System.out.println("Found " + eigv.columns() + " eigenvectors");
    return eigv.toArray();
}
Also used : DoubleMatrix2D(cern.colt.matrix.tdouble.DoubleMatrix2D) DenseDoubleEigenvalueDecomposition(cern.colt.matrix.tdouble.algo.decomposition.DenseDoubleEigenvalueDecomposition)

Example 3 with DenseDoubleEigenvalueDecomposition

use of cern.colt.matrix.tdouble.algo.decomposition.DenseDoubleEigenvalueDecomposition in project clusterMaker2 by RBVI.

the class RunSCPS method run.

public List<NodeCluster> run(CyNetwork network, TaskMonitor monitor) {
    int k;
    monitor.showMessage(TaskMonitor.Level.INFO, "Formatting Matrix Data");
    DoubleMatrix2D sMat = getSMat(this.distanceMatrix);
    DoubleMatrix2D LMat = getLMat(sMat);
    monitor.showMessage(TaskMonitor.Level.INFO, "Calculating Eigenvalues");
    DenseDoubleEigenvalueDecomposition decomp = new DenseDoubleEigenvalueDecomposition(LMat);
    DoubleMatrix2D eigenVect = decomp.getV();
    DoubleMatrix1D eigenVal = decomp.getRealEigenvalues();
    monitor.showMessage(TaskMonitor.Level.INFO, "Calculating K value");
    if (this.kvalue > -1)
        k = this.kvalue;
    else
        k = getK(eigenVal, .3);
    System.out.println("K is " + k);
    if (numComponents > k) {
        doComponentClustering();
        return new ArrayList<NodeCluster>(this.clusterMap.values());
    }
    monitor.showMessage(TaskMonitor.Level.INFO, "Creating uMatrix for kMeans");
    DoubleMatrix2D uMat = getUMat(eigenVect, k);
    monitor.showMessage(TaskMonitor.Level.INFO, "Running kmeans clustering");
    doKMeansClustering(uMat, sMat);
    // clusterMap calculated in getSMat and doKMeansClustering steps. Simply return the results
    return new ArrayList<NodeCluster>(this.clusterMap.values());
}
Also used : DoubleMatrix2D(cern.colt.matrix.tdouble.DoubleMatrix2D) DenseDoubleEigenvalueDecomposition(cern.colt.matrix.tdouble.algo.decomposition.DenseDoubleEigenvalueDecomposition) DoubleMatrix1D(cern.colt.matrix.tdouble.DoubleMatrix1D) DoubleArrayList(cern.colt.list.tdouble.DoubleArrayList) IntArrayList(cern.colt.list.tint.IntArrayList) ArrayList(java.util.ArrayList)

Aggregations

DenseDoubleEigenvalueDecomposition (cern.colt.matrix.tdouble.algo.decomposition.DenseDoubleEigenvalueDecomposition)3 DoubleMatrix2D (cern.colt.matrix.tdouble.DoubleMatrix2D)2 DoubleArrayList (cern.colt.list.tdouble.DoubleArrayList)1 IntArrayList (cern.colt.list.tint.IntArrayList)1 DoubleMatrix1D (cern.colt.matrix.tdouble.DoubleMatrix1D)1 ArrayList (java.util.ArrayList)1