本文整理汇总了Java中cern.colt.matrix.linalg.EigenvalueDecomposition.getRealEigenvalues方法的典型用法代码示例。如果您正苦于以下问题:Java EigenvalueDecomposition.getRealEigenvalues方法的具体用法?Java EigenvalueDecomposition.getRealEigenvalues怎么用?Java EigenvalueDecomposition.getRealEigenvalues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cern.colt.matrix.linalg.EigenvalueDecomposition
的用法示例。
在下文中一共展示了EigenvalueDecomposition.getRealEigenvalues方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getGt
import cern.colt.matrix.linalg.EigenvalueDecomposition; //导入方法依赖的package包/类
private static DoubleMatrix2D getGt(final DenseDoubleMatrix2D p, final DenseDoubleMatrix2D q, double lambda) {
final int K = p.columns();
DenseDoubleMatrix2D A1 = new DenseDoubleMatrix2D(K, K);
q.zMult(q, A1, 1.0, 0.0, true, false);
for (int k = 0; k < K; k++) {
A1.setQuick(k, k, lambda + A1.getQuick(k, k));
}
EigenvalueDecomposition eig = new EigenvalueDecomposition(A1);
DoubleMatrix1D d = eig.getRealEigenvalues();
DoubleMatrix2D gt = eig.getV();
for (int k = 0; k < K; k++) {
double a = sqrt(d.get(k));
gt.viewColumn(k).assign(x -> a * x);
}
return gt;
}
示例2: SolveSpectralClustering
import cern.colt.matrix.linalg.EigenvalueDecomposition; //导入方法依赖的package包/类
/**
* Finds the clusters using algorithm version 1.
*
* @param similarityMatrix
* the similarity matrix
* @param numCluster
* the number of clusters to construct
*/
public static void SolveSpectralClustering(DenseDoubleMatrix2D similarityMatrix, int numCluster,
SimilarityMatrixTransformer transformer) {
for (int r = 0; r < similarityMatrix.rows(); r++) {
for (int c = 0; c < similarityMatrix.columns(); c++) {
System.out.print(similarityMatrix.getQuick(r, c) + " ");
}
System.out.println();
}
DenseDoubleMatrix2D weightedMatrix = transformer.transform(similarityMatrix);
DenseDoubleMatrix2D laplacianMatrix = getLaplacian(weightedMatrix);
EigenvalueDecomposition eigenDecomposition = new EigenvalueDecomposition(laplacianMatrix);
DoubleMatrix2D eigenVectors = eigenDecomposition.getV();
DoubleMatrix1D eigenValues = eigenDecomposition.getRealEigenvalues();
System.out.println("EigenValues:");
EigenValueSortHelper[] eigenvaluesToSort = new EigenValueSortHelper[eigenValues.size()];
for (int iEigen = 0; iEigen < eigenValues.size(); iEigen++) {
eigenvaluesToSort[iEigen] = new EigenValueSortHelper(eigenValues.getQuick(iEigen), iEigen);
System.out.print(eigenValues.getQuick(iEigen) + " ");
}
System.out.println();
Arrays.sort(eigenvaluesToSort);
for (int iEigen = 0; iEigen < eigenValues.size(); iEigen++) {
System.out.print(eigenvaluesToSort[iEigen].getIndex() + ":"
+ eigenValues.getQuick(eigenvaluesToSort[iEigen].getIndex()) + " ");
}
System.out.println();
System.out.println("EigenVectors:");
for (int iEigen = 0; iEigen < eigenVectors.columns(); iEigen++) {
System.out.print("[");
for (int r = 0; r < eigenVectors.rows(); r++) {
System.out.print(eigenVectors.getQuick(r, eigenvaluesToSort[iEigen].getIndex()) + " ");
}
System.out.println("]");
}
}
示例3: getSpectralRadius
import cern.colt.matrix.linalg.EigenvalueDecomposition; //导入方法依赖的package包/类
public static double getSpectralRadius(DoubleMatrix2D A){
EigenvalueDecomposition eigen = new EigenvalueDecomposition(A);
DoubleMatrix1D eigenValues = eigen.getRealEigenvalues();
return eigenValues.assign(Functions.abs).viewSorted().get(eigenValues.size()-1);
}