From 1fd47aaad2f699133ac31f1245ddd33a9ed7ce03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20R=C3=BCth?= Date: Wed, 7 Dec 2016 13:16:05 -0500 Subject: [PATCH] Document passing in coefficients into valuations() --- augmented_valuation.py | 10 ++++++++++ gauss_valuation.py | 9 +++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/augmented_valuation.py b/augmented_valuation.py index d7ea0a4e69..7a74304981 100644 --- a/augmented_valuation.py +++ b/augmented_valuation.py @@ -1540,6 +1540,11 @@ def valuations(self, f, coefficients=None): - ``f`` -- a polynomial in the domain of this valuation + - ``coefficients`` -- the coefficients of ``f`` as produced by + :meth:`coefficients` or ``None`` (default: ``None``); this can be + used to speed up the computation when the expansion of ``f`` is + already known from a previous computation. + OUTPUT: An iterator over rational numbers (or infinity) `[v(f_0), v(f_1\phi), \dots]` @@ -1703,6 +1708,11 @@ def valuations(self, f, coefficients=None): - ``f`` -- a polynomial in the domain of this valuation + - ``coefficients`` -- the coefficients of ``f`` as produced by + :meth:`coefficients` or ``None`` (default: ``None``); this can be + used to speed up the computation when the expansion of ``f`` is + already known from a previous computation. + OUTPUT: An iterator over rational numbers (or infinity) `[v(f_0), v(f_1\phi), \dots]` diff --git a/gauss_valuation.py b/gauss_valuation.py index 96807f1a23..f098f4c5f8 100644 --- a/gauss_valuation.py +++ b/gauss_valuation.py @@ -242,7 +242,7 @@ def uniformizer(self): """ return self.domain()(self._base_valuation.uniformizer()) - def valuations(self, f): + def valuations(self, f, coefficients=None): """ Return the valuations of the `f_i\phi^i` in the expansion `f=\sum f_i\phi^i`. @@ -250,6 +250,11 @@ def valuations(self, f): - ``f`` -- a polynomial in the domain of this valuation + - ``coefficients`` -- the coefficients of ``f`` as produced by + :meth:`coefficients` or ``None`` (default: ``None``); this can be + used to speed up the computation when the expansion of ``f`` is + already known from a previous computation. + OUTPUT: A list, each entry a rational numbers or infinity, the valuations of `f_0, f_1\phi, \dots` @@ -267,7 +272,7 @@ def valuations(self, f): """ f = self.domain().coerce(f) - for c in self.coefficients(f): + for c in coefficients or self.coefficients(f): yield self._base_valuation(c) @cached_method