Dense Matrices over a general ring

class sage.matrix.matrix_generic_dense.Matrix_generic_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); A
[    x^2 + 12*x + 2   4*x^2 + 13*x + 8]
[ 22*x^2 + 2*x + 17 19*x^2 + 22*x + 14]
sage: type(A)
<type 'sage.matrix.matrix_generic_dense.Matrix_generic_dense'>
sage: A == loads(dumps(A))
True
__copy__()

Creates a copy of self, which may be changed without altering self.

EXAMPLES:

sage: A = matrix(ZZ[['t']], 2,3,range(6)); A
[0 1 2]
[3 4 5]
sage: A.subdivide(1,1); A
[0|1 2]
[-+---]
[3|4 5]
sage: B = A.copy(); B
[0|1 2]
[-+---]
[3|4 5]
sage: B == A
True
sage: B[0,0] = 100
sage: B
[100|  1   2]
[---+-------]
[  3|  4   5]
sage: A
[0|1 2]
[-+---]
[3|4 5]
__deepcopy__()
EXAMPLES:
sage: R.<x> = QQ[] sage: A = matrix(R, 2, [1,2,x,x^2]) sage: B = A.__deepcopy__() sage: A[0,0]._unsafe_mutate(1,2/3) sage: A [2/3*x + 1 2] [ x x^2] sage: B [ 1 2] [ x x^2]
__eq__()
x.__eq__(y) <==> x==y
__ge__()
x.__ge__(y) <==> x>=y
__gt__()
x.__gt__(y) <==> x>y
__hash__()
x.__hash__() <==> hash(x)
__init__()
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
__le__()
x.__le__(y) <==> x<=y
__lt__()
x.__lt__(y) <==> x<y
__ne__()
x.__ne__(y) <==> x!=y
static __new__()
T.__new__(S, ...) -> a new object with type S, a subtype of T
_list()

Return reference to list of entries of self. For internal use only, since this circumvents immutability.

EXAMPLES:
sage: A = random_matrix(Integers(25)[‘x’],2); A.set_immutable() sage: A._list()[0] = 0 sage: A._list()[0] 0
_multiply_classical()

Multiply the matrices left and right using the classical O(n^3) algorithm.

EXAMPLES: We multiply two matrices over a fairly general ring::

sage: R.<x,y> = Integers(8)[‘x,y’] sage: a = matrix(R,2,[x,y,x^2,y^2]); a [ x y] [x^2 y^2] sage: type(a) <type ‘sage.matrix.matrix_generic_dense.Matrix_generic_dense’> sage: a*a [ x^2*y + x^2 y^3 + x*y] [x^2*y^2 + x^3 y^4 + x^2*y] sage: a.det()^2 == (a*a).det() True sage: a._multiply_classical(a) [ x^2*y + x^2 y^3 + x*y] [x^2*y^2 + x^3 y^4 + x^2*y]

sage: A = matrix(QQ[‘x,y’], 2, [0,-1,2,-2]) sage: B = matrix(QQ[‘x,y’], 2, [-1,-1,-2,-2]) sage: A*B [2 2] [2 2]

Sage fully supports degenerate matrices with 0 rows or 0 columns:

sage: A = matrix(QQ['x,y'], 0, 4, []); A
[]
sage: B = matrix(QQ['x,y'], 4,0, []); B
[]
sage: A*B
[]
sage: B*A
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
_pickle()
EXAMPLES:
sage: R.<x> = Integers(25)[‘x’]; A = matrix(R, [1,x,x^3+1,2*x]) sage: A._pickle() ([1, x, x^3 + 1, 2*x], 0)
_unpickle()
EXAMPLES:
sage: R.<x> = Integers(25)[‘x’]; A = matrix(R, [1,x,x^3+1,2*x]); B = A.parent()(0) sage: v = A._pickle() sage: B._unpickle(v[0], v[1]) sage: B [ 1 x x^3 + 1 2*x]
sage.matrix.matrix_generic_dense._convert_dense_entries_to_list()

Create list of entries that define a matrix from a list of vectors.

EXAMPLES:
sage: entries = [vector([1,2,3]), vector([4,5,6])] sage: sage.matrix.matrix_generic_dense._convert_dense_entries_to_list(entries) [1, 2, 3, 4, 5, 6]

Previous topic

Base class for sparse matrices

Next topic

Sparse Matrices over a general ring

This Page