- V = self.span_of_powers()
- assoc_subalg = self.subalgebra_generated_by()
- # Mis-design warning: the basis used for span_of_powers()
- # and subalgebra_generated_by() must be the same, and in
- # the same order!
- subalg_self = assoc_subalg(V.coordinates(self.vector()))
- # Recursive call, but should work since the subalgebra is
- # associative.
- return subalg_self.minimal_polynomial()
+ if self.parent().is_associative():
+ elt = FiniteDimensionalAlgebraElement(self.parent(), self)
+ else:
+ V = self.span_of_powers()
+ assoc_subalg = self.subalgebra_generated_by()
+ # Mis-design warning: the basis used for span_of_powers()
+ # and subalgebra_generated_by() must be the same, and in
+ # the same order!
+ elt = assoc_subalg(V.coordinates(self.vector()))
+
+ # Recursive call, but should work since elt lives in an
+ # associative algebra.
+ return elt.minimal_polynomial()