module

Geode::VectorMatrices(T, N)

Methods for vectors interacting with matrices.

Intended to be used as a mix-in on vector types. N is the number of components in the vector.

Instance methods

&*(matrix : CommonMatrix(U, M, M)) : CommonVector forall U, M

Multiplies the vector by a matrix.

The vector is treated as a single row matrix. Returns a vector of equal size. This method requires that the matrix is square (M == N) and the size of the vector matches the side length of this matrix.

Values will wrap instead of overflowing and raising an error.

vector = Vector[1, 10, 100]
matrix = Matrix[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
vector &* matrix # => (741, 852, 963)
Source
*(matrix : CommonMatrix(U, M, M)) : CommonVector forall U, M

Multiplies the vector by a matrix.

The vector is treated as a single row matrix. Returns a vector of equal size. This method requires that the matrix is square (M == N) and the size of the vector matches the side length of this matrix.

vector = Vector[1, 10, 100]
matrix = Matrix[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
vector * matrix # => (741, 852, 963)
Source
to_column

Converts this vector to a column vector, in other words a matrix with one column.

vector = Vector[1, 2, 3]
vector.to_column # => [[1], [2], [3]]
Source
to_row

Converts this vector to a row vector, in other words a matrix with one row.

vector = Vector[1, 2, 3]
vector.to_row # => [[1, 2, 3]]
Source