numeric v0.0.1 Elyanah.Numeric
Operators for Matrix & Array operations.
Summary
Functions
Multiply matrices and vectors.
Examples
iex> [[1,2],[3,4]] * [[1,2], [3,4]]
['\a\n', [15, 22]]
iex> [1,2] * [[1,2], [3,4]]
['\a\n']
iex> [[1,2],[3,4]] * [1,2]
[[5], '\v']
iex> 3 * [[1,2], [3,4]]
[[3, 6], '\t\f']
iex> [[1,2], [3,4]] * 3
[[3, 6], '\t\f']
iex> [1,2] * [3,4]
[3, 8]
iex> 3 * [1,2]
[3, 6]
iex> [1,2] * 3
[3, 6]
iex> 3 * 4
12
Add matrices and vectors.
Examples
iex> [[1,2],[3,4]] + [[1,2], [3,4]]
[[2, 4], [6, 8]]
iex> [1,2] + [[1,2], [3,4]]
[[2, 3], [5, 6]]
iex> [[1,2],[3,4]] + [1,2]
[[2, 3], [5, 6]]
iex> 3 + [[1,2], [3,4]]
[[4, 5], [6, 7]]
iex> [[1,2], [3,4]] + 3
[[4, 5], [6, 7]]
iex> [1,2] + [3,4]
[4, 6]
iex> 3 + [1,2]
[4, 5]
iex> [1,2] + 3
[4, 5]
iex> 3 + 4
7
Subtract matrices and vectors.
Examples
iex> [[1,2],[3,4]] - [[1,2], [3,4]]
[[0, 0], [0, 0]]
iex> [1,2] - [[1,2], [3,4]]
[[0, -1], [-1, -2]]
iex> [[1,2],[3,4]] - [1,2]
[[0, 1], [1, 2]]
iex> 3 - [[1,2], [3,4]]
[[2, 1], [0, -1]]
iex> [[1,2], [3,4]] - 3
[[-2, -1], [0, 1]]
iex> [1,2] - [3,4]
[-2, -2]
iex> 3 - [1,2]
[2, 1]
iex> [1,2] - 3
[-2, -1]
iex> 3 - 4
-1
Divide matrices and vectors.
Examples
iex> [[1,2],[3,4]] / [[1,2], [3,4]]
[[1.0, 0.0], [0.0, 1.0]]
iex> [1,2] / [[1,2], [3,4]]
[[1.0, 0.0]]
iex> 3 / [[1,2], [3,4]]
[[-6.0, 3.0], [4.5, -1.5]]
iex> [[1,2], [3,4]] / 3
[[0.3333333333333333, 0.6666666666666666], [1.0, 1.3333333333333333]]
iex> [1,2] / [3,4]
[0.3333333333333333, 0.5]
iex> 3 / [1,2]
[3.0, 1.5]
iex> [1,2] / 3
[0.3333333333333333, 0.6666666666666666]
iex> 3 / 4
0.75