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


Java Array2DRowRealMatrix.getColumnDimension方法代码示例

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


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

示例1: DataSet

import org.apache.commons.math3.linear.Array2DRowRealMatrix; //导入方法依赖的package包/类
public DataSet(Array2DRowRealMatrix data, int[] labels, String[] hdrz, MatrixFormatter formatter, boolean copyData) {
	
	/*// we should allow this behavior...
	if(null == labels)
		throw new IllegalArgumentException("labels cannot be null");
	*/

	if(null == data)
		throw new IllegalArgumentException("data cannot be null");
	if(null == hdrz)
		this.headers = genHeaders(data.getColumnDimension());
	else 
		this.headers = VecUtils.copy(hdrz);
	
	
	// Check to make sure dims match up...
	if((null != labels) && labels.length != data.getRowDimension())
		throw new DimensionMismatchException(labels.length, data.getRowDimension());
	if(this.headers.length != data.getColumnDimension())
		throw new DimensionMismatchException(this.headers.length, data.getColumnDimension());
	
	this.data = copyData ? (Array2DRowRealMatrix)data.copy() : data;
	this.labels = VecUtils.copy(labels);
	this.formatter = null == formatter ? DEF_FORMATTER : formatter;
}
 
开发者ID:tgsmith61591,项目名称:clust4j,代码行数:26,代码来源:DataSet.java

示例2: computeMatrixInverse

import org.apache.commons.math3.linear.Array2DRowRealMatrix; //导入方法依赖的package包/类
/**
 * Function to compute matrix inverse via matrix decomposition.
 * 
 * @param in commons-math3 Array2DRowRealMatrix
 * @return matrix block
 * @throws DMLRuntimeException if DMLRuntimeException occurs
 */
private static MatrixBlock computeMatrixInverse(Array2DRowRealMatrix in) 
	throws DMLRuntimeException 
{	
	if ( !in.isSquare() )
		throw new DMLRuntimeException("Input to inv() must be square matrix -- given: a " + in.getRowDimension() + "x" + in.getColumnDimension() + " matrix.");
	
	QRDecomposition qrdecompose = new QRDecomposition(in);
	DecompositionSolver solver = qrdecompose.getSolver();
	RealMatrix inverseMatrix = solver.getInverse();

	return DataConverter.convertToMatrixBlock(inverseMatrix.getData());
}
 
开发者ID:apache,项目名称:systemml,代码行数:20,代码来源:LibCommonsMath.java

示例3: computeCholesky

import org.apache.commons.math3.linear.Array2DRowRealMatrix; //导入方法依赖的package包/类
/**
 * Function to compute Cholesky decomposition of the given input matrix. 
 * The input must be a real symmetric positive-definite matrix.
 * 
 * @param in commons-math3 Array2DRowRealMatrix
 * @return matrix block
 * @throws DMLRuntimeException if DMLRuntimeException occurs
 */
private static MatrixBlock computeCholesky(Array2DRowRealMatrix in) 
	throws DMLRuntimeException 
{	
	if ( !in.isSquare() )
		throw new DMLRuntimeException("Input to cholesky() must be square matrix -- given: a " + in.getRowDimension() + "x" + in.getColumnDimension() + " matrix.");

	CholeskyDecomposition cholesky = new CholeskyDecomposition(in, 1e-14,
		CholeskyDecomposition.DEFAULT_ABSOLUTE_POSITIVITY_THRESHOLD);
	RealMatrix rmL = cholesky.getL();
	
	return DataConverter.convertToMatrixBlock(rmL.getData());
}
 
开发者ID:apache,项目名称:systemml,代码行数:21,代码来源:LibCommonsMath.java

示例4: initializeHighOrderDerivatives

import org.apache.commons.math3.linear.Array2DRowRealMatrix; //导入方法依赖的package包/类
/** Initialize the high order scaled derivatives at step start.
 * @param h step size to use for scaling
 * @param t first steps times
 * @param y first steps states
 * @param yDot first steps derivatives
 * @return Nordieck vector at start of first step (h<sup>2</sup>/2 y''<sub>n</sub>,
 * h<sup>3</sup>/6 y'''<sub>n</sub> ... h<sup>k</sup>/k! y<sup>(k)</sup><sub>n</sub>)
 */

public Array2DRowRealMatrix initializeHighOrderDerivatives(final double h, final double[] t,
                                                           final double[][] y,
                                                           final double[][] yDot) {

    // using Taylor series with di = ti - t0, we get:
    //  y(ti)  - y(t0)  - di y'(t0) =   di^2 / h^2 s2 + ... +   di^k     / h^k sk + O(h^k)
    //  y'(ti) - y'(t0)             = 2 di   / h^2 s2 + ... + k di^(k-1) / h^k sk + O(h^(k-1))
    // we write these relations for i = 1 to i= 1+n/2 as a set of n + 2 linear
    // equations depending on the Nordsieck vector [s2 ... sk rk], so s2 to sk correspond
    // to the appropriately truncated Taylor expansion, and rk is the Taylor remainder.
    // The goal is to have s2 to sk as accurate as possible considering the fact the sum is
    // truncated and we don't want the error terms to be included in s2 ... sk, so we need
    // to solve also for the remainder
    final double[][] a     = new double[c1.length + 1][c1.length + 1];
    final double[][] b     = new double[c1.length + 1][y[0].length];
    final double[]   y0    = y[0];
    final double[]   yDot0 = yDot[0];
    for (int i = 1; i < y.length; ++i) {

        final double di    = t[i] - t[0];
        final double ratio = di / h;
        double dikM1Ohk    =  1 / h;

        // linear coefficients of equations
        // y(ti) - y(t0) - di y'(t0) and y'(ti) - y'(t0)
        final double[] aI    = a[2 * i - 2];
        final double[] aDotI = (2 * i - 1) < a.length ? a[2 * i - 1] : null;
        for (int j = 0; j < aI.length; ++j) {
            dikM1Ohk *= ratio;
            aI[j]     = di      * dikM1Ohk;
            if (aDotI != null) {
                aDotI[j]  = (j + 2) * dikM1Ohk;
            }
        }

        // expected value of the previous equations
        final double[] yI    = y[i];
        final double[] yDotI = yDot[i];
        final double[] bI    = b[2 * i - 2];
        final double[] bDotI = (2 * i - 1) < b.length ? b[2 * i - 1] : null;
        for (int j = 0; j < yI.length; ++j) {
            bI[j]    = yI[j] - y0[j] - di * yDot0[j];
            if (bDotI != null) {
                bDotI[j] = yDotI[j] - yDot0[j];
            }
        }

    }

    // solve the linear system to get the best estimate of the Nordsieck vector [s2 ... sk],
    // with the additional terms s(k+1) and c grabbing the parts after the truncated Taylor expansion
    final QRDecomposition decomposition = new QRDecomposition(new Array2DRowRealMatrix(a, false));
    final RealMatrix x = decomposition.getSolver().solve(new Array2DRowRealMatrix(b, false));

    // extract just the Nordsieck vector [s2 ... sk]
    final Array2DRowRealMatrix truncatedX = new Array2DRowRealMatrix(x.getRowDimension() - 1, x.getColumnDimension());
    for (int i = 0; i < truncatedX.getRowDimension(); ++i) {
        for (int j = 0; j < truncatedX.getColumnDimension(); ++j) {
            truncatedX.setEntry(i, j, x.getEntry(i, j));
        }
    }
    return truncatedX;

}
 
开发者ID:biocompibens,项目名称:SME,代码行数:74,代码来源:AdamsNordsieckTransformer.java


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