exalgebra v0.0.2 ExAlgebra.Matrix
ExAlgebra.Matrix contains functions used in matrix algebra.
Summary
Functions
Returns the addition of two matrices. ## Examples
Returns the (i, j) cofactor of a matrix. ## Examples
Returns the determinant of a matrix. ## Examples
Returns the (i, j) minor of a matrix. ## Examples
iex> matrix = [[2, 3, 4], [1, 0, 0], [3, 4, 5]]
[[2, 3, 4], [1, 0, 0], [3, 4, 5]]
Returns the multiplication of two matrices. ## Examples
Removes the ith column of a matrix. ## Examples
Removes the ith row of a matrix. ## Examples
Returns the multiple of a matrix by a scalar. ## Examples
Returns the size of a matrix. ## Examples
Returns the (i, j) submatrix of a 3 x 3 matrix. ## Examples
Returns the subtraction of two matrices. ## Examples
Returns the trace of a matrix. ## Examples
iex> matrix = [[6, 1, 1], [4, -2, 5], [2, 8, 7]]
[[6, 1, 1], [4, -2, 5], [2, 8, 7]]
Returns the transpose of a matrix. ## Examples
Functions
Specs
add([[number]], [[number]]) :: [[number]]
Returns the addition of two matrices. ## Examples
iex> matrix = [[1, 3, 1], [1, 0, 0]]
[[1, 3, 1], [1, 0, 0]]
iex> matrix |> ExAlgebra.Matrix.add [[0, 0, 5], [7, 5, 0]]
[[1, 3, 6], [8, 5, 0]]
Specs
cofactor([[number]], number, number) :: number
Returns the (i, j) cofactor of a matrix. ## Examples
iex> matrix = [[2, 3, 4], [1, 0, 0], [3, 4, 5]]
[[2, 3, 4], [1, 0, 0], [3, 4, 5]]
iex> matrix |> ExAlgebra.Matrix.cofactor(1, 2)
-5
Specs
det([[number]]) :: number
Returns the determinant of a matrix. ## Examples
iex> matrix = [[6, 1, 1], [4, -2, 5], [2, 8, 7]]
[[6, 1, 1], [4, -2, 5], [2, 8, 7]]
iex> matrix |> ExAlgebra.Matrix.det
-306
Specs
minor([[number]], number, number) :: number
Returns the (i, j) minor of a matrix. ## Examples
iex> matrix = [[2, 3, 4], [1, 0, 0], [3, 4, 5]]
[[2, 3, 4], [1, 0, 0], [3, 4, 5]]
iex> matrix |> ExAlgebra.Matrix.minor(1, 2)
5
Specs
multiply([[number]], [[number]]) :: [[number]]
Returns the multiplication of two matrices. ## Examples
iex> matrix = [[2, 3, 4], [1, 0, 0]]
[[2, 3, 4], [1, 0, 0]]
iex> matrix |> ExAlgebra.Matrix.multiply [[0, 1000], [1, 100], [0, 10]]
[[3, 2340], [0, 1000]]
Specs
remove_column([[number]], number) :: [[number]]
Removes the ith column of a matrix. ## Examples
iex> matrix = [[2, 3, 4], [1, 0, 0], [3, 4, 5]]
[[2, 3, 4], [1, 0, 0], [3, 4, 5]]
iex> matrix |> ExAlgebra.Matrix.remove_column(2)
[[2, 4], [1, 0], [3, 5]]
Specs
remove_row([[number]], number) :: [[number]]
Removes the ith row of a matrix. ## Examples
iex> matrix = [[2, 3, 4], [1, 0, 0], [3, 4, 5]]
[[2, 3, 4], [1, 0, 0], [3, 4, 5]]
iex> matrix |> ExAlgebra.Matrix.remove_row(2)
[[2, 3, 4], [3, 4, 5]]
Specs
scalar_multiply([[number]], number) :: [[number]]
Returns the multiple of a matrix by a scalar. ## Examples
iex> matrix = [[1, 3, 1], [1, 0, 0]]
[[1, 3, 1], [1, 0, 0]]
iex> matrix |> ExAlgebra.Matrix.scalar_multiply 2.5
[[2.5, 7.5, 2.5], [2.5, 0, 0]]
Specs
size([[number]]) :: map
Returns the size of a matrix. ## Examples
iex> matrix = [[1, 2], [3, 4], [4, 3]]
[[1, 2], [3, 4], [4, 3]]
iex> matrix |> ExAlgebra.Matrix.size
%{rows: 3, columns: 2}
Specs
submatrix([[number]], number, number) :: [[number]]
Returns the (i, j) submatrix of a 3 x 3 matrix. ## Examples
iex> matrix = [[2, 3, 4], [1, 0, 0], [3, 4, 5]]
[[[2, 3, 4], [1, 0, 0], [3, 4, 5]]
iex> matrix |> ExAlgebra.Matrix.submatrix(2, 3)
[[2, 3], [3, 4]]
Specs
subtract([[number]], [[number]]) :: [[number]]
Returns the subtraction of two matrices. ## Examples
iex> matrix = [[1, 3, 1], [1, 0, 0]]
[[1, 3, 1], [1, 0, 0]]
iex> matrix |> ExAlgebra.Matrix.subtract [[0, 0, 5], [7, 5, 0]]
[[1, 3, -4], [-6, -5, 0]]
Specs
trace([[number]]) :: number
Returns the trace of a matrix. ## Examples
iex> matrix = [[6, 1, 1], [4, -2, 5], [2, 8, 7]]
[[6, 1, 1], [4, -2, 5], [2, 8, 7]]
iex> matrix |> ExAlgebra.Matrix.trace
11