当前位置: 首页>>代码示例>>Java>>正文


Java EigenvalueDecomposition.getRealEigenvalues方法代码示例

本文整理汇总了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;
}
 
开发者ID:RankSys,项目名称:RankSys,代码行数:20,代码来源:PZTFactorizer.java

示例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("]");
    }
}
 
开发者ID:dexyko,项目名称:spectralclustering,代码行数:46,代码来源:SpectralClusteringSolver.java

示例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);
}
 
开发者ID:wil3,项目名称:lacus,代码行数:7,代码来源:MLMatrixUtils.java


注:本文中的cern.colt.matrix.linalg.EigenvalueDecomposition.getRealEigenvalues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。