Vector.fromMatrix constructor
Vector.fromMatrix(
- Matrix matrix
Converts a Matrix to a Vector if one of its dimensions is 1 will throw MatrixInvalidDimensions if that is not the case.
Implementation
factory Vector.fromMatrix(Matrix matrix) {
if (matrix.m == 1) {
return Vector._(matrix, VectorType.row);
} else if (matrix.n == 1) {
return Vector._(matrix, VectorType.column);
}
throw MatrixInvalidDimensions("n or m must be 1 to be able to cast to a vector.");
}