# Ticket #15193: 15193-Factorization-pari.patch

File 15193-Factorization-pari.patch, 1.5 KB (added by pbruin, 8 years ago)
• ## sage/structure/factorization.py

# HG changeset patch
# User Peter Bruin <P.Bruin@warwick.ac.uk>
# Date 1379079713 -3600
# Node ID 4954795dcbc6500559a748e648f52e1fa6e267f0
# Parent  4275212b576c16066ba6d5e9574e057c7f558bc8
diff --git a/sage/structure/factorization.py b/sage/structure/factorization.py
 a from sage.structure.sequence import Sequence from sage.rings.integer import Integer from sage.misc.all import prod from sage.misc.cachefunc import cached_method class Factorization(SageObject): """ s =  u + ' \\cdot ' + s return s @cached_method def _pari_(self): """ Return the PARI factorization matrix corresponding to self. EXAMPLES:: sage: f = factor(-24) sage: pari(f) [-1, 1; 2, 3; 3, 1] sage: R. = QQ[] sage: g = factor(x^10 - 1) sage: pari(g) [x - 1, 1; x + 1, 1; x^4 - x^3 + x^2 - x + 1, 1; x^4 + x^3 + x^2 + x + 1, 1] """ from sage.libs.pari.all import pari n = len(self) if self.__unit == 1: init = () else: init = (self.__unit, 1) n += 1 # concatenate (p, e) tuples entries = reduce(lambda f, g: f + g, self, init) return pari.matrix(n, 2, entries) def __add__(self, other): """ Return the (unfactored) sum of self and other.