本文整理汇总了Java中cern.colt.matrix.DoubleMatrix2D.toArray方法的典型用法代码示例。如果您正苦于以下问题:Java DoubleMatrix2D.toArray方法的具体用法?Java DoubleMatrix2D.toArray怎么用?Java DoubleMatrix2D.toArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cern.colt.matrix.DoubleMatrix2D
的用法示例。
在下文中一共展示了DoubleMatrix2D.toArray方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSumDeviations
import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
public static double getSumDeviations(DoubleMatrix2D proj, int[] groups) {
int idx = 0;
int currGroup;
double[][] projD = proj.toArray();
do {
double[] avgGroup = new double[proj.columns()];
int grpSize = 0;
currGroup = groups[idx];
while (idx < groups.length && groups[idx] == currGroup) {
avgGroup = MatrixOp.sum(avgGroup, projD[idx]);
idx++;
grpSize++;
}
idx -= grpSize;
MatrixOp.mult(avgGroup, 1.0 / (double) grpSize);
while (idx < groups.length && groups[idx] == currGroup) {
projD[idx] = MatrixOp.diff(projD[idx], avgGroup);
idx++;
}
} while (idx < groups.length);
double sumSqLen = 0;
for (double[] ds : projD) {
sumSqLen += asinh(MatrixOp.mult(ds, ds));
}
return sumSqLen;
}
示例2: getMedianDev
import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
public static double getMedianDev(DoubleMatrix2D proj, int[] groups) {
int idx = 0;
int currGroup;
double[][] projD = proj.toArray();
do {
double[] avgGroup = new double[proj.columns()];
int grpSize = 0;
currGroup = groups[idx];
while (idx < groups.length && groups[idx] == currGroup) {
avgGroup = MatrixOp.sum(avgGroup, projD[idx]);
idx++;
grpSize++;
}
idx -= grpSize;
MatrixOp.mult(avgGroup, 1.0 / (double) grpSize);
while (idx < groups.length && groups[idx] == currGroup) {
projD[idx] = MatrixOp.diff(projD[idx], avgGroup);
idx++;
}
} while (idx < groups.length);
double[] len = new double[groups.length];
for (int i = 0; i < groups.length; i++) {
len[i] = Math.sqrt(MatrixOp.mult(projD[i], projD[i]));
}
Arrays.sort(len);
return len[len.length / 2];
}
示例3: getDistanceMtx
import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
public static double[][] getDistanceMtx(DoubleMatrix2D in) {
double[][] vec = in.toArray();
double[][] out = new double[vec.length][vec.length];
for (int i = 0; i < out.length; i++) {
for (int j = i + 1; j < out.length; j++) {
out[i][j] = MatrixOp.getEuclideanDistance(vec[i], vec[j]);
}
}
return out;
}
示例4: ColtDenseDoubleMatrix2D
import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
public ColtDenseDoubleMatrix2D(DoubleMatrix2D m) {
super(m.rows(), m.columns());
if (m instanceof DenseDoubleMatrix2D) {
this.matrix = (DenseDoubleMatrix2D) m;
} else {
this.matrix = new DenseDoubleMatrix2D(m.toArray());
}
}
示例5: show3DPlot
import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
public static void show3DPlot(DoubleMatrix2D proj, int[] groups, String[] names) {
org.math.plot.Plot3DPanel plotpanel = new Plot3DPanel();
ColorPalette cp = ColorPalette.NEUTRAL_PALETTE;
int idx = 0;
int currGroup;
double[][] projD = proj.toArray();
while (idx < groups.length) {
double[] avgGroup = new double[proj.columns()];
int grpSize = 0;
currGroup = groups[idx];
ArrayList<double[]> groupVec = new ArrayList<>();
while (idx < groups.length && groups[idx] == currGroup) {
groupVec.add(projD[idx]);
idx++;
}
if (idx < groups.length) {
plotpanel.addScatterPlot(names[idx].split("_")[0], cp.getColor(currGroup), groupVec.toArray(new double[groupVec.size()][]));
}
}
JFrame jf = new JFrame();
plotpanel.removeLegend();
plotpanel.plotLegend.getParent();
plotpanel.remove(plotpanel.plotLegend);
plotpanel.removeLegend();
plotpanel.plotLegend = new LegendPanel(plotpanel, 0);
plotpanel.add(plotpanel.plotLegend, BorderLayout.EAST);
jf.add(plotpanel);
jf.setBounds(200, 200, 800, 600);
jf.setVisible(true);
}
示例6: getEigenvectors
import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
public double[][] getEigenvectors(){
EigenvalueDecomposition eigenDecomp = new EigenvalueDecomposition(matrix);
DoubleMatrix2D eigenVectorMatrix = eigenDecomp.getV();
return eigenVectorMatrix.toArray();
}
示例7: decomposeMatrix
import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
public EigenDecomposition decomposeMatrix(double[][] matrix) {
final int stateCount = matrix.length;
RobustEigenDecomposition eigenDecomp = new RobustEigenDecomposition(
new DenseDoubleMatrix2D(matrix), maxIterations);
DoubleMatrix2D eigenV = eigenDecomp.getV();
DoubleMatrix2D eigenVInv;
if (checkConditioning) {
RobustSingularValueDecomposition svd;
try {
svd = new RobustSingularValueDecomposition(eigenV, maxIterations);
} catch (ArithmeticException ae) {
System.err.println(ae.getMessage());
return getEmptyDecomposition(stateCount);
}
if (svd.cond() > maxConditionNumber) {
return getEmptyDecomposition(stateCount);
}
}
try {
eigenVInv = alegbra.inverse(eigenV);
} catch (IllegalArgumentException e) {
return getEmptyDecomposition(stateCount);
}
double[][] Evec = eigenV.toArray();
double[][] Ievc = eigenVInv.toArray();
double[] Eval = getAllEigenValues(eigenDecomp);
if (checkConditioning) {
for (int i = 0; i < Eval.length; i++) {
if (Double.isNaN(Eval[i]) ||
Double.isInfinite(Eval[i])) {
return getEmptyDecomposition(stateCount);
} else if (Math.abs(Eval[i]) < 1e-10) {
Eval[i] = 0.0;
}
}
}
double[] flatEvec = new double[stateCount * stateCount];
double[] flatIevc = new double[stateCount * stateCount];
for (int i = 0; i < Evec.length; i++) {
System.arraycopy(Evec[i], 0, flatEvec, i * stateCount, stateCount);
System.arraycopy(Ievc[i], 0, flatIevc, i * stateCount, stateCount);
}
return new EigenDecomposition(flatEvec, flatIevc, Eval);
}