public Matrix insertRow(int i, Vector row) {
if (i >= rows || i < 0) {
throw new IndexOutOfBoundsException("Illegal row number, must be 0.." + (rows - 1));
}
Matrix result = blankOfShape(rows + 1, columns);
for (int ii = 0; ii < i; ii++) {
result.setRow(ii, getRow(ii));
}
result.setRow(i, row);
for (int ii = i; ii < rows; ii++) {
result.setRow(ii + 1, getRow(ii));
}
return result;
}
Doesn't allow you to start with an empty matrix and add rows to it. I won't every know the size of my matrix upon creation!? :-)
Thanks,
David