class Ish::Matrix(T)
- Ish::Matrix(T)
- Reference
- Object
Defined in:
ish/lib/matrix.crConstructors
-
.new(m : Int, n : Int, value : T)
Creates a m x n matrix with each element initialized as value.
-
.new(m : Int, n : Int, &block)
Creates an m x n matrix, yielding indicies for each element to provide an initial value.
Instance Method Summary
-
#[](i : Int, j : Int) : T
Retrieves the value of the element at i,j.
-
#[]=(i : Int, j : Int, value : T)
Sets the value of the element at i,j.
-
#size
Returns the dimensions of
self
as a tuple of{m, n}
. -
#update(i, j, &block : T -> T)
Yields the current element at i,j and updates the value with the block's return value.
Constructor Detail
Creates a m x n matrix with each element initialized as value.
Creates an m x n matrix, yielding indicies for each element to provide an initial value.
Instance Method Detail
Retrieves the value of the element at i,j.
Indicies are zero-based. Negative values may be passed for i and j to
enable reverse indexing such that self[-1, -1] == self[m - 1, n - 1]
(same behaviour as arrays).
Yields the current element at i,j and updates the value with the block's return value.