Ticket #14825: trac_14825_polynomial_representation_padics.patch
File trac_14825_polynomial_representation_padics.patch, 4.7 KB (added by , 6 years ago) 


sage/rings/padics/padic_ZZ_pX_CR_element.pyx
# HG changeset patch # User Xavier Caruso <xavier.caruso@normalesup.org> # Date 1363522332 3600 # Node ID a09c4e3e2ae8214a40ce10c1e192e0654ca86b54 # Parent a095d2879fc460a22289129f68149ffd13cfbb16 Trac #14825: polynomial representation of an unramified padic number diff git a/sage/rings/padics/padic_ZZ_pX_CR_element.pyx b/sage/rings/padics/padic_ZZ_pX_CR_element.pyx
a b 2512 2512 """ 2513 2513 return ZZ_pX_ConstTerm((<pAdicZZpXCRElement>self).unit) 2514 2514 2515 def polynomial(self, PolRing=None, variable_name='x'): 2516 """ 2517 INPUT: 2518 2519  PolRing (default: None)  a polynomial Ring or None 2520 2521  variable_name (default: 'x') 2522 2523 OUTPUT: 2524 2525 A polynomial with coefficients in `\mathbb Q_p` (where `p` 2526 is the underlying prime) representing this element. 2527 2528 If ``PolRing`` is not None, it will be used as the parent 2529 of the returned polynomial. In this case, the attribute 2530 ``variable_name`` is ignored. 2531 2532 If ``PolRing`` is None, a new parent is created. 2533 2534 EXAMPLES: 2535 2536 sage: K.<a> = Qq(5^3) 2537 sage: a.polynomial() 2538 (1 + O(5^20))*x + (O(5^20)) 2539 sage: a.polynomial(variable_name='y') 2540 (1 + O(5^20))*y + (O(5^20)) 2541 2542 sage: PolRing.<X> = PolynomialRing(Qp(5)) 2543 sage: a.polynomial(PolRing) 2544 (1 + O(5^20))*X + (O(5^20)) 2545 sage: a.polynomial(PolRing, variable_name='Y') # here ``variable_name`` is ignored 2546 (1 + O(5^20))*X + (O(5^20)) 2547 2548 AUTHOR: 2549 2550  Xavier Caruso (201303) 2551 """ 2552 if PolRing is None: 2553 from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing 2554 PolRing = PolynomialRing(self.base_ring(), name=variable_name) 2555 from sage.functions.other import ceil 2556 base = self.base_ring() 2557 parent = self.parent() 2558 e = parent.e() 2559 if self.is_zero(): 2560 coeffs = [ ] 2561 shift = 0 2562 else: 2563 val = self.valuation() 2564 if val < 0: 2565 shift = ceil(val/e) 2566 self *= parent(base.uniformizer_pow(shift)) 2567 else: 2568 shift = 0 2569 f, _ = self._ntl_rep_abs() 2570 coeffs = f.list() 2571 prec = self.precision_absolute() 2572 if prec is infinity: 2573 coeffs = [ base(Integer(coeffs[i])) >> shift for i in range(len(coeffs)) ] 2574 else: 2575 if e > 1: 2576 coeffs = [ base(Integer(coeffs[i]), ceil((preci)/e)) >> shift for i in range(len(coeffs)) ] 2577 else: 2578 coeffs = [ base(Integer(coeffs[i]), prec) >> shift for i in range(len(coeffs)) ] 2579 return PolRing(coeffs) 2580 2515 2581 def is_equal_to(self, right, absprec = None): 2516 2582 """ 2517 2583 Returns whether ``self`` is equal to ``right`` modulo ``self.uniformizer()^absprec``. 
sage/rings/padics/padic_capped_relative_element.pyx
diff git a/sage/rings/padics/padic_capped_relative_element.pyx b/sage/rings/padics/padic_capped_relative_element.pyx
a b 817 817 """ 818 818 return (<Element>left)._richcmp(right, op) 819 819 820 def polynomial(self, PolRing=None, variable_name='x'): 821 """ 822 INPUT: 823 824  PolRing (default: None)  a polynomial Ring or None 825 826  variable_name (default: 'x') 827 828 OUTPUT: 829 830 A polynomial with coefficients in `\mathbb Q_p` (where `p` 831 is the underlying prime) representing this element. 832 833 If ``PolRing`` is not None, it will be used as the parent 834 of the returned polynomial. In this case, the attribute 835 ``variable_name`` is ignored. 836 837 If ``PolRing`` is None, a new parent is created. 838 839 EXAMPLES: 840 841 sage: K.<a> = Qq(5^3) 842 sage: a.polynomial() 843 (1 + O(5^20))*x + (O(5^20)) 844 sage: a.polynomial(variable_name='y') 845 (1 + O(5^20))*y + (O(5^20)) 846 847 sage: PolRing.<X> = PolynomialRing(Qp(5)) 848 sage: a.polynomial(PolRing) 849 (1 + O(5^20))*X + (O(5^20)) 850 sage: a.polynomial(PolRing, variable_name='Y') # here ``variable_name`` is ignored 851 (1 + O(5^20))*X + (O(5^20)) 852 853 AUTHOR: 854 855  Xavier Caruso (201303) 856 """ 857 if PolRing is None: 858 from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing 859 PolRing = PolynomialRing(self.base_ring(), name=variable_name) 860 return PolRing(self) 861 820 862 cpdef ModuleElement _neg_(self): 821 863 """ 822 864 Negation.