Dense Matrices over a general ring#

class sage.matrix.matrix_generic_dense.Matrix_generic_dense[source]#

Bases: Matrix_dense

The Matrix_generic_dense class derives from Matrix, and defines functionality for dense matrices over any base ring. Matrices are represented by a list of elements in the base ring, and element access operations are implemented in this class.

EXAMPLES:

sage: A = random_matrix(Integers(25)['x'], 2)
sage: type(A)
<class 'sage.matrix.matrix_generic_dense.Matrix_generic_dense'>
sage: TestSuite(A).run(skip='_test_minpoly')
>>> from sage.all import *
>>> A = random_matrix(Integers(Integer(25))['x'], Integer(2))
>>> type(A)
<class 'sage.matrix.matrix_generic_dense.Matrix_generic_dense'>
>>> TestSuite(A).run(skip='_test_minpoly')

Test comparisons:

sage: A = random_matrix(Integers(25)['x'], 2)
sage: A == A
True
sage: A < A + 1 or A[0, 0].coefficients()[0] == 24
True
sage: A+1 < A and A[0, 0].coefficients()[0] != 24
False
>>> from sage.all import *
>>> A = random_matrix(Integers(Integer(25))['x'], Integer(2))
>>> A == A
True
>>> A < A + Integer(1) or A[Integer(0), Integer(0)].coefficients()[Integer(0)] == Integer(24)
True
>>> A+Integer(1) < A and A[Integer(0), Integer(0)].coefficients()[Integer(0)] != Integer(24)
False

Test hashing:

sage: A = random_matrix(Integers(25)['x'], 2)
sage: hash(A)
Traceback (most recent call last):
...
TypeError: mutable matrices are unhashable
sage: A.set_immutable()
sage: H = hash(A)
>>> from sage.all import *
>>> A = random_matrix(Integers(Integer(25))['x'], Integer(2))
>>> hash(A)
Traceback (most recent call last):
...
TypeError: mutable matrices are unhashable
>>> A.set_immutable()
>>> H = hash(A)