Matrices and Spaces of Matrices#
Sage provides native support for working with matrices over any
commutative or noncommutative ring. The parent object for a matrix
is a matrix space MatrixSpace(R, n, m)
of all
\(n\times
m\) matrices over a ring \(R\).
To create a matrix, either use the matrix(...)
function or create a matrix space using the
MatrixSpace
command and coerce an object into it.
Matrices also act on row vectors, which you create using the
vector(...)
command or by making a
VectorSpace
and coercing lists into it. The natural
action of matrices on row vectors is from the right. Sage currently
does not have a column vector class (on which matrices would act
from the left), but this is planned.
In addition to native Sage matrices, Sage also includes the following additional ways to compute with matrices:
Several math software systems included with Sage have their own native matrix support, which can be used from Sage. E.g., PARI, GAP, Maxima, and Singular all have a notion of matrices.
The GSL C-library is included with Sage, and can be used via Cython.
The
scipy
module provides support for sparse numerical linear algebra, among many other things.The
numpy
module, which you load by typingimport numpy
is included standard with Sage. It contains a very sophisticated and well developed array class, plus optimized support for numerical linear algebra. Sage’s matrices over RDF and CDF (native floating-point real and complex numbers) use numpy.
Finally, this module contains some data-structures for matrix-like objects like operation tables (e.g. the multiplication table of a group).
- Matrix Spaces
- General matrix Constructor and display options
- Constructors for special matrices
block_diagonal_matrix()
block_matrix()
circulant()
column_matrix()
companion_matrix()
diagonal_matrix()
elementary_matrix()
hankel()
hilbert()
identity_matrix()
ith_to_zero_rotation_matrix()
jordan_block()
lehmer()
matrix_method()
ones_matrix()
random_diagonalizable_matrix()
random_echelonizable_matrix()
random_matrix()
random_rref_matrix()
random_subspaces_matrix()
random_unimodular_matrix()
toeplitz()
vandermonde()
vector_on_axis_rotation_matrix()
zero_matrix()
- Helpers for creating matrices
- Matrices over an arbitrary ring
- Base class for matrices, part 0
- Base class for matrices, part 1
- Base class for matrices, part 2
- Generic Asymptotically Fast Strassen Algorithms
- Minimal Polynomials of Linear Recurrence Sequences
- Base class for dense matrices
- Base class for sparse matrices
- Dense Matrices over a general ring
- Sparse Matrices over a general ring
- Dense matrices over the integer ring
- Sparse integer matrices
- Modular algorithm to compute Hermite normal forms of integer matrices
add_column()
add_column_fallback()
add_row()
benchmark_hnf()
benchmark_magma_hnf()
det_from_modp_and_divisor()
det_given_divisor()
det_padic()
double_det()
extract_ones_data()
hnf()
hnf_square()
hnf_with_transformation()
hnf_with_transformation_tests()
interleave_matrices()
is_in_hnf_form()
max_det_prime()
ones()
pad_zeros()
pivots_of_hnf_matrix()
probable_hnf()
probable_pivot_columns()
probable_pivot_rows()
sanity_checks()
solve_system_with_difficult_last_row()
- Saturation over ZZ
- Dense matrices over the rational field
- Sparse rational matrices
- Dense matrices using a NumPy backend
- Dense matrices over the Real Double Field using NumPy
- Dense matrices over GF(2) using the M4RI library
- Dense matrices over \(\GF{2^e}\) for \(2 \leq e \leq 16\) using the M4RIE library
- Dense matrices over \(\ZZ/n\ZZ\) for \(n < 2^{23}\) using LinBox’s
Modular<double>
- Dense matrices over \(\ZZ/n\ZZ\) for \(n < 2^{11}\) using LinBox’s
Modular<float>
- Sparse matrices over \(\ZZ/n\ZZ\) for \(n\) small
- Symbolic matrices
- Dense matrices over the Complex Double Field using NumPy
- Arbitrary precision complex ball matrices using Arb
- Dense matrices over univariate polynomials over fields
- Dense matrices over multivariate polynomials over fields
- Matrices over Cyclotomic Fields
- Operation Tables
- Actions used by the coercion model for matrix and vector multiplications
- Functions for changing the base ring of matrices quickly
- Echelon matrices over finite fields.
- Miscellaneous matrix functions
- Matrix windows
- Misc matrix algorithms
- Calculate symplectic bases for matrices over fields and the integers.
- \(J\)-ideals of matrices
- Benchmarks for matrices
MatrixVector_QQ()
charpoly_GF()
charpoly_ZZ()
det_GF()
det_QQ()
det_ZZ()
det_hilbert_QQ()
echelon_QQ()
hilbert_matrix()
inverse_QQ()
invert_hilbert_QQ()
matrix_add_GF()
matrix_add_ZZ()
matrix_add_ZZ_2()
matrix_multiply_GF()
matrix_multiply_QQ()
matrix_multiply_ZZ()
nullspace_GF()
nullspace_RDF()
nullspace_RR()
nullspace_ZZ()
rank2_GF()
rank2_ZZ()
rank_GF()
rank_ZZ()
report()
report_GF()
report_ZZ()
smithform_ZZ()
vecmat_ZZ()