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;
}
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();
}
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());
}
Aggregations