struct Geode::Matrix3x1(T)
 Geode::Matrix3x1(T)
 Struct
 Value
 Object
Overview
Matrix with 3 rows and 1 column. Provides a rectangular array of scalars of the same type.
T is the scalar type. Indices i and j refer to the zerobased row and column index respectively. Unless noted otherwise, all operations are in rowmajor order.
Included Modules
Defined in:
geode/matrices/matrix3.crConstructors

.new(matrix : CommonMatrix(T, 3, 1))
Copies contents from another matrix.

.new(&)
Creates a new matrix by iterating through each element.

.new(rows : Indexable(Indexable(T)))
Creates a new matrix from nested collections.

.new(elements : Indexable(T))
Creates a new matrix from a flat collection of elements.

.zero : self
Creates a matrix filled with zeroes.
Class Method Summary

.[](row_0 : Indexable, row_1 : Indexable, row_2 : Indexable)
Constructs a matrix with existing elements.
Instance Method Summary

#&*(other : CommonMatrix(U, 1, P)) : Matrix forall U, P
Multiplies this matrix by another.

#&*(other : Matrix1x1) : Matrix3x1
Multiplies this matrix by another.

#&*(other : Matrix1x2) : Matrix3x2
Multiplies this matrix by another.

#&*(other : Matrix1x3) : Matrix3x3
Multiplies this matrix by another.

#&*(other : Matrix1x4) : Matrix3x4
Multiplies this matrix by another.

#*(other : CommonMatrix(U, 1, P)) : Matrix forall U, P
Multiplies this matrix by another.

#*(other : Matrix1x1) : Matrix3x1
Multiplies this matrix by another.

#*(other : Matrix1x2) : Matrix3x2
Multiplies this matrix by another.

#*(other : Matrix1x3) : Matrix3x3
Multiplies this matrix by another.

#*(other : Matrix1x4) : Matrix3x4
Multiplies this matrix by another.

#a : T
Retrieves the element at (0, 0)

#b : T
Retrieves the element at (1, 0)

#c : T
Retrieves the element at (2, 0)

#map(& : T > U) : Matrix3x1 forall U
Returns a new matrix with elements mapped by the given block.

#to_slice : Slice(T)
Returns a slice that points to the elements in this matrix.

#to_unsafe : Pointer(T)
Returns a pointer to the data for this matrix.

#transpose : Matrix1x3(T)
Returns a new matrix that is transposed from this one.

#unsafe_fetch(index : Int)
Retrieves the scalar value of the component at the given index, without checking size boundaries.

#unsafe_fetch_column(j : Int) : Vector3(T)
Retrieves the column at the specified index.

#unsafe_fetch_row(i : Int) : Vector1(T)
Retrieves the row at the specified index.
Macro Summary

[](*rows)
Constructs a matrix with existing elements.
Instance methods inherited from module Geode::CommonMatrix(T, 3, 1)
[](i : Int, j : Int) : T
[],
[]?(i : Int, j : Int) : T  Nil
[]?,
column(j : Int) : CommonVector(T, M)
column,
column?(j : Int) : CommonVector(T, M)  Nil
column?,
columns : Int
columns,
columns_at(*indices) : Tuple
columns_at,
each_column(& : CommonVector(T, M) > _)
each_column,
each_column_with_index(offset = 0, & : CommonVector(T, M), Int32 > _)
each_column_with_index,
each_indices(& : Int32, Int32 > _)
each_indices,
each_row(& : CommonVector(T, N) > _)
each_row,
each_row_with_index(offset = 0, & : CommonVector(T, N), Int32 > _)
each_row_with_index,
each_with_indices(& : T, Int32, Int32 > _)
each_with_indices,
inspect(io : IO) : Nil
inspect,
map(& : T > U) : CommonMatrix forall U
map,
map_with_index(offset = 0, & : T, Int32 > U) : CommonMatrix(U, M, N) forall U
map_with_index,
map_with_indices(& : T, Int32, Int32 > U) : CommonMatrix(U, M, N) forall U
map_with_indices,
row(i : Int) : CommonVector(T, N)
row,
row?(i : Int) : CommonVector(T, N)  Nil
row?,
rows : Int
rows,
rows_at(*indices) : Tuple
rows_at,
size
size,
square?
square?,
to_columns : Array
to_columns,
to_rows : Array
to_rows,
to_s(io : IO) : Nil
to_s,
unsafe_fetch(i : Int, j : Int) : T
unsafe_fetch,
unsafe_fetch_column(j : Int) : CommonVector(T, M)
unsafe_fetch_column,
unsafe_fetch_row(i : Int) : CommonVector(T, N)
unsafe_fetch_row,
zip_map(other : CommonMatrix(U, M, N), & : T, U > V) : CommonMatrix(V, M, N) forall U, V
zip_map
Instance methods inherited from module Geode::MatrixVectors(3, 1)
&*(vector : CommonVector(U, P)) : CommonVector forall U, P
&*,
*(vector : CommonVector(U, P)) : CommonVector forall U, P
*,
column?
column?,
row?
row?,
to_vector : CommonVector
to_vector
Instance methods inherited from module Geode::MatrixOperations(3, 1)
&*(scalar : Number) : CommonMatrix
&*,
&+(other : CommonMatrix(T, M, N)) : CommonMatrix forall T
&+,
&(other : CommonMatrix(T, M, N)) : CommonMatrix forall T
&,
*(scalar : Number) : CommonMatrix
*,
+(other : CommonMatrix(T, M, N)) : CommonMatrix forall T
+,
(other : CommonMatrix(T, M, N)) : CommonMatrix forall T : self , /(scalar : Number) : CommonMatrix /, //(scalar : Number) : CommonMatrix //, abs : self abs, abs2 : self abs2, ceil : self ceil, clamp(min : CommonMatrix(T, M, N), max : CommonMatrix(T, M, N)) : CommonMatrix forall T
clamp(min, max) : CommonMatrix
clamp(range : Range(CommonMatrix(T, M, N), CommonMatrix(T, M, N))) : CommonMatrix forall T
clamp(range : Range) : CommonMatrix clamp, edge(edge : CommonMatrix(T, M, N)) : self forall T
edge(edge) : self edge, floor : self floor, fraction : self fraction, lerp(other : CommonMatrix(T, M, N), t : Number) : CommonMatrix forall T lerp, round(mode : Number::RoundingMode = :ties_even) : self
round(digits : Number, base = 10, *, mode : Number::RoundingMode = :ties_even) : self round, scale(matrix : CommonMatrix(T, M, N)) : CommonMatrix forall T scale, scale!(matrix : CommonMatrix(T, M, N)) : CommonMatrix forall T scale!, sign : self sign
Instance methods inherited from module Geode::MatrixIterators(T, 3, 1)
each_column : Iterator(CommonVector(T, M))
each_column,
each_column_with_index(offset = 0) : Iterator(Tuple(CommonVector(T, M), Int32))
each_column_with_index,
each_indices : Iterator(Tuple(Int32, Int32))
each_indices,
each_row : Iterator(CommonVector(T, N))
each_row,
each_row_with_index(offset = 0) : Iterator(Tuple(CommonVector(T, N), Int32))
each_row_with_index,
each_with_indices : Iterator(Tuple(T, Int32, Int32))
each_with_indices
Instance methods inherited from module Geode::MatrixComparison(3, 1)
==(other : CommonMatrix(T, M, N)) forall T
==,
compare(other : CommonMatrix(T, M, N)) : CommonMatrix(Int32, M, N) forall T
compare,
eq?(other : CommonMatrix(T, M, N)) : CommonMatrix(Bool, M, N) forall T
eq?,
ge?(other : CommonMatrix(T, M, N)) : CommonMatrix(Bool, M, N) forall T
ge?,
gt?(other : CommonMatrix(T, M, N)) : CommonMatrix(Bool, M, N) forall T
gt?,
le?(other : CommonMatrix(T, M, N)) : CommonMatrix(Bool, M, N) forall T
le?,
lt?(other : CommonMatrix(T, M, N)) : CommonMatrix(Bool, M, N) forall T
lt?,
near_zero?(tolerance)
near_zero?,
zero?
zero?
Constructor Detail
Creates a new matrix by iterating through each element.
Yields the indices (i and j) for the matrix element. The block should return the value to use for the corresponding element.
Matrix3x1.new { i, j i * 10 + j }
Creates a new matrix from nested collections.
The size of rows must be 3. Each row of elements in rows must have a size of 1.
Creates a new matrix from a flat collection of elements.
The size of elements must be equal to 3 x 1 (3). Items in elements are consumed in rowmajor order.
Class Method Detail
Constructs a matrix with existing elements.
The type of the elements is specified by the type parameter. Each value is cast to the type T.
Instance Method Detail
Multiplies this matrix by another.
The other matrix's row count (M) must be equal to this matrix's column count (N). Produces a new matrix with the row count from this matrix and the column count from other. Matrices can be of any size and type as long as this condition is met.
Values will wrap instead of overflowing and raising an error.
Multiplies this matrix by another.
The other matrix's row count (M) must be equal to this matrix's column count (N). Produces a new matrix with the row count from this matrix and the column count from other. Matrices can be of any size and type as long as this condition is met.
Values will wrap instead of overflowing and raising an error.
Multiplies this matrix by another.
The other matrix's row count (M) must be equal to this matrix's column count (N). Produces a new matrix with the row count from this matrix and the column count from other. Matrices can be of any size and type as long as this condition is met.
Values will wrap instead of overflowing and raising an error.
Multiplies this matrix by another.
The other matrix's row count (M) must be equal to this matrix's column count (N). Produces a new matrix with the row count from this matrix and the column count from other. Matrices can be of any size and type as long as this condition is met.
Values will wrap instead of overflowing and raising an error.
Multiplies this matrix by another.
The other matrix's row count (M) must be equal to this matrix's column count (N). Produces a new matrix with the row count from this matrix and the column count from other. Matrices can be of any size and type as long as this condition is met.
Values will wrap instead of overflowing and raising an error.
Multiplies this matrix by another.
The other matrix's row count (M) must be equal to this matrix's column count (N). Produces a new matrix with the row count from this matrix and the column count from other. Matrices can be of any size and type as long as this condition is met.
Multiplies this matrix by another.
The other matrix's row count (M) must be equal to this matrix's column count (N). Produces a new matrix with the row count from this matrix and the column count from other. Matrices can be of any size and type as long as this condition is met.
Multiplies this matrix by another.
The other matrix's row count (M) must be equal to this matrix's column count (N). Produces a new matrix with the row count from this matrix and the column count from other. Matrices can be of any size and type as long as this condition is met.
Multiplies this matrix by another.
The other matrix's row count (M) must be equal to this matrix's column count (N). Produces a new matrix with the row count from this matrix and the column count from other. Matrices can be of any size and type as long as this condition is met.
Multiplies this matrix by another.
The other matrix's row count (M) must be equal to this matrix's column count (N). Produces a new matrix with the row count from this matrix and the column count from other. Matrices can be of any size and type as long as this condition is met.
Returns a new matrix with elements mapped by the given block.
Returns a slice that points to the elements in this matrix.
NOTE The returned slice is only valid for the caller's scope and subcalls. The slice points to memory on the stack, it will be invalid after the caller returns.
Returns a pointer to the data for this matrix.
The elements are tightly packed and ordered consecutively in memory.
NOTE The returned pointer is only valid for the caller's scope and subcalls. The pointer refers to memory on the stack, it will be invalid after the caller returns.
Retrieves the scalar value of the component at the given index, without checking size boundaries.
Endusers should never invoke this method directly.
Instead, methods like #[]
and #[]?
should be used.
This method should only be directly invoked if the index is certain to be in bounds.
Retrieves the column at the specified index.
Returns the elements as a vector. The vector will have a size equal to the number of rows in this matrix. This method does not perform any bounds checks. It should only be used if the indices are guaranteed to be in bounds.
matrix = Matrix[[1, 2, 3], [4, 5, 6]]
matrix.unsafe_fetch_column(1) # => (2, 5)
Retrieves the row at the specified index.
Returns the elements as a vector. The vector will have a size equal to the number of columns in this matrix. This method does not perform any bounds checks. It should only be used if the indices are guaranteed to be in bounds.
matrix = Matrix[[1, 2, 3], [4, 5, 6]]
matrix.unsafe_fetch_row(1) # => (4, 5, 6)
Macro Detail
Constructs a matrix with existing elements.
The type of the elements is derived from the type of each argument. The size of rows must be 3 and the size of each row must be 1.