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


Java AMatrix.asDoubleArray方法代码示例

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


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

示例1: convertToColumnMajor

import mikera.matrixx.AMatrix; //导入方法依赖的package包/类
/**
 * Converts the standard row-major matrix into a column-major vector
 * that is advantageous for this problem.
 *
 * @param A original matrix that is to be decomposed.
 */
protected void convertToColumnMajor(AMatrix A) {
    double[] data = A.asDoubleArray();
    for( int x = 0; x < numCols; x++ ) {
        double colQ[] = dataQR[x];
        for( int y = 0; y < numRows; y++ ) {
            colQ[y] = data[y*numCols+x];
        }
    }
}
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:16,代码来源:HouseholderColQR.java

示例2: improveSol

import mikera.matrixx.AMatrix; //导入方法依赖的package包/类
/**
     * This attempts to improve upon the solution generated by account
     * for numerical imprecisions.  See numerical recipes for more information.  It
     * is assumed that solve has already been run on 'b' and 'x' at least once.
     *
     * @param b A matrix. Not modified.
     * @param x A matrix. Modified.
     */
    public void improveSol( AMatrix b , AMatrix x )
    {
        if( b.columnCount() != x.columnCount() ) {
            throw new IllegalArgumentException("bad shapes");
        }

        double dataA[] = A.asDoubleArray();
        double dataB[] = b.asDoubleArray();
        double dataX[] = x.asDoubleArray();

        final int nc = b.columnCount();
        final int n = b.columnCount();

        double []vv = decomp._getVV();
//        AMatrix LU = decomp.getLU();

//        BigDecimal sdp = new BigDecimal(0);
        for( int k = 0; k < nc; k++ ) {
            for( int i = 0; i < n; i++ ) {
                // *NOTE* in the book this is a long double.  extra precision might be required
                double sdp = -dataB[ i * nc + k];
//                BigDecimal sdp = new BigDecimal(-dataB[ i * nc + k]);
                for( int j = 0; j < n; j++ ) {
                    sdp += dataA[i* n +j] * dataX[ j * nc + k];
//                    sdp = sdp.add( BigDecimal.valueOf(dataA[i* n +j] * dataX[ j * nc + k]));
                }
                vv[i] = sdp;
//                vv[i] = sdp.doubleValue();
            }
            decomp._solveVectorInternal(vv);
            for( int i = 0; i < n; i++ ) {
                dataX[i*nc + k] -= vv[i];
            }
        }
    }
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:44,代码来源:LUSolver.java


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