當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。