the usual one. Then for the basis to be orthonormal, we would need
to divide e.g. (1,0,0) by <(1,0,0),(1,0,0)> = 2 to normalize it.
-8. Use charpoly for inverse itself?
+8. Pre-cache charpoly for some small algebras?
-9. Pre-cache charpoly for some small algebras?
-
-10. Compute the scalar in the general natural_inner_product() for
- matrices, so no overrides are necessary.
\ No newline at end of file
+9. Compute the scalar in the general natural_inner_product() for
+ matrices, so no overrides are necessary.
\ No newline at end of file
if not self.is_invertible():
raise ValueError("element is not invertible")
+ if self.parent()._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!
+ r = self.parent().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 (~self.quadratic_representation())(self)