columnVector method
Returns a column from the matrix as a vector.
This function returns a new vector that never shares its storage with the source matrix.
Example
Matrix m = Matrix([
[1.0, 2.0, 3.0, 1.0],
[4.0, 5.0, 6.0, 2.0],
[7.0, 8.0, 9.0, 3.0],
]);
print( m.columnVector(0) )
prints
1.0,
4.0,
7.0
Implementation
Vector columnVector(int column) {
if (column < 0 || column >= this.n) {
throw MatrixInvalidDimensions();
}
Vector vector = Vector.fillColumn(this.m);
for (int i = 0; i < this.m; i++) {
vector[i] = this[i][column];
}
return vector;
}