This module provides various matrix functions to facilitate matrix operations, including creation, manipulation, and advanced computations.
This module allows you to create matrices using 2D arrays (lists in Python) and perform complex operations such as calculating determinants, inverses, and matrix arithmetic. It aims to save time and provide consistency in matrix operations.
Initializes the matrix with dimensions r x c, with all elements set to 0.
Example:
obj = Matrix(3, 3)Returns the matrix as a 2-D list.
Example:
lst99 = obj.list()Allows user input to modify the matrix elements.
Example:
obj.inputAdd()Converts a list into a matrix (self.matrix).
Example:
obj.listTomatrix([1, 2, 3, 4, 5, 6, 7, 8, 9])Prints the matrix using the Tabulate module.
Example:
obj.printMatrix()Returns the transpose of the matrix.
Returns:
Matrix
Example:
obj2 = obj.transpose()Returns the dimensions of the matrix.
Returns:
Tuple
Example:
tuple1 = obj.sizeMatrix()Multiplies the current matrix with another matrix m2.
Returns:
Matrix
Example:
obj3 = obj.matrixMultiplication(obj2)Adds the current matrix to another matrix m2.
Returns:
Matrix
Example:
obj4 = obj.matrixAddition(obj2)Subtracts matrix m2 from the current matrix.
Returns:
Matrix
Example:
obj4 = obj.matrixSubtraction(obj2)Multiplies the matrix by a constant c.
Example:
obj.matrixMultiplicationConstant(5)Returns the adjoint of the matrix.
Returns:
Matrix
Example:
obj5 = obj.adj()Returns the inverse of the matrix.
Returns:
Matrix
Example:
obj6 = obj.inverse()Returns the mean of all elements in the matrix.
Returns:
Float
Example:
float1 = obj.mean()Returns the mean of each row in the matrix.
Returns:
Matrix
Example:
obj7 = obj.rowMeans()Returns the mean of each column in the matrix.
Returns:
Matrix
Example:
obj8 = obj.colMeans()Returns the sum of each row in the matrix.
Returns:
Matrix
Example:
obj9 = obj.rowSum()Returns the sum of each column in the matrix.
Returns:
Matrix
Example:
obj10 = obj.colSum()Returns the sum of all elements in the matrix.
Returns:
FloatorInt
Example:
var = obj.sum()Divides the current matrix by the inverse of another matrix m2.
Returns:
Matrix
Example:
obj11 = obj.matrixDivision(obj2)Returns a diagonal matrix if m1 is a list, or a list of diagonal elements if m1 is a matrix.
Returns:
MatrixorList
Example:
list1 = diag(obj) # if obj is a Matrix
obj12 = diag([1, 2, 3, 4, 5, 6]) # if [1, 2, 3, 4, 5, 6] is a listReturns an identity matrix.
Example:
obj13 = identity(obj)Returns the determinant of an N x N matrix.
Returns:
FloatorInt
Example:
det12 = determinant(obj)- Instagram: prak_entech983
- YouTube: Prak EnTech