]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: fix complex-unembedding with respect to 5537f4534.
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 19 Jul 2019 21:35:12 +0000 (17:35 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Mon, 29 Jul 2019 03:19:01 +0000 (23:19 -0400)
mjo/eja/euclidean_jordan_algebra.py

index 8f21db7406a2d336a43f6fec3c8bc4438d0536a8..1e5ada2188c3b6b3834165f221ab20b56d5c1f98 100644 (file)
@@ -1216,8 +1216,17 @@ def _unembed_complex_matrix(M):
         ....:                 [ 9,  10, 11, 12],
         ....:                 [-10, 9, -12, 11] ])
         sage: _unembed_complex_matrix(A)
-        [  -2*i + 1   -4*i + 3]
-        [ -10*i + 9 -12*i + 11]
+        [  2*i + 1   4*i + 3]
+        [ 10*i + 9 12*i + 11]
+
+    TESTS::
+
+        sage: set_random_seed()
+        sage: F = QuadraticField(-1, 'i')
+        sage: M = random_matrix(F, 3)
+        sage: _unembed_complex_matrix(_embed_complex_matrix(M)) == M
+        True
+
     """
     n = ZZ(M.nrows())
     if M.ncols() != n:
@@ -1238,7 +1247,7 @@ def _unembed_complex_matrix(M):
                 raise ValueError('bad real submatrix')
             if submat[0,1] != -submat[1,0]:
                 raise ValueError('bad imag submatrix')
-            z = submat[0,0] + submat[1,0]*i
+            z = submat[0,0] + submat[0,1]*i
             elements.append(z)
 
     return matrix(F, n/2, elements)