class Ish::Matrix(T)

Defined in:

ish/lib/matrix.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(m : Int, n : Int, value : T) #

Creates a m x n matrix with each element initialized as value.


[View source]
def self.new(m : Int, n : Int, &block) #

Creates an m x n matrix, yielding indicies for each element to provide an initial value.


[View source]

Instance Method Detail

def [](i : Int, j : Int) : T #

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).


[View source]
def []=(i : Int, j : Int, value : T) #

Sets the value of the element at i,j.


[View source]
def size #

Returns the dimensions of self as a tuple of {m, n}.


[View source]
def update(i, j, &block : T -> T) #

Yields the current element at i,j and updates the value with the block's return value.


[View source]