Matrix Library Documentation¶
- class app.lib.Matrix(*args)¶
Python matrix representation
- A(row_i, row_j, scalar)¶
Adds to the elements of the row_j’th row the scalar * the corresponding elements of the row_i’th row.
- M(row, scalar)¶
Multiply every element of the row’th row by nonzero scalar
- P(row_i, row_j)¶
Permutes the row_i’th and row_j’th rows in self.matrix in place
- augment(other)¶
Augments other to self. First checks if number of rows are equal eg: if self = 1 2 and other = 5
3 4 5- self.augment(other) returns 1 2 5
- 3 4 5
- change_element(row, column, new_element)¶
Changes the element in the specified row and the specified column to new_element.
- static dot_product(t1, t2)¶
Returns the dot product of two input lists
- static expanded_dot_product(t1, t2)¶
Returns the expanded dot product of two input lists as a string
- static first_nonzero(t)¶
Takes an input list and return the first nonzero element
- static identity_matrix(n)¶
Returns n x n identity matrix
- linear_equation_print()¶
Prints the matrix as a system of linear equations. Assumes that an augmented matrix is given and so the last column is the system constants while the rest of the matrix are the system coefficients.
- static matrix_check(t)¶
Checks whether an input list can be turned into a matrix object
- multiply_check(other)¶
Checks whether the middle dimensions are the same to do matrix multiplication.
- multiply_expanded(other)¶
Matrix multiplication that shows expanded dot product. First checks dimensions to see if multiplication is possible for regular matrix multiplication. Accepted formats:
foo = Matrix(2, 2) bar = Matrix(2, 2, 5) print foo * bar <-> returns a matrix of the form Matrix(2,2,0)
- static one_position(row, row_num)¶
Returns the position of the first one or an appropriate value if the row is all zeroes. The goal is that the positions of a row echelon matrix will be in increasing order.
- row_echelon_check()¶
Checks if a matrix is in row echelon form
- same_dimensions_check(other)¶
First makes sure both matrices are valid. Then makes sure the dimensions are the same for both.
- skew_symmetric_check()¶
Checks if a matrix is skew symmetric (anti-symmetric). eg: transpose(A) = -A
- static space_length(t)¶
Takes in matrix as input (eg:self.matrix) and returns length of longest element. For use in printing matrices with correct spacing.
- symmetric_check()¶
Checks if a matrix is symmetric. eg: transpose(A) = A
- transpose()¶
Returns the transpose of the matrix
- valid_check()¶
Checks whether a matrix is valid. Eg: Checks whether the dimensions of self.matrix actually
correspond to self.rows and self.columns
- vector_equation_print()¶
Prints the matrix as a system of linear equations. Assumes that an augmented matrix is given and so the last column is the system constants while the rest of the matrix are the system coefficients.