1# -*- coding: utf-8 -*- 2r""" 3Legacy conversions of SageMath Number Fields and their Elements to the real 4embedded variants provided by e-antic. 5""" 6###################################################################### 7# This file is part of e-antic. 8# 9# Copyright (C) 2019 Vincent Delecroix 10# Copyright (C) 2019 Julian Rüth 11# 12# e-antic is free software: you can redistribute it and/or modify 13# it under the terms of the GNU Lesser General Public License as published by 14# the Free Software Foundation, either version 3 of the License, or (at your 15# option) any later version. 16# 17# e-antic is distributed in the hope that it will be useful, 18# but WITHOUT ANY WARRANTY; without even the implied warranty of 19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20# GNU General Public License for more details. 21# 22# You should have received a copy of the GNU General Public License 23# along with e-antic. If not, see <https://www.gnu.org/licenses/>. 24##################################################################### 25 26def sage_nf_to_eantic(K): 27 r""" 28 An alias for ``pyeantic.RealEmbeddedNumberField(K).renf``. 29 30 EXAMPLES:: 31 32 sage: from pyeantic.sage_conversion import sage_nf_to_eantic 33 sage: x = polygen(QQ) 34 sage: K = NumberField(x**3 - 3, 'a', embedding=AA(3)**Rational((1,3))) 35 sage: L = sage_nf_to_eantic(K) 36 sage: L 37 NumberField(a^3 - 3, [1.442249570307408382321638310780 +/- 5.49e-31]) 38 sage: L.gen() 39 (a ~ 1.4422496) 40 41 """ 42 from .real_embedded_number_field import RealEmbeddedNumberField 43 return RealEmbeddedNumberField(K).renf 44 45def sage_nf_elem_to_eantic(K, elem): 46 r""" 47 An alias for ``pyeantic.RealEmbeddedNumberField(K)(elem).renf_elem`` 48 49 INPUT: 50 51 - ``K`` (eantic number field): the number field to which the conversion is 52 performed 53 - ``elem`` (Sage number field element): the element to convert 54 55 EXAMPLES:: 56 57 sage: from pyeantic.sage_conversion import sage_nf_to_eantic, sage_nf_elem_to_eantic 58 sage: x = polygen(QQ) 59 sage: K = NumberField(x**3 - 3, 'a', embedding=AA(3)**Rational((1,3))) 60 sage: L = sage_nf_to_eantic(K) 61 sage: sage_nf_elem_to_eantic(L, Integer(1)) 62 1 63 sage: sage_nf_elem_to_eantic(L, Rational((2,3))) 64 (2/3 ~ 0.66666667) 65 sage: sage_nf_elem_to_eantic(L, 'a') 66 (a ~ 1.4422496) 67 sage: sage_nf_elem_to_eantic(L, K.gen()) 68 (a ~ 1.4422496) 69 70 """ 71 from .real_embedded_number_field import RealEmbeddedNumberField 72 return RealEmbeddedNumberField(K)(elem).renf_elem 73