]> gitweb.michael.orlitzky.com - sage.d.git/blobdiff - mjo/eja/eja_utils.py
eja: more tests/examples.
[sage.d.git] / mjo / eja / eja_utils.py
index c25b81921e1be4f0d6a77580227cb8692e21605f..832dcef1fac0baa573b4883bc4e2ddd3fbfd55a8 100644 (file)
@@ -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