NumEx v0.1.0 Matrix View Source
A module to perform Matrix Operations
Link to this section Summary
Functions
Performs elmentwise addition
Removes the column j from the matrix
Takes matrix and returns number of columns in the given matrix
Computes the determinant of a matrix
Takes three numerals ‘row’, ‘col’, ‘k’ and returns eye matrix of the given order
Takes a numeral ‘col’ and returns a single row of ‘col’ number of random elements
Takes two numerals ‘row’, ‘col and returns a the identity matrix of the given order
Takes a Matrix and finds the maximum element from each row
Takes two numerals ‘row’, ‘col’ and returns a matrix of ones
Takes two numerals ‘row’, ‘col’ and returns a matrix of random elements
Removes the row i from the matrix
Takes matrix and returns number of rows in the given matrix
Elementwise mutiplication with a scalar
Takes a Matrix, returns size of the matrix
Performs elementwise subtraction
Returns the (i, j) submatrix of a matrix. This is the matrix with the ith row and jth column removed
Computes the the trace of a matrix. This is the sum of the elements accross the diagonal of a matrix
Transposes a matrix
Takes two numerals ‘row’, ‘col’ and returns a matrix of zeros
Link to this section Functions
Performs elmentwise addition
Examples
iex> Matrix.add([[1, 2, 3],[1, 1, 1]],[[3, 2, 1],[2, 2, 2]])
[[4, 4, 4],
[3, 3, 3]]
colRemove([[number()]], number()) :: [[number()]]
Removes the column j from the matrix.
Examples
iex> Matrix.colRemove([[2, 9, 4], [8, 7, 6], [3, 1, 5]], 2)
[[2, 4], [8, 6], [3, 5]]
Takes matrix and returns number of columns in the given matrix.
Examples
iex> Matrix.colcount([[12,34,56,11],[98,78,67,0],[0,34,78,9]])
4
eye(number(), number(), number()) :: [[number()]]
Takes three numerals ‘row’, ‘col’, ‘k’ and returns eye matrix of the given order.
Examples
iex> Matrix.eye(4,3,0)
[[1, 0, 0], [0, 1, 0], [0, 0, 1], [0, 0, 0]]
iex> Matrix.eye(3, 3, -1)
[[0, 0, 0], [1, 0, 0], [0, 1, 0]]
Takes a numeral ‘col’ and returns a single row of ‘col’ number of random elements..
Examples
iex> Matrix.genrandrow(6)
[34, 101, 23, 110, 17, 10]
Takes two numerals ‘row’, ‘col and returns a the identity matrix of the given order.
Examples
iex> Matrix.identity(6,3)
[[1, 0, 0], [0, 1, 0], [0, 0, 1], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
Takes a Matrix and finds the maximum element from each row.
Examples
iex>Matrix.max([[1,2,34],[3,4,5],[4,5,6,7]])
[34, 5, 7]
Takes two numerals ‘row’, ‘col’ and returns a matrix of ones.
Examples
iex> Matrix.ones(5,3)
[[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]
Takes two numerals ‘row’, ‘col’ and returns a matrix of random elements.
Examples
iex> Matrix.rand(2,3)
[[47, 31, 53], [6, 7, 42]]
rowRemove([[number()]], number()) :: [[number()]]
Removes the row i from the matrix.
Examples
iex> Matrix.rowRemove([[2, 9, 4], [8, 7, 6], [3, 1, 5]], 1)
[[8, 7, 6], [3, 1, 5]]
Takes matrix and returns number of rows in the given matrix.
Examples
iex> Matrix.rowcount([[12,34,56,11],[98,78,67,0],[0,34,78,9]])
3
Elementwise mutiplication with a scalar.
Examples
iex> Matrix.scalar([[2, 2, 2], [1, 1, 1]], 2)
[[4, 4, 4],
[2, 2, 2]]
Takes a Matrix, returns size of the matrix.
Examples
iex> Matrix.size([[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]])
6
Performs elementwise subtraction
Examples
iex> Matrix.sub([[1, 2, 3],[1, 2, 2]],[[1, 2, 3],[2, 2, 2]])
[[0, 0, 0],
[-1, 0, 0]]
submatrix([[number()]], number(), number()) :: [[number()]]
Returns the (i, j) submatrix of a matrix. This is the matrix with the ith row and jth column removed.
Examples
iex> Matrix.submatrix([[2, 9, 4], [8, 7, 6], [3, 1, 5]], 2, 3)
[[2, 9], [3, 1]]
Computes the the trace of a matrix. This is the sum of the elements accross the diagonal of a matrix.
Examples
iex> Matrix.trace([[6, 1, 1], [4, -2, 5], [2, 8, 7]])
11
Transposes a matrix.
Examples
iex> Matrix.transpose([[1, 2, 3], [4, 5, 6]])
[[1, 4], [2, 5], [3, 6]]