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


Java DoubleMatrix2D.toArray方法代码示例

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

示例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];
    }
 
开发者ID:nolanlab,项目名称:vortex,代码行数:34,代码来源:Trajectories_MDSJ.java

示例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;
}
 
开发者ID:nolanlab,项目名称:vortex,代码行数:13,代码来源:Trajectories.java

示例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());
	}
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:9,代码来源:ColtDenseDoubleMatrix2D.java

示例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);

}
 
开发者ID:nolanlab,项目名称:vortex,代码行数:45,代码来源:Trajectories_Correl.java

示例6: getEigenvectors

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
public double[][] getEigenvectors(){ 
       EigenvalueDecomposition eigenDecomp = new EigenvalueDecomposition(matrix);
DoubleMatrix2D eigenVectorMatrix = eigenDecomp.getV();
       return eigenVectorMatrix.toArray();
       
   }
 
开发者ID:rafaelmss,项目名称:GraphClustering,代码行数:7,代码来源:MatrixColt.java

示例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);
    }
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:55,代码来源:ColtEigenSystem.java


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