Welcome to linalg’s documentation!¶
Welcome! This is the documentation for linalg, a simple python package for linear algebra.
Main functions and classes
-
class
linalg.
Matrix
(mat, valid=False)¶ Implements Matrices.
-
T
() → linalg.types.Matrix¶ computes the transpose of self implemented as an alias of linalg.unary.transpose
Returns: transposed matrix Return type: Matrix
-
det
() → float¶ computes the determinant for self. implemented as an alias of linalg.unary.det
Returns: the determinant for mat Return type: float
-
inv
() → linalg.types.Matrix¶ returns the inverse matrix of mat implemented as an alias of linalg.unary.inverse
Parameters: mat (Matrix) – the matrix to invert Returns: the inverse matrix of mat Return type: Matrix
-
-
linalg.
zeroes
(i: int, j: int) → linalg.types.Matrix¶ creates an i by j zero matrix
Parameters: - i (int) – number of columns
- j (int) – number of rows
Returns: an i by j matrix filled with zeroes
Return type:
-
linalg.
identity
(n: int) → linalg.types.Matrix¶ generates an n by n identity matrix
Parameters: n (int) – number of rows/columns Returns: n by b indentity matrix Return type: Matrix
-
linalg.
random_matrix
(dim: tuple, rng: tuple, use_float: bool = False) → linalg.types.Matrix¶ generates a random matrix
Parameters: - dim (tuple) – dimensions of matrix
- rng (tuple) – range of randomized elements
- float (bool) – whether to use floats for elements (default False)
Returns: randomized matrix of specified size and range
Return type:
-
linalg.
lu
(mat: linalg.types.Matrix) -> (<class 'linalg.types.Matrix'>, <class 'linalg.types.Matrix'>, <class 'linalg.types.Matrix'>, <class 'int'>)¶ implements LUP decomposition
Returns: returns a tuple with L, U, and P Return type: Matrix, Matrix, Matrix, int
-
linalg.
linsolve
(mat: linalg.types.Matrix, b: linalg.types.Matrix) → linalg.types.Matrix¶ solve a system of linear equations using LU decomposition
Parameters: Returns: the solution
Return type:
-
linalg.
pivotize
(mat: linalg.types.Matrix) -> (<class 'linalg.types.Matrix'>, <class 'int'>)¶ creates the pivoting matrix for mat
Parameters: mat (Matrix) – the matrix to perform the operation on Returns: the pivoting matrix for self and the number of permutations Return type: Matrix, int
-
linalg.
inverse
(mat: linalg.types.Matrix) → linalg.types.Matrix¶ returns the inverse matrix of mat
Parameters: mat (Matrix) – the matrix to invert Returns: the inverse matrix of mat Return type: Matrix
-
linalg.
det
(mat: linalg.types.Matrix) → float¶ computes the determinant for a given matrix
Parameters: mat (Matrix) – matrix to compute the determinant for Returns: the determinant for mat Return type: float
-
linalg.
transpose
(mat: linalg.types.Matrix) → linalg.types.Matrix¶ computes the transpose of a given matrix
Parameters: mat (Matrix) – matrix to perform the operation on Returns: transposed matrix Return type: Matrix
-
linalg.
T
(mat: linalg.types.Matrix) → linalg.types.Matrix¶ computes the transpose of a given matrix
Parameters: mat (Matrix) – matrix to perform the operation on Returns: transposed matrix Return type: Matrix
-
linalg.
inv
(mat: linalg.types.Matrix) → linalg.types.Matrix¶ returns the inverse matrix of mat
Parameters: mat (Matrix) – the matrix to invert Returns: the inverse matrix of mat Return type: Matrix