X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=mjo%2Feja%2Feja_utils.py;fp=mjo%2Feja%2Feja_utils.py;h=832dcef1fac0baa573b4883bc4e2ddd3fbfd55a8;hb=8059516ad9df112ac18c740af7d6f856639d4b8d;hp=c25b81921e1be4f0d6a77580227cb8692e21605f;hpb=f85bca2ff71a537c82fae3736944ce8896c30251;p=sage.d.git diff --git a/mjo/eja/eja_utils.py b/mjo/eja/eja_utils.py index c25b819..832dcef 100644 --- a/mjo/eja/eja_utils.py +++ b/mjo/eja/eja_utils.py @@ -6,6 +6,32 @@ def _scale(x, alpha): r""" Scale the vector, matrix, or cartesian-product-of-those-things ``x`` by ``alpha``. + + This works around the inability to scale certain elements of + Cartesian product spaces, as reported in + + https://trac.sagemath.org/ticket/31435 + + ..WARNING: + + This will do the wrong thing if you feed it a tuple or list. + + SETUP:: + + sage: from mjo.eja.eja_utils import _scale + + EXAMPLES:: + + sage: v = vector(QQ, (1,2,3)) + sage: _scale(v,2) + (2, 4, 6) + sage: m = matrix(QQ, [[1,2],[3,4]]) + sage: M = cartesian_product([m.parent(), m.parent()]) + sage: _scale(M((m,m)), 2) + ([2 4] + [6 8], [2 4] + [6 8]) + """ if hasattr(x, 'cartesian_factors'): P = x.parent() @@ -14,6 +40,7 @@ def _scale(x, alpha): else: return x*alpha + def _all2list(x): r""" Flatten a vector, matrix, or cartesian product of those things