The identity element acts like the identity over the rationals::
sage: set_random_seed()
- sage: x = random_eja().random_element()
+ sage: x = random_eja(field=QQ).random_element()
sage: A = x.subalgebra_generated_by()
sage: x = A.random_element()
sage: A.one()*x == x and x*A.one() == x
reals with an orthonormal basis::
sage: set_random_seed()
- sage: x = random_eja(AA).random_element()
+ sage: x = random_eja().random_element()
sage: A = x.subalgebra_generated_by(orthonormalize_basis=True)
sage: x = A.random_element()
sage: A.one()*x == x and x*A.one() == x
the rationals::
sage: set_random_seed()
- sage: x = random_eja().random_element()
+ sage: x = random_eja(field=QQ).random_element()
sage: A = x.subalgebra_generated_by()
sage: actual = A.one().operator().matrix()
sage: expected = matrix.identity(A.base_ring(), A.dimension())
the algebraic reals with an orthonormal basis::
sage: set_random_seed()
- sage: x = random_eja(AA).random_element()
+ sage: x = random_eja().random_element()
sage: A = x.subalgebra_generated_by(orthonormalize_basis=True)
sage: actual = A.one().operator().matrix()
sage: expected = matrix.identity(A.base_ring(), A.dimension())
return self.zero()
else:
sa_one = self.superalgebra().one().to_vector()
- sa_coords = self.vector_space().coordinate_vector(sa_one)
- return self.from_vector(sa_coords)
+ # The extra hackery is because foo.to_vector() might not
+ # live in foo.parent().vector_space()!
+ coords = sum( a*b for (a,b)
+ in zip(sa_one,
+ self.superalgebra().vector_space().basis()) )
+ return self.from_vector(self.vector_space().coordinate_vector(coords))
+