From: Michael Orlitzky Date: Wed, 24 Feb 2021 02:24:56 +0000 (-0500) Subject: eja: simplify to_matrix() for elements. X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=028e405e8fd8672d0a68d21118305586a34927ad;p=sage.d.git eja: simplify to_matrix() for elements. --- diff --git a/mjo/eja/eja_element.py b/mjo/eja/eja_element.py index 7388e96..347aa3c 100644 --- a/mjo/eja/eja_element.py +++ b/mjo/eja/eja_element.py @@ -1651,8 +1651,7 @@ class CartesianProductEJAElement(FiniteDimensionalEJAElement): # product spaces, even though they provide a method # with that name. pairs = zip(B, self.to_vector()) - sigma = W.zero() - for (b,alpha) in pairs: - # sum(...) ALSO doesn't work on Cartesian products. - sigma += W(tuple(alpha*b_i for b_i in b)) - return sigma + return sum( ( W(tuple(alpha*b_i for b_i in b)) + for (b,alpha) in pairs ), + W.zero()) +