# long run to have the multiplication table be in terms of
# algebra elements. We do this after calling the superclass
# constructor so that from_vector() knows what to do.
- self._multiplication_table = [
- list(map(lambda x: self.from_vector(x), ls))
- for ls in mult_table
- ]
+ self._multiplication_table = [ [ self.vector_space().zero()
+ for i in range(n) ]
+ for j in range(n) ]
+ # take advantage of symmetry
+ for i in range(n):
+ for j in range(i+1):
+ elt = self.from_vector(mult_table[i][j])
+ self._multiplication_table[i][j] = elt
+ self._multiplication_table[j][i] = elt
if check_axioms:
if not self._is_commutative():
Ensure that computing the rank actually works, since the ranks
of all simple algebras are known and will be cached by default::
- sage: J = HadamardEJA(4)
- sage: J.rank.clear_cache()
- sage: J.rank()
- 4
-
- ::
-
- sage: J = JordanSpinEJA(4)
- sage: J.rank.clear_cache()
- sage: J.rank()
- 2
-
- ::
-
- sage: J = RealSymmetricEJA(3)
- sage: J.rank.clear_cache()
- sage: J.rank()
- 3
-
- ::
-
- sage: J = ComplexHermitianEJA(2)
- sage: J.rank.clear_cache()
- sage: J.rank()
- 2
-
- ::
+ sage: set_random_seed() # long time
+ sage: J = random_eja() # long time
+ sage: caches = J.rank() # long time
+ sage: J.rank.clear_cache() # long time
+ sage: J.rank() == cached # long time
+ True
- sage: J = QuaternionHermitianEJA(2)
- sage: J.rank.clear_cache()
- sage: J.rank()
- 2
"""
return len(self._charpoly_coefficients())
return superclass._charpoly_coefficients()
mult_table = tuple(
- map(lambda x: x.to_vector(), ls)
+ tuple(map(lambda x: x.to_vector(), ls))
for ls in self._multiplication_table
)