himamo v0.1.0 Himamo.Matrix
Defines a two- or three-dimensional matrix.
Examples
iex> matrix = Himamo.Matrix.new({2, 3})
...> matrix = Himamo.Matrix.put(matrix, {1, 0}, 0.1)
...> Himamo.Matrix.get(matrix, {1, 0})
0.1
Implements the Collectable
protocol.
Examples
iex> matrix = [{{0, 1}, 0.1}] |> Enum.into(Himamo.Matrix.new({2, 2}))
...> Himamo.Matrix.get(matrix, {0, 1})
0.1
Summary
Types
Functions
Returns entry at position
.
position
is a tuple of indices.
Raises KeyError
when accessing a position that was not previously set.
Specs
new(tuple) :: t
Creates a Matrix
.
The size
argument is a tuple that specifies the dimensions. For example,
new({5, 3})
creates a 5×3 two-dimensional matrix and new({7, 5, 4})
creates a 7×5×4 three-dimensional matrix.