# Vector class

The Vector class

Most of the class code is not optimized for high performance but for readability. You should be able to read the functions and understand what is going on with basic linear algebra knowledge.

The vector can be either a row or column vector. More reading about vectors

``````final Matrix a = Matrix([[1, 2], [3, 4]]);
final Vector b = Vector.column([2, 3]);
final Matrix e = Matrix([[8], [18]]);
Matrix result = a * b;
print(result);
print(result == e);
``````

This prints

``````[[8.0], [18.0]]
true
``````

## Constructors

Vector.column(List<double> values)
Creates a column vector from the list of values given. [...]
factory
Vector.fillColumn(int count, [ double fill = 0.0 ])
Creates a column vector with `count` elements filled with `fill` [...]
factory
Vector.fillRow(int count, [ double fill = 0.0 ])
Creates a row vector with `count` elements filled with `fill` [...]
factory
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.
factory
Vector.row(List<double> values)
Creates a row vector from the list of values given. [...]
factory

## Properties

elements → int
Returns the number of elements in the vector.
hashCode → int
Returns the hashCode for the matrix.
type
Returns the VectorType of the vector.
runtimeType → Type
A representation of the runtime type of the object.

## Methods

crossProduct(Vector other)
Calculates the cross product for two 3-dimensional vectors. [...]
dotProduct(Vector other) → double
Calculates the dot product for two 3-dimensional vectors. [...]
magnitude() → double
Returns the magnitude, length or Euclidean norm of the vector. [...]
manhattanNorm() → double
Returns the Manhattan norm of the vector. [...]
map()
Maps this Vector via function `f` to a new Vector. [...]
mean() → double
Returns element wise mean of the vector. [...]
norm() → double
Returns the Euclidean norm of the vector. [...]
normalize()
Normalizes this Vector to have magnitude 1.0 [...]
sum() → double
Returns element wise sum of the vector. [...]
toList([bool deepCopy = true ]) → List<double>
Returns the `List<double>` of this Vector [...]
toMatrix([bool deepCopy = true ])
Returns the Matrix representation of this Vector [...]
toString() → String
Prints the content of the matrix.
transpose()
Transposes a Vector from row or column to column or row. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited

## Operators

operator *(dynamic other)
Multiplies two vectors, note the return value is a Matrix. If you need a scalar result add `0`, and if you need the Vector result add .toVector() [...]
operator +(Vector other)
Access the `element`'s value in the vector. [...]