X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=mjo%2Feja%2Feja_element.py;h=4c9993a2cae68c8064a087c344ef2a5bf23877c5;hb=d6f51df5e37b30956849e01b70c4aede00f3434e;hp=c2f2b7c12ff92dbc0a57036057afad55acd63ddd;hpb=a4f0908c2216ff989161d33873102805d1c6aabd;p=sage.d.git diff --git a/mjo/eja/eja_element.py b/mjo/eja/eja_element.py index c2f2b7c..4c9993a 100644 --- a/mjo/eja/eja_element.py +++ b/mjo/eja/eja_element.py @@ -1117,6 +1117,7 @@ class FiniteDimensionalEJAElement(IndexedFreeModuleElement): return W.linear_combination( zip(B, self.to_vector()) ) + def norm(self): """ The norm of this element with respect to :meth:`inner_product`. @@ -1618,3 +1619,38 @@ class FiniteDimensionalEJAElement(IndexedFreeModuleElement): """ return self.trace_inner_product(self).sqrt() + + + +class CartesianProductEJAElement(FiniteDimensionalEJAElement): + + def to_matrix(self): + r""" + SETUP:: + + sage: from mjo.eja.eja_algebra import (HadamardEJA, + ....: RealSymmetricEJA) + + EXAMPLES:: + + sage: J1 = HadamardEJA(1) + sage: J2 = RealSymmetricEJA(2) + sage: J = cartesian_product([J1,J2]) + sage: x = sum(J.gens()) + sage: x.to_matrix()[0] + [1] + sage: x.to_matrix()[1] + [ 1 0.7071067811865475?] + [0.7071067811865475? 1] + + """ + B = self.parent().matrix_basis() + W = self.parent().matrix_space() + + # Aaaaand linear combinations don't work in Cartesian + # product spaces, even though they provide a method + # with that name. + pairs = zip(B, self.to_vector()) + return sum( ( W(tuple(alpha*b_i for b_i in b)) + for (b,alpha) in pairs ), + W.zero())