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


Java Array2DRowRealMatrix.getDataRef方法代码示例

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


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

示例1: calculateHat

import org.apache.commons.math3.linear.Array2DRowRealMatrix; //导入方法依赖的package包/类
/**
 * <p>Compute the "hat" matrix.
 * </p>
 * <p>The hat matrix is defined in terms of the design matrix X
 *  by X(X<sup>T</sup>X)<sup>-1</sup>X<sup>T</sup>
 * </p>
 * <p>The implementation here uses the QR decomposition to compute the
 * hat matrix as Q I<sub>p</sub>Q<sup>T</sup> where I<sub>p</sub> is the
 * p-dimensional identity matrix augmented by 0's.  This computational
 * formula is from "The Hat Matrix in Regression and ANOVA",
 * David C. Hoaglin and Roy E. Welsch,
 * <i>The American Statistician</i>, Vol. 32, No. 1 (Feb., 1978), pp. 17-22.
 * </p>
 * <p>Data for the model must have been successfully loaded using one of
 * the {@code newSampleData} methods before invoking this method; otherwise
 * a {@code NullPointerException} will be thrown.</p>
 *
 * @return the hat matrix
 * @throws NullPointerException unless method {@code newSampleData} has been
 * called beforehand.
 */
public RealMatrix calculateHat() {
    // Create augmented identity matrix
    RealMatrix Q = qr.getQ();
    final int p = qr.getR().getColumnDimension();
    final int n = Q.getColumnDimension();
    // No try-catch or advertised NotStrictlyPositiveException - NPE above if n < 3
    Array2DRowRealMatrix augI = new Array2DRowRealMatrix(n, n);
    double[][] augIData = augI.getDataRef();
    for (int i = 0; i < n; i++) {
        for (int j =0; j < n; j++) {
            if (i == j && i < p) {
                augIData[i][j] = 1d;
            } else {
                augIData[i][j] = 0d;
            }
        }
    }

    // Compute and return Hat matrix
    // No DME advertised - args valid if we get here
    return Q.multiply(augI).multiply(Q.transpose());
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:44,代码来源:OLSMultipleLinearRegression.java

示例2: fastMultiply

import org.apache.commons.math3.linear.Array2DRowRealMatrix; //导入方法依赖的package包/类
private void fastMultiply(final Array2DRowRealMatrix mat, final double[] v, final double[] out) {
    final int n = v.length;
    for (int row = 0; row < n; row++) {
        final double[] dataRow = mat.getDataRef()[row];
        double sum = 0;
        for (int i = 0; i < n; i++) {
            sum += dataRow[i] * v[i];
        }
        out[row] = sum;
    }
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:12,代码来源:MultiplexImageReader.java

示例3: fastMultiply

import org.apache.commons.math3.linear.Array2DRowRealMatrix; //导入方法依赖的package包/类
private static void fastMultiply(final Array2DRowRealMatrix mat, final double[] v, final double[] out) {
    final int n = v.length;
    for (int row = 0; row < n; row++) {
        final double[] dataRow = mat.getDataRef()[row];
        double sum = 0;
        for (int i = 0; i < n; i++) {
            sum += dataRow[i] * v[i];
        }
        out[row] = sum;
    }
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:12,代码来源:DemoMihcComputation.java

示例4: updateHighOrderDerivativesPhase2

import org.apache.commons.math3.linear.Array2DRowRealMatrix; //导入方法依赖的package包/类
/** Update the high order scaled derivatives Adams integrators (phase 2).
 * <p>The complete update of high order derivatives has a form similar to:
 * <pre>
 * r<sub>n+1</sub> = (s<sub>1</sub>(n) - s<sub>1</sub>(n+1)) P<sup>-1</sup> u + P<sup>-1</sup> A P r<sub>n</sub>
 * </pre>
 * this method computes the (s<sub>1</sub>(n) - s<sub>1</sub>(n+1)) P<sup>-1</sup> u part.</p>
 * <p>Phase 1 of the update must already have been performed.</p>
 * @param start first order scaled derivatives at step start
 * @param end first order scaled derivatives at step end
 * @param highOrder high order scaled derivatives, will be modified
 * (h<sup>2</sup>/2 y'', ... h<sup>k</sup>/k! y(k))
 * @see #updateHighOrderDerivativesPhase1(Array2DRowRealMatrix)
 */
public void updateHighOrderDerivativesPhase2(final double[] start,
                                             final double[] end,
                                             final Array2DRowRealMatrix highOrder) {
    final double[][] data = highOrder.getDataRef();
    for (int i = 0; i < data.length; ++i) {
        final double[] dataI = data[i];
        final double c1I = c1[i];
        for (int j = 0; j < dataI.length; ++j) {
            dataI[j] += c1I * (start[j] - end[j]);
        }
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:26,代码来源:AdamsNordsieckTransformer.java


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