Java Code Examples for org.apache.commons.math.linear.Array2DRowRealMatrix#getDataRef()

The following examples show how to use org.apache.commons.math.linear.Array2DRowRealMatrix#getDataRef() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OLSMultipleLinearRegression.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <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.
 * 
 * @return the hat matrix
 */
public RealMatrix calculateHat() {
    // Create augmented identity matrix
    RealMatrix Q = qr.getQ();
    final int p = qr.getR().getColumnDimension();
    final int n = Q.getColumnDimension();
    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
    return Q.multiply(augI).multiply(Q.transpose());
}
 
Example 2
Source File: OLSMultipleLinearRegression.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <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.
 *
 * @return the hat matrix
 */
public RealMatrix calculateHat() {
    // Create augmented identity matrix
    RealMatrix Q = qr.getQ();
    final int p = qr.getR().getColumnDimension();
    final int n = Q.getColumnDimension();
    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
    return Q.multiply(augI).multiply(Q.transpose());
}
 
Example 3
Source File: OLSMultipleLinearRegression.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <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.
 *
 * @return the hat matrix
 */
public RealMatrix calculateHat() {
    // Create augmented identity matrix
    RealMatrix Q = qr.getQ();
    final int p = qr.getR().getColumnDimension();
    final int n = Q.getColumnDimension();
    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
    return Q.multiply(augI).multiply(Q.transpose());
}
 
Example 4
Source File: OLSMultipleLinearRegression.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <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.
 *
 * @return the hat matrix
 */
public RealMatrix calculateHat() {
    // Create augmented identity matrix
    RealMatrix Q = qr.getQ();
    final int p = qr.getR().getColumnDimension();
    final int n = Q.getColumnDimension();
    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
    return Q.multiply(augI).multiply(Q.transpose());
}
 
Example 5
Source File: OLSMultipleLinearRegression.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <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.
 *
 * @return the hat matrix
 */
public RealMatrix calculateHat() {
    // Create augmented identity matrix
    RealMatrix Q = qr.getQ();
    final int p = qr.getR().getColumnDimension();
    final int n = Q.getColumnDimension();
    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
    return Q.multiply(augI).multiply(Q.transpose());
}
 
Example 6
Source File: OLSMultipleLinearRegression.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <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.
 *
 * @return the hat matrix
 */
public RealMatrix calculateHat() {
    // Create augmented identity matrix
    RealMatrix Q = qr.getQ();
    final int p = qr.getR().getColumnDimension();
    final int n = Q.getColumnDimension();
    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
    return Q.multiply(augI).multiply(Q.transpose());
}
 
Example 7
Source File: OLSMultipleLinearRegression.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <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.
 *
 * @return the hat matrix
 */
public RealMatrix calculateHat() {
    // Create augmented identity matrix
    RealMatrix Q = qr.getQ();
    final int p = qr.getR().getColumnDimension();
    final int n = Q.getColumnDimension();
    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
    return Q.multiply(augI).multiply(Q.transpose());
}
 
Example 8
Source File: OLSMultipleLinearRegression.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <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.
 *
 * @return the hat matrix
 */
public RealMatrix calculateHat() {
    // Create augmented identity matrix
    RealMatrix Q = qr.getQ();
    final int p = qr.getR().getColumnDimension();
    final int n = Q.getColumnDimension();
    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
    return Q.multiply(augI).multiply(Q.transpose());
}
 
Example 9
Source File: OLSMultipleLinearRegression.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <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.
 *
 * @return the hat matrix
 */
public RealMatrix calculateHat() {
    // Create augmented identity matrix
    RealMatrix Q = qr.getQ();
    final int p = qr.getR().getColumnDimension();
    final int n = Q.getColumnDimension();
    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
    return Q.multiply(augI).multiply(Q.transpose());
}
 
Example 10
Source File: AdamsNordsieckTransformer.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/** 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]);
        }
    }
}
 
Example 11
Source File: AdamsNordsieckTransformer.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/** 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]);
        }
    }
}
 
Example 12
Source File: AdamsNordsieckTransformer.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/** 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]);
        }
    }
}
 
Example 13
Source File: AdamsNordsieckTransformer.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/** 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]);
        }
    }
}
 
Example 14
Source File: AdamsNordsieckTransformer.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/** 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]);
        }
    }
}
 
Example 15
Source File: AdamsNordsieckTransformer.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/** 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]);
        }
    }
}
 
Example 16
Source File: AdamsNordsieckTransformer.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/** 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]);
        }
    }
}
 
Example 17
Source File: AdamsNordsieckTransformer.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/** 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]);
        }
    }
}
 
Example 18
Source File: AdamsNordsieckTransformer.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/** 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]);
        }
    }
}
 
Example 19
Source File: AdamsNordsieckTransformer.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/** 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]);
        }
    }
}
 
Example 20
Source File: AdamsNordsieckTransformer.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/** 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]);
        }
    }
}