Matrix

Matrix()

A matrix with rational polynomial coefficients.

Methods

Name Description
augment Solve A * x = b for x, where A is the current matrix.
content Get the content of the matrix, i.e. the gcd of all entries.
det Return the determinant of the matrix.
eye Create a new matrix with the scalars diag on the main diagonal and zeroes elsewhere.
format Convert the matrix into a human-readable string, with tunable settings.
from_linear Create a new row vector from a list of scalars.
from_nested Create a new matrix from a 2-dimensional vector of scalars.
identity Create a new square matrix with nrows rows and ones on the main diagonal and zeroes elsewhere.
inv Return the inverse of the matrix, if it exists.
is_diagonal Return true iff every non- main diagonal entry in the matrix is zero.
is_zero Return true iff every entry in the matrix is zero.
map Apply a function f to every entry of the matrix.
ncols Return the number of columns.
nrows Return the number of rows.
primitive_part Construct the same matrix, but with the content removed.
row_reduce Augment the matrix with another matrix, e.g. create [A B] from matrix A and B.
solve Solve A * x = b for x, where A is the current matrix.
solve_any Solve A * x = b for x, where A is the current matrix and return any solution if the
split_col Solve A * x = b for x, where A is the current matrix.
to_latex Convert the matrix into a LaTeX string.
transpose Return the transpose of the matrix.
vec Create a new column vector from a list of scalars.

augment

Matrix.augment(b)

Solve A * x = b for x, where A is the current matrix.

content

Matrix.content()

Get the content of the matrix, i.e. the gcd of all entries.

det

Matrix.det()

Return the determinant of the matrix.

eye

Matrix.eye(diag)

Create a new matrix with the scalars diag on the main diagonal and zeroes elsewhere.

format

Matrix.format(
    mode=Ellipsis,
    pretty_matrix=True,
    number_thousands_separator=None,
    multiplication_operator='*',
    double_star_for_exponentiation=False,
    square_brackets_for_function=False,
    num_exp_as_superscript=True,
    precision=None,
    show_namespaces=False,
    include_attributes=False,
    max_terms=None,
    custom_print_mode=None,
)

Convert the matrix into a human-readable string, with tunable settings.

from_linear

Matrix.from_linear(nrows, ncols, entries)

Create a new row vector from a list of scalars.

from_nested

Matrix.from_nested(entries)

Create a new matrix from a 2-dimensional vector of scalars.

identity

Matrix.identity(nrows)

Create a new square matrix with nrows rows and ones on the main diagonal and zeroes elsewhere.

inv

Matrix.inv()

Return the inverse of the matrix, if it exists.

is_diagonal

Matrix.is_diagonal()

Return true iff every non- main diagonal entry in the matrix is zero.

is_zero

Matrix.is_zero()

Return true iff every entry in the matrix is zero.

map

Matrix.map(f)

Apply a function f to every entry of the matrix.

ncols

Matrix.ncols()

Return the number of columns.

nrows

Matrix.nrows()

Return the number of rows.

primitive_part

Matrix.primitive_part()

Construct the same matrix, but with the content removed.

row_reduce

Matrix.row_reduce(max_col)

Augment the matrix with another matrix, e.g. create [A B] from matrix A and B.

Returns an error when the matrices do not have the same number of rows.

solve

Matrix.solve(b)

Solve A * x = b for x, where A is the current matrix.

solve_any

Matrix.solve_any(b)

Solve A * x = b for x, where A is the current matrix and return any solution if the system is underdetermined.

split_col

Matrix.split_col(index)

Solve A * x = b for x, where A is the current matrix.

to_latex

Matrix.to_latex()

Convert the matrix into a LaTeX string.

transpose

Matrix.transpose()

Return the transpose of the matrix.

vec

Matrix.vec(entries)

Create a new column vector from a list of scalars.