X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=mjo%2Feja%2Feja_subalgebra.py;h=6a9d10f65b7164627394c5ddb32bd682c323c5b2;hb=af79c1d027cf737d125b11fd41bb0bc2150778fb;hp=85ada0705fe8073fa80500d4719c38a5ea16a576;hpb=09e103320c85de7be6846be6980642d37a5ca6a9;p=sage.d.git diff --git a/mjo/eja/eja_subalgebra.py b/mjo/eja/eja_subalgebra.py index 85ada07..6a9d10f 100644 --- a/mjo/eja/eja_subalgebra.py +++ b/mjo/eja/eja_subalgebra.py @@ -56,6 +56,14 @@ class FiniteDimensionalEuclideanJordanSubalgebraElement(FiniteDimensionalEuclide f1 sage: A(x).superalgebra_element() e0 + e1 + e2 + e3 + e4 + e5 + sage: y = sum(A.gens()) + sage: y + f0 + f1 + sage: B = y.subalgebra_generated_by() + sage: B(y) + g1 + sage: B(y).superalgebra_element() + f0 + f1 TESTS: @@ -70,10 +78,23 @@ class FiniteDimensionalEuclideanJordanSubalgebraElement(FiniteDimensionalEuclide sage: y = A.random_element() sage: A(y.superalgebra_element()) == y True + sage: B = y.subalgebra_generated_by() + sage: B(y).superalgebra_element() == y + True """ - return self.parent().superalgebra().linear_combination( - zip(self.parent()._superalgebra_basis, self.to_vector()) ) + # As with the _element_constructor_() method on the + # algebra... even in a subspace of a subspace, the basis + # elements belong to the ambient space. As a result, only one + # level of coordinate_vector() is needed, regardless of how + # deeply we're nested. + W = self.parent().vector_space() + V = self.parent().superalgebra().vector_space() + + # Multiply on the left because basis_matrix() is row-wise. + ambient_coords = self.to_vector()*W.basis_matrix() + V_coords = V.coordinate_vector(ambient_coords) + return self.parent().superalgebra().from_vector(V_coords) @@ -149,20 +170,20 @@ class FiniteDimensionalEuclideanJordanSubalgebra(FiniteDimensionalEuclideanJorda except ValueError: prefix = prefixen[0] - basis_vectors = [ b.to_vector() for b in basis ] - superalgebra_basis = [ self._superalgebra.from_vector(b) - for b in basis_vectors ] - # If our superalgebra is a subalgebra of something else, then # these vectors won't have the right coordinates for # V.span_of_basis() unless we use V.from_vector() on them. - W = V.span_of_basis( V.from_vector(v) for v in basis_vectors ) + W = V.span_of_basis( V.from_vector(b.to_vector()) for b in basis ) - n = len(superalgebra_basis) + n = len(basis) mult_table = [[W.zero() for i in range(n)] for j in range(n)] + ip_table = [ [ self._superalgebra.inner_product(basis[i],basis[j]) + for i in range(n) ] + for j in range(n) ] + for i in range(n): for j in range(n): - product = superalgebra_basis[i]*superalgebra_basis[j] + product = basis[i]*basis[j] # product.to_vector() might live in a vector subspace # if our parent algebra is already a subalgebra. We # use V.from_vector() to make it "the right size" in @@ -170,13 +191,11 @@ class FiniteDimensionalEuclideanJordanSubalgebra(FiniteDimensionalEuclideanJorda product_vector = V.from_vector(product.to_vector()) mult_table[i][j] = W.coordinate_vector(product_vector) - natural_basis = tuple( b.natural_representation() - for b in superalgebra_basis ) + self._inner_product_matrix = matrix(field, ip_table) + natural_basis = tuple( b.natural_representation() for b in basis ) self._vector_space = W - self._superalgebra_basis = superalgebra_basis - fdeja = super(FiniteDimensionalEuclideanJordanSubalgebra, self) fdeja.__init__(field, @@ -220,12 +239,20 @@ class FiniteDimensionalEuclideanJordanSubalgebra(FiniteDimensionalEuclideanJorda if elt not in self.superalgebra(): raise ValueError("not an element of this subalgebra") - # 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(elt.to_vector(), - self.superalgebra().vector_space().basis()) ) - return self.from_vector(self.vector_space().coordinate_vector(coords)) + # The extra hackery is because foo.to_vector() might not live + # in foo.parent().vector_space()! Subspaces of subspaces still + # have user bases in the ambient space, though, so only one + # level of coordinate_vector() is needed. In other words, if V + # is itself a subspace, the basis elements for W will be of + # the same length as the basis elements for V -- namely + # whatever the dimension of the ambient (parent of V?) space is. + V = self.superalgebra().vector_space() + W = self.vector_space() + + # Multiply on the left because basis_matrix() is row-wise. + ambient_coords = elt.to_vector()*V.basis_matrix() + W_coords = W.coordinate_vector(ambient_coords) + return self.from_vector(W_coords)