Ensure that the determinant is multiplicative on an associative
subalgebra as in Faraut and Korányi's Proposition II.2.2::
- sage: J = random_eja().random_element().subalgebra_generated_by()
+ sage: x0 = random_eja().random_element()
+ sage: J = x0.subalgebra_generated_by(orthonormalize=False)
sage: x,y = J.random_elements(2)
sage: (x*y).det() == x.det()*y.det()
True
of an element is the inverse of its left-multiplication operator
applied to the algebra's identity, when that inverse exists::
- sage: J = random_eja()
- sage: x = J.random_element()
- sage: (not x.operator().is_invertible()) or (
- ....: x.operator().inverse()(J.one()) == x.inverse() )
+ sage: J = random_eja() # long time
+ sage: x = J.random_element() # long time
+ sage: (not x.operator().is_invertible()) or ( # long time
+ ....: x.operator().inverse()(J.one()) # long time
+ ....: == # long time
+ ....: x.inverse() ) # long time
True
Check that the fast (cached) and slow algorithms give the same
True
"""
not_invertible_msg = "element is not invertible"
- if self.parent()._charpoly_coefficients.is_in_cache():
+
+ algebra = self.parent()
+ if algebra._charpoly_coefficients.is_in_cache():
# We can invert using our charpoly if it will be fast to
# compute. If the coefficients are cached, our rank had
# better be too!
if self.det().is_zero():
raise ZeroDivisionError(not_invertible_msg)
- r = self.parent().rank()
+ r = algebra.rank()
a = self.characteristic_polynomial().coefficients(sparse=False)
- return (-1)**(r+1)*sum(a[i+1]*self**i for i in range(r))/self.det()
+ return (-1)**(r+1)*algebra.sum(a[i+1]*self**i
+ for i in range(r))/self.det()
try:
inv = (~self.quadratic_representation())(self)
The minimal polynomial should always kill its element::
- sage: x = random_eja().random_element()
- sage: p = x.minimal_polynomial()
- sage: x.apply_univariate_polynomial(p)
+ sage: x = random_eja().random_element() # long time
+ sage: p = x.minimal_polynomial() # long time
+ sage: x.apply_univariate_polynomial(p) # long time
0
The minimal polynomial is invariant under a change of basis,
This subalgebra, being composed of only powers, is associative::
sage: x0 = random_eja().random_element()
- sage: A = x0.subalgebra_generated_by()
+ sage: A = x0.subalgebra_generated_by(orthonormalize=False)
sage: x,y,z = A.random_elements(3)
sage: (x*y)*z == x*(y*z)
True
the superalgebra::
sage: x = random_eja().random_element()
- sage: A = x.subalgebra_generated_by()
+ sage: A = x.subalgebra_generated_by(orthonormalize=False)
sage: A(x^2) == A(x)*A(x)
True