From e776b06ba3e77214bf670043bbff81148891b195 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 21 Aug 2019 09:57:40 -0400 Subject: [PATCH] eja: use QuadraticField selectively to simplify tests. --- mjo/eja/eja_algebra.py | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index f7983c8..05dea56 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -15,7 +15,7 @@ from sage.misc.prandom import choice from sage.misc.table import table from sage.modules.free_module import FreeModule, VectorSpace from sage.rings.integer_ring import ZZ -from sage.rings.number_field.number_field import NumberField +from sage.rings.number_field.number_field import NumberField, QuadraticField from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.rings.rational_field import QQ from sage.rings.real_lazy import CLF, RLF @@ -853,9 +853,7 @@ def _complex_hermitian_basis(n, field): sage: set_random_seed() sage: n = ZZ.random_element(1,5) - sage: R = PolynomialRing(QQ, 'z') - sage: z = R.gen() - sage: field = NumberField(z**2 - 2, 'sqrt2', embedding=RLF(2).sqrt()) + sage: field = QuadraticField(2, 'sqrt2') sage: B = _complex_hermitian_basis(n, field) sage: all( M.is_symmetric() for M in B) True @@ -989,9 +987,7 @@ def _embed_complex_matrix(M): EXAMPLES:: - sage: R = PolynomialRing(QQ, 'z') - sage: z = R.gen() - sage: F = NumberField(z**2 + 1, 'i', embedding=CLF(-1).sqrt()) + sage: F = QuadraticField(-1, 'i') sage: x1 = F(4 - 2*i) sage: x2 = F(1 + 2*i) sage: x3 = F(-i) @@ -1010,9 +1006,7 @@ def _embed_complex_matrix(M): sage: set_random_seed() sage: n = ZZ.random_element(5) - sage: R = PolynomialRing(QQ, 'z') - sage: z = R.gen() - sage: F = NumberField(z**2 + 1, 'i', embedding=CLF(-1).sqrt()) + sage: F = QuadraticField(-1, 'i') sage: X = random_matrix(F, n) sage: Y = random_matrix(F, n) sage: actual = _embed_complex_matrix(X) * _embed_complex_matrix(Y) @@ -1059,9 +1053,7 @@ def _unembed_complex_matrix(M): Unembedding is the inverse of embedding:: sage: set_random_seed() - sage: R = PolynomialRing(QQ, 'z') - sage: z = R.gen() - sage: F = NumberField(z**2 + 1, 'i', embedding=CLF(-1).sqrt()) + sage: F = QuadraticField(-1, 'i') sage: M = random_matrix(F, 3) sage: _unembed_complex_matrix(_embed_complex_matrix(M)) == M True @@ -1137,9 +1129,7 @@ def _embed_quaternion_matrix(M): if M.ncols() != n: raise ValueError("the matrix 'M' must be square") - R = PolynomialRing(QQ, 'z') - z = R.gen() - F = NumberField(z**2 + 1, 'i', embedding=CLF(-1).sqrt()) + F = QuadraticField(-1, 'i') i = F.gen() blocks = [] -- 2.44.2