本文整理汇总了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;
}
示例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;
}
示例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("]");
}
}
示例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()];
}
示例5: ColtDenseDoubleMatrix2D
import cern.colt.matrix.impl.DenseDoubleMatrix2D; //导入方法依赖的package包/类
public ColtDenseDoubleMatrix2D(DenseDoubleMatrix2D matrix) {
super(matrix.rows(), matrix.columns());
this.matrix = matrix;
}