module Geode::MatrixVectors(M, N)
Overview
Methods for matrices interacting with vectors.
Intended to be used as a mix-in on matrix types. M and N are the number of rows and columns respectively.
Direct including types
Defined in:
geode/matrices/vectors.crInstance Method Summary
-
#&*(vector : CommonVector(U, P)) : CommonVector forall U, P
Multiplies the matrix by a vector.
-
#*(vector : CommonVector(U, P)) : CommonVector forall U, P
Multiplies the matrix by a vector.
-
#column?
Indicates whether this matrix is a column vector.
-
#row?
Indicates whether this matrix is a row vector.
-
#to_vector : CommonVector
Converts this matrix to a vector.
Instance Method Detail
Multiplies the matrix by a vector.
The vector is treated as a single column 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.
matrix = Matrix[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
vector = Vector[1, 10, 100]
matrix &* vector # => (321, 654, 987)
Multiplies the matrix by a vector.
The vector is treated as a single column 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.
matrix = Matrix[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
vector = Vector[1, 10, 100]
matrix * vector # => (321, 654, 987)
Indicates whether this matrix is a column vector.
Returns true if the matrix has one column.
Converts this matrix to a vector.
Requires that the matrix is a row or column vector. That is, the matrix has one row or one column.
matrix = Matrix[[1, 2, 3]]
matrix.to_vector # => (1, 2, 3)
matrix = Matrix[[1], [2], [3]]
matrix.to_vector # => (1, 2, 3)