toVector method

Vector toVector([
  1. bool deepCopy = true
])

Returns the Vector representation of this Matrix if one of it's dimensions is 1.

Note that by default this function returns a vector that does not shares its storage with the matrix, but allocates it's own memory. This means you can freely change the matrix after creating the vector and the vector will be unaffected.

If you wish to share the storage with the matrix for performance reasons pass deepCopy = false. This means that changes to the matrix also appear in the vector.

Throws MatrixInvalidDimensions if m or n are not 1.

Implementation

Vector toVector([bool deepCopy = true]) {
  if (deepCopy) {
    return Vector.fromMatrix(this.copy());
  } else {
    return Vector.fromMatrix(this);
  }
}