2. Profile (and fix?) any remaining slow operations.
-3. Every once in a long while, the test
-
- sage: set_random_seed()
- sage: x = random_eja().random_element()
- sage: x.is_invertible() == (x.det() != 0)
-
- in eja_element.py returns False. Example:
-
- sage: J1 = ComplexHermitianEJA(2)
- sage: J2 = TrivialEJA()
- sage: J = cartesian_product([J1,J2])
- sage: x = J.from_vector(vector(QQ, [-1, -1/2, -1/2, -1/2]))
- sage: x.is_invertible()
- True
- sage: x.det()
- 0
-
-4. When we take a Cartesian product involving a trivial algebra, we
+3. When we take a Cartesian product involving a trivial algebra, we
could easily cache the identity and charpoly coefficients using
the nontrivial factor. On the other hand, it's nice that we can
test out some alternate code paths...
# written out as "long vectors."
V = VectorSpace(field, degree)
- # The matrix that will hole the orthonormal -> unorthonormal
- # coordinate transformation.
- self._deortho_matrix = None
+ # The matrix that will hold the orthonormal -> unorthonormal
+ # coordinate transformation. Default to an identity matrix of
+ # the appropriate size to avoid special cases for None
+ # everywhere.
+ self._deortho_matrix = matrix.identity(field,n)
if orthonormalize:
# Save a copy of the un-orthonormalized basis for later.
a = ( a_i.change_ring(self.base_ring())
for a_i in self._rational_algebra._charpoly_coefficients() )
- if self._deortho_matrix is None:
- # This can happen if our base ring was, say, AA and we
- # chose not to (or didn't need to) orthonormalize. It's
- # still faster to do the computations over QQ even if
- # the numbers in the boxes stay the same.
- return tuple(a)
-
# Otherwise, convert the coordinate variables back to the
# deorthonormalized ones.
R = self.coordinate_polynomial_ring()
check_field=False,
check_axioms=False)
+ # Since we don't (re)orthonormalize the basis, the FDEJA
+ # constructor is going to set self._deortho_matrix to the
+ # identity matrix. Here we set it to the correct value using
+ # the deortho matrices from our factors.
+ self._deortho_matrix = matrix.block_diagonal( [J._deortho_matrix
+ for J in factors] )
+
self.rank.set_cache(sum(J.rank() for J in factors))
ones = tuple(J.one().to_matrix() for J in factors)
self.one.set_cache(self(ones))