# points.matrices¶

Contains the Matrix class.

class points.matrices.Matrix(*rows, columns=False)[source]

A Matrix is a rectangular array of numbers. They are created from iterables, which will be interpeted as rows unless specified otherwise.

They can be added and subtracted from each other, and multiplied by a scalar using the * operator. To multiply a Matrix with another Matrix, use @.

Parameters: args (iter) – The rows of the Matrix. Each row must be iterable. ValueError – if you create an empty matrix. TypeError – if you mix Vectors with other iterables. TypeError – if you give non iterables. ValueError – if you give rows of different lengths.
static identity()[source]

Creates an identity matrix.

Parameters: dimensions (int) – the size of the identity matrix to create. TypeError – if non-integer dimension is given. Matrix
width()[source]

Returns the Matrix width - how many columns it has.

Return type: int
height()[source]

Returns the Matrix height - how many rows it has.

Return type: int
size()[source]

Returns the dimensions of the Matrix.

Return type: tuple
rows()[source]

Returns the rows of the Matrix.

Return type: tuple
columns()[source]

Returns the rows of the Matrix.

Return type: tuple
is_square()[source]

Checks if the number of rows equals the number of columns.

Return type: bool
transposed()[source]

Returns a transposed version of the matrix. The matrix calling the method is unaffected.

Return type: Matrix
minor(i, j)[source]

Returns the first minor of the value at the position specified.

Parameters: i (int) – The row to use. j (int) – The column to use. ValueError – if a non-square matrix is given. float
cofactor(i, j)[source]

Returns the cofactor of the value at the position specified.

Parameters: i (int) – The row to use. j (int) – The column to use. ValueError – if a non-square matrix is given. float
minors()[source]

Returns the matrix of minors for this matrix.

Raises: ValueError – if a non-square matrix is given. Matrix
cofactors()[source]

Returns the matrix of cofactors for this matrix.

Raises: ValueError – if a non-square matrix is given. Matrix
determinant()[source]

Returns the determinant of the matrix - the matrix must be square for this to happen.

The Laplace expansion is used to calculate matrices of three dimensions and above.

Raises: ValueError – if a non-square matrix is given. float
adjoint()[source]

Returns the adjoint matrix of this matrix.

Raises: ValueError – if a non-square matrix is given. Matrix
inverse()[source]

Returns the inverse matrix of this matrix.

Raises: ValueError – if the matrix is not invertible. Matrix
column_space()[source]

Returns the column space of matrix - the set of vectors reachable by its column vectors.

Return type: VectorSpan
rank()[source]

The dimensions of the matrix’s column space.

Return type: int
is_full_rank()[source]

Checks if the matrix is full rank - that is, whether its rank equals the number of dimensions of its column space.

Return type: bool
gauss()[source]

Performs Gaussian elimination on the matrix, changing it in place, and putting it into row echelon form (not reduced row echelon form).

This is useful in solving systems of linear equations.

is_row_echelon()[source]

Checks to see if the matrix is in row echelon form.

Return type: bool
is_reduced_row_echelon()[source]

Checks to see if the matrix is in reduced row echelon form.

Return type: bool