Example usage for org.apache.commons.math.linear RealMatrix setRowMatrix

List of usage examples for org.apache.commons.math.linear RealMatrix setRowMatrix

Introduction

In this page you can find the example usage for org.apache.commons.math.linear RealMatrix setRowMatrix.

Prototype

void setRowMatrix(int row, RealMatrix matrix) throws MatrixIndexException, InvalidMatrixException;

Source Link

Document

Sets the entries in row number row as a row matrix.

Usage

From source file:dr.math.Procrustes.java

/**
 * procrustinate the complete matrix of coordinates
 * @param X the matrix containing coordinates (same dimensions as X in the constructor)
 * @return the transformed matrix/* w w  w  . j a va2  s .c om*/
 */
public final RealMatrix procrustinate(RealMatrix X) {
    if (X.getRowDimension() != rowDimension) {
        throw new IllegalArgumentException("X does not have the expected number of rows");
    }
    if (X.getColumnDimension() != columnDimension) {
        throw new IllegalArgumentException("X does not have the expected number of columns");
    }

    //       X.new <- s * X %*% R + matrix(tt, nrow(X), ncol(X), byrow = TRUE)
    RealMatrix tt = new Array2DRowRealMatrix(rowDimension, columnDimension);

    for (int i = 0; i < rowDimension; i++) {
        tt.setRowMatrix(i, T.transpose());
    }

    // rotate, scale and translate
    return X.multiply(R).scalarMultiply(s).add(tt); // Was a bug here
}