module Geode::VectorMatrices(T, N)

Overview

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.

Direct including types

Defined in:

geode/vectors/matrices.cr

Instance Method Summary

Instance Method Detail

def &*(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)

[View source]
def *(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)

[View source]
def to_column : CommonMatrix #

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]]

[View source]
def to_row : CommonMatrix #

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]]

[View source]