matrix_operation v0.1.0 MatrixOperation

Documentation for Matrix operation library.

Link to this section Summary

Functions

Matrix addition

A matrix is multiplied by a constant.

A row of a matrix is deleted.

A determinant of a n×n square matrix is got.

A column of a matrix is got.

A element of a matrix is got.

A row of a matrix is got.

Hadamard division

Hadamard power

Hadamard product

Inverse Matrix

Liner equations are solved.

Matrix product

Numbers of row and column of a matrix are got.

Matrix subtraction

Tensor product

Trace of a matrix

Transpose of a matrix

Link to this section Functions

Matrix addition

Examples

iex> MatrixOperation.add([[3, 2, 3], [2, 1, 2]], [[2, 3, 1], [3, 2, 2]])
[[5, 5, 4], [5, 3, 4]]
Link to this function

const_multiple(const, a)

A matrix is multiplied by a constant.

Examples

iex> MatrixOperation.const_multiple(-1, [1.0, 2.0, 3.0])
[-1.0, -2.0, -3.0]
iex> MatrixOperation.const_multiple(2, [[1, 2, 3], [2, 2, 2], [3, 8, 9]])
[[2, 4, 6], [4, 4, 4], [6, 16, 18]]
Link to this function

cramer(t, a, select_index)

Cramer's rule

Examples

iex> MatrixOperation.cramer([1, 0, 0], [[1, 0, 0], [0, 1, 0], [0, 0, 1]], 0)
1.0
Link to this function

delete_one_row(matrix, delete_index)

A row of a matrix is deleted.

Examples

iex> MatrixOperation.delete_one_row([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 3)
[[1, 2, 3], [4, 5, 6]]

A determinant of a n×n square matrix is got.

Examples

iex> MatrixOperation.determinant([[1, 2, 1], [2, 1, 0], [1, 1, 2]])
-5
iex> MatrixOperation.determinant([[1, 2, 1, 1], [2, 1, 0, 1], [1, 1, 2, 1], [1, 2, 3, 4]])
-13
iex> MatrixOperation.determinant([ [3,1,1,2,1], [5,1,3,4,1], [2,0,1,0,1], [1,3,2,1,1], [1,1,1,1,1] ])
-14
Link to this function

get_one_column(matrix, column_index)

A column of a matrix is got.

Examples

iex> MatrixOperation.get_one_column([[1, 2, 3], [4, 5, 6], [7, 8, 9] ], 1)
[1, 4, 7]
Link to this function

get_one_element(matrix, list)

A element of a matrix is got.

Examples

iex> MatrixOperation.get_one_element([[1, 2, 3], [4, 5, 6], [7, 8, 9] ], [1, 1]) 1

Link to this function

get_one_row(matrix, row_index)

A row of a matrix is got.

Examples

iex> MatrixOperation.get_one_row([[1, 2, 3], [4, 5, 6], [7, 8, 9] ], 1) [1, 2, 3]

Link to this function

hadamard_division(a, b)

Hadamard division

Examples

iex> MatrixOperation.hadamard_division([[3, 2, 3], [2, 1, 2]], [[2, 3, 1], [3, 2, 2]])
[[1.5, 0.6666666666666666, 3.0], [0.6666666666666666, 0.5, 1.0]]
Link to this function

hadamard_power(a, n)

Hadamard power

Examples

iex> MatrixOperation.hadamard_power([[3, 2, 3], [2, 1, 2]], 2)
[[9.0, 4.0, 9.0], [4.0, 1.0, 4.0]]
Link to this function

hadamard_product(a, b)

Hadamard product

Examples

iex> MatrixOperation.hadamard_product([[3, 2, 3], [2, 1, 2]], [[2, 3, 1], [3, 2, 2]])
[[6, 6, 3], [6, 2, 4]]
Link to this function

inverse_matrix(a)

Inverse Matrix

Examples

iex> MatrixOperation.inverse_matrix([[1, 1, -1], [-2, -1, 1], [-1, -2, 1]])
[[-1.0, -1.0, 0.0], [-1.0, 0.0, -1.0], [-3.0, -1.0, -1.0]]
Link to this function

linear_equations(t, a)

Liner equations are solved.

Examples

iex> MatrixOperation.linear_equations([1, 0, 0], [[1, 0, 0], [0, 1, 0], [0, 0, 1]])
[1.0, 0.0, 0.0]
iex> MatrixOperation.linear_equations([3, -7, 4], [[0, -2, 1], [-1, 1, -4], [3, 3, 1]])
[2.0, -1.0, 1.0]

Matrix product

Examples

iex> MatrixOperation.product([[3, 2, 3], [2, 1, 2]], [[2, 3], [2, 1], [3, 5]])
[[19, 26], [12, 17]]
Link to this function

row_column_matrix(a)

Numbers of row and column of a matrix are got.

Examples

iex> MatrixOperation.row_column_matrix([[3, 2, 3], [2, 1, 2]]) [2, 3]

Matrix subtraction

Examples

iex> MatrixOperation.subtract([[3, 2, 3], [2, 1, 2]], [[2, 3, 1], [3, 2, 2]])
[[1, -1, 2], [-1, -1, 0]]
Link to this function

tensor_product(a, b)

Tensor product

Examples

iex> MatrixOperation.tensor_product([[3, 2, 3], [2, 1, 2]], [[2, 3, 1], [2, 1, 2], [3, 5, 3]])
[
[
[[6, 9, 3], [6, 3, 6], [9, 15, 9]],
[[4, 6, 2], [4, 2, 4], [6, 10, 6]],
[[6, 9, 3], [6, 3, 6], [9, 15, 9]]
],
[
[[4, 6, 2], [4, 2, 4], [6, 10, 6]],
[[2, 3, 1], [2, 1, 2], [3, 5, 3]],
[[4, 6, 2], [4, 2, 4], [6, 10, 6]]
]
]

Trace of a matrix

Examples

iex> MatrixOperation.trace([[1.0, 2.0], [3.0, 4.0]])
5.0

Transpose of a matrix

Examples

iex> MatrixOperation.transpose([[1.0, 2.0], [3.0, 4.0]])
[[1.0, 3.0], [2.0, 4.0]]