-
-
Notifications
You must be signed in to change notification settings - Fork 688
Description
Matrices inherit from RingElement even if they are not square. Their parents do behave correctly.
sage: A = Matrix([[1, 2], [3, 4]])
sage: A.parent() in Rings()
True
sage: A.parent() in Modules(ZZ)
True
sage: isinstance(A, RingElement)
True
sage: B = Matrix([[1, 2, 3], [4, 5, 6]])
sage: B.parent() in Rings()
False
sage: A.parent() in Modules(ZZ)
True
sage: isinstance(B, RingElement)
True
The same happens with Algebras(ZZ) and AlgebraElement.
Square matrices over a ring R should be made to inherit dynamically from AlgebraElement; non-square matrices should only inherit from ModuleElement.
Motivation: Multiplication of matrices over a commutative ring R is in general only a bilinear map between R-modules (in general three different ones). Only if the matrices are square of the same size n can this be described as the multiplication map on an R-algebra, namely Matn(R).
This is a duplicate of #804.
CC: @robertwb
Component: categories
Keywords: inheritance
Reviewer: Travis Scrimshaw
Issue created by migration from https://trac.sagemath.org/ticket/15215