MATH-1425: Overridden methods for improved performance.

Thanks to Christoph Dibak.
This commit is contained in:
Gilles 2017-07-22 02:17:35 +02:00
parent f940239fd2
commit e1f30a1c32
1 changed files with 24 additions and 0 deletions

View File

@ -562,4 +562,28 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
throws DimensionMismatchException, NoDataException, NullArgumentException { throws DimensionMismatchException, NoDataException, NullArgumentException {
setSubMatrix(in, 0, 0); setSubMatrix(in, 0, 0);
} }
/** {@inheritDoc} */
@Override
public double[] getRow(final int row)
throws OutOfRangeException {
MatrixUtils.checkRowIndex(this, row);
final int nCols = getColumnDimension();
final double[] out = new double[nCols];
System.arraycopy(data[row], 0, out, 0, nCols);
return out;
}
/** {@inheritDoc} */
@Override
public void setRow(final int row,
final double[] array)
throws OutOfRangeException, MatrixDimensionMismatchException {
MatrixUtils.checkRowIndex(this, row);
final int nCols = getColumnDimension();
if (array.length != nCols) {
throw new MatrixDimensionMismatchException(1, array.length, 1, nCols);
}
System.arraycopy(array, 0, data[row], 0, nCols);
}
} }