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
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
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)
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)
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
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 = []