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


Java DenseDoubleMatrix2D.columns方法代码示例

本文整理汇总了Java中cern.colt.matrix.impl.DenseDoubleMatrix2D.columns方法的典型用法代码示例。如果您正苦于以下问题:Java DenseDoubleMatrix2D.columns方法的具体用法?Java DenseDoubleMatrix2D.columns怎么用?Java DenseDoubleMatrix2D.columns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cern.colt.matrix.impl.DenseDoubleMatrix2D的用法示例。


在下文中一共展示了DenseDoubleMatrix2D.columns方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getGt

import cern.colt.matrix.impl.DenseDoubleMatrix2D; //导入方法依赖的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: getLaplacian

import cern.colt.matrix.impl.DenseDoubleMatrix2D; //导入方法依赖的package包/类
public static DenseDoubleMatrix2D getLaplacian(DenseDoubleMatrix2D weightedMatrix) {
    DenseDoubleMatrix2D laplacian = new DenseDoubleMatrix2D(weightedMatrix.rows(), weightedMatrix.columns());
    for (int r = 0; r < laplacian.rows(); r++) {
        double sumRow = 0.0;
        for (int c = 0; c < laplacian.columns(); c++) {
            if (r != c) {
                double wrc = weightedMatrix.getQuick(r, c);
                sumRow += wrc;
                laplacian.setQuick(r, c, -wrc);
            }
        }
        laplacian.setQuick(r, r, sumRow);
    }
    return laplacian;
}
 
开发者ID:dexyko,项目名称:spectralclustering,代码行数:16,代码来源:SpectralClusteringSolver.java

示例3: SolveSpectralClustering

import cern.colt.matrix.impl.DenseDoubleMatrix2D; //导入方法依赖的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

示例4: Eigen

import cern.colt.matrix.impl.DenseDoubleMatrix2D; //导入方法依赖的package包/类
public Eigen(double[][] m_x) {

	x = m_x;
	x_matrix = new DenseDoubleMatrix2D(x);
	float_positive_result = new float[x_matrix.columns()];
	sort_result = new float[x_matrix.columns()];
    }
 
开发者ID:kewei-ma,项目名称:GeDBIT,代码行数:8,代码来源:Eigen.java

示例5: ColtDenseDoubleMatrix2D

import cern.colt.matrix.impl.DenseDoubleMatrix2D; //导入方法依赖的package包/类
public ColtDenseDoubleMatrix2D(DenseDoubleMatrix2D matrix) {
	super(matrix.rows(), matrix.columns());
	this.matrix = matrix;
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:5,代码来源:ColtDenseDoubleMatrix2D.java


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