Added MatrixUtils.copyIntoMatrix utility function to copy part of one 2D matrix into another

This commit is contained in:
joseph.lizier 2013-01-22 03:36:11 +00:00
parent cd5073c98e
commit afe224ab11
1 changed files with 9 additions and 0 deletions

View File

@ -1268,6 +1268,15 @@ public class MatrixUtils {
return newMatrix;
}
public static void copyIntoMatrix(double[][] source, int fromRow, int fromCol,
double[][] dest, int toRow, int toCol, int rows, int cols) {
for (int r = 0; r < rows; r++) {
for (int c = 0; c < cols; c++) {
dest[toRow + r][toCol + c] = source[fromRow + r][fromCol + c];
}
}
}
public static double[] extractSelectedTimePoints(double[] data, int[] timePoints) {
double[] extracted = new double[timePoints.length];
for (int t = 0; t < timePoints.length; t++) {