# HG changeset patch
# User Peter Bruin <P.Bruin@warwick.ac.uk>
# Date 1379079713 3600
# Node ID 4954795dcbc6500559a748e648f52e1fa6e267f0
# Parent 4275212b576c16066ba6d5e9574e057c7f558bc8
Trac 15193: add method Factorization._pari_()
diff git a/sage/structure/factorization.py b/sage/structure/factorization.py
a

b


186  186  from sage.structure.sequence import Sequence 
187  187  from sage.rings.integer import Integer 
188  188  from sage.misc.all import prod 
 189  from sage.misc.cachefunc import cached_method 
189  190  
190  191  class Factorization(SageObject): 
191  192  """ 
… 
… 

885  886  s = u + ' \\cdot ' + s 
886  887  return s 
887  888  
 889  @cached_method 
 890  def _pari_(self): 
 891  """ 
 892  Return the PARI factorization matrix corresponding to ``self``. 
 893  
 894  EXAMPLES:: 
 895  
 896  sage: f = factor(24) 
 897  sage: pari(f) 
 898  [1, 1; 2, 3; 3, 1] 
 899  
 900  sage: R.<x> = QQ[] 
 901  sage: g = factor(x^10  1) 
 902  sage: pari(g) 
 903  [x  1, 1; x + 1, 1; x^4  x^3 + x^2  x + 1, 1; x^4 + x^3 + x^2 + x + 1, 1] 
 904  
 905  """ 
 906  from sage.libs.pari.all import pari 
 907  n = len(self) 
 908  if self.__unit == 1: 
 909  init = () 
 910  else: 
 911  init = (self.__unit, 1) 
 912  n += 1 
 913  # concatenate (p, e) tuples 
 914  entries = reduce(lambda f, g: f + g, self, init) 
 915  return pari.matrix(n, 2, entries) 
 916  
888  917  def __add__(self, other): 
889  918  """ 
890  919  Return the (unfactored) sum of self and other. 