Matrix
Matrix()
A matrix with rational polynomial coefficients.
Methods
Name | Description |
---|---|
augment | Augment the matrix with another matrix, e.g. create [A B] from matrix A and B . |
content | Get the content, i.e., the GCD of the coefficients. |
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 matrix from a 1-dimensional vector 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 | Get the number of columns in the matrix. |
nrows | Get the number of rows in the matrix. |
primitive_part | Construct the same matrix, but with the content removed. |
row_reduce | Row-reduce the first max_col columns of the matrix in-place using Gaussian elimination and return the rank. |
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 | Split the matrix into two matrices at column col . |
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)
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.
content
Matrix.content()
Get the content, i.e., the GCD of the coefficients.
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
format(
Matrix.=True,
pretty_matrix=None,
number_thousands_separator='*',
multiplication_operator=False,
double_star_for_exponentiation=False,
square_brackets_for_function=True,
num_exp_as_superscript=False,
latex=None,
precision )
Convert the matrix into a human-readable string, with tunable settings.
from_linear
Matrix.from_linear(nrows, ncols, entries)
Create a new matrix from a 1-dimensional vector 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
map(f) Matrix.
Apply a function f
to every entry of the matrix.
ncols
Matrix.ncols()
Get the number of columns in the matrix.
nrows
Matrix.nrows()
Get the number of rows in the matrix.
primitive_part
Matrix.primitive_part()
Construct the same matrix, but with the content removed.
row_reduce
Matrix.row_reduce(max_col)
Row-reduce the first max_col
columns of the matrix in-place using Gaussian elimination and return the rank.
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(col)
Split the matrix into two matrices at column col
.
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.