- def __init__(self, J1, J2, **kwargs):
- if J1.base_ring() != J2.base_ring():
- raise ValueError("algebras must share the same base field")
- field = J1.base_ring()
-
- self._factors = (J1, J2)
- n1 = J1.dimension()
- n2 = J2.dimension()
- n = n1+n2
- V = VectorSpace(field, n)
- mult_table = [ [ V.zero() for j in range(i+1) ]
- for i in range(n) ]
- for i in range(n1):
- for j in range(i+1):
- p = (J1.monomial(i)*J1.monomial(j)).to_vector()
- mult_table[i][j] = V(p.list() + [field.zero()]*n2)
+ def __init__(self, modules, **kwargs):
+ CombinatorialFreeModule_CartesianProduct.__init__(self,
+ modules,
+ **kwargs)
+ field = modules[0].base_ring()
+ if not all( J.base_ring() == field for J in modules ):
+ raise ValueError("all factors must share the same base field")
+
+ basis = tuple( b.to_vector().column() for b in self.basis() )
+
+ # Define jordan/inner products that operate on the basis.
+ def jordan_product(x_mat,y_mat):
+ x = self.from_vector(_mat2vec(x_mat))
+ y = self.from_vector(_mat2vec(y_mat))
+ return self.cartesian_jordan_product(x,y).to_vector().column()
+
+ def inner_product(x_mat, y_mat):
+ x = self.from_vector(_mat2vec(x_mat))
+ y = self.from_vector(_mat2vec(y_mat))
+ return self.cartesian_inner_product(x,y)
+
+ # Use whatever category the superclass came up with. Usually
+ # some join of the EJA and Cartesian product
+ # categories. There's no need to check the field since it
+ # already came from an EJA. Likewise the axioms are guaranteed
+ # to be satisfied. We can't orthonormalize by default because
+ # there's no way to pass "orthonormalize=False" to
+ # cartesian_product(...) when the base ring is QQ and
+ # orthonormalizing would give us irrational entries.
+ #
+ # TODO: create a separate constructor that is capable of
+ # orthonormalizing and is only used by the cartesian_product()
+ # thingy.
+ FiniteDimensionalEJA.__init__(self,
+ basis,
+ jordan_product,
+ inner_product,
+ field=field,
+ orthonormalize=False,
+ check_field=False,
+ check_axioms=False,
+ category=self.category())
+ # TODO:
+ #
+ # Initialize the FDEJA class, too. Does this override the
+ # initialization that we did for the
+ # CombinatorialFreeModule_CartesianProduct class? If not, we
+ # will probably have to duplicate some of the work (i.e. one
+ # of the constructors). Since the CartesianProduct one is
+ # smaller, that makes the most sense to copy/paste if it comes
+ # down to that.
+ #