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

Link to this function add(m1, m2) View Source
add([[number()]], [[number()]]) :: [[number()]]

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]]
Link to this function colRemove(mat, j) View Source
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]]
Link to this function columncount(list) View Source
columncount([[number()]]) :: number()

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
Link to this function det(mat) View Source
det([[number()]]) :: number()

Computes the determinant of a matrix.

Examples

iex> Matrix.det([[6, 2, 1], [4, 3, 5], [2, 0, 7]])

Link to this function eye(row, col, k) View Source
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]]
Link to this function genrandrow(col) View Source
genrandrow(number()) :: [number()]

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]
Link to this function identity(row, col) View Source
identity(number(), number()) :: [[number()]]

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]]
Link to this function max(mat) View Source
max([[integer()]]) :: [integer()]

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]
Link to this function ones(row, col) View Source
ones(number(), number()) :: [[number()]]

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]]
Link to this function rand(row, col) View Source
rand(number(), number()) :: [[number()]]

Takes two numerals ‘row’, ‘col’ and returns a matrix of random elements.

Examples

iex> Matrix.rand(2,3)
[[47, 31, 53], [6, 7, 42]]
Link to this function rowRemove(mat, i) View Source
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]]
Link to this function rowcount(row) View Source
rowcount([[number()]]) :: number()

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
Link to this function scalar(m1, s) View Source
scalar([[number()]], number()) :: [[number()]]

Elementwise mutiplication with a scalar.

Examples

iex> Matrix.scalar([[2, 2, 2], [1, 1, 1]], 2)
[[4, 4, 4],
 [2, 2, 2]]
Link to this function size(row) View Source
size([number()]) :: number()

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
Link to this function sub(m1, m2) View Source
sub([[number()]], [[number()]]) :: [[number()]]

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]]
Link to this function submatrix(mat, i, j) View Source
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]]
Link to this function trace(mat) View Source
trace([[number()]]) :: number()

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
Link to this function transpose(a) View Source
transpose([[number()]]) :: [[number()]]

Transposes a matrix.

Examples

iex> Matrix.transpose([[1, 2, 3], [4, 5, 6]])
[[1, 4], [2, 5], [3, 6]]
Link to this function zeros(row, col) View Source
zeros(number(), number()) :: [[number()]]

Takes two numerals ‘row’, ‘col’ and returns a matrix of zeros.

Examples

iex> Matrix.zeros(6,3)
[[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]