Skip to content

Commit 6fffd92

Browse files
committed
more detailed documentation
1 parent 6ff8acf commit 6fffd92

File tree

1 file changed

+32
-12
lines changed

1 file changed

+32
-12
lines changed

src/sage/arith/misc.py

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6290,7 +6290,34 @@ def dedekind_psi(N):
62906290

62916291
class ProductTree:
62926292
r"""
6293-
A simple product tree.
6293+
A simple binary product tree, i.e., a tree of ring elements in
6294+
which every node equals the product of its children.
6295+
(In particular, the *root* equals the product of all *leaves*.)
6296+
6297+
Product trees are a very useful building block for fast computer
6298+
algebra. For example, a quasilinear-time Discrete Fourier Transform
6299+
(the famous *Fast* Fourier Transform) can be implemented as follows
6300+
using the :meth:`remainders` method of this class::
6301+
6302+
sage: F = GF(65537)
6303+
sage: a = F(1111)
6304+
sage: assert a.multiplicative_order() == 1024
6305+
sage: R.<x> = F[]
6306+
sage: ms = [x - a^i for i in range(1024)] # roots of unity
6307+
sage: ys = [F.random_element() for _ in range(1024)] # input vector
6308+
sage: zs = ProductTree(ms).remainders(R(ys)) # compute FFT!
6309+
6310+
This class encodes the tree as *layers*: Layer `0` is just a tuple
6311+
of the leaves. Layer `i+1` is obtained from layer `i` by replacing
6312+
each pair of two adjacent elements by their product, starting from
6313+
the left. (If the length is odd, the unpaired element at the end is
6314+
simply copied as is.) This iteration stops as soon as it yields a
6315+
layer containing only a single element (the root).
6316+
6317+
.. NOTE::
6318+
6319+
Use this class if you need the :meth:`remainders` method.
6320+
To compute just the product, :func:`prod` is likely faster.
62946321
62956322
INPUT:
62966323
@@ -6327,11 +6354,6 @@ class ProductTree:
63276354
(9699690, 3359814435017, 729345064647247, 97),
63286355
(32589158477190044730, 70746471270782959),
63296356
(2305567963945518424753102147331756070,)]
6330-
6331-
.. NOTE::
6332-
6333-
Use this class if you need the :meth:`remainders` method.
6334-
To compute just the product, :func:`prod` is likely faster.
63356357
"""
63366358
def __init__(self, leaves):
63376359
r"""
@@ -6458,18 +6480,16 @@ def prod_with_derivative(pairs):
64586480
64596481
This function is entirely algebraic, hence still works when the
64606482
elements `f` and `\partial f` are all passed through some ring
6461-
homomorphism first. (See the polynomial-evaluation example below.)
6483+
homomorphism first. One particularly useful instance of this is
6484+
evaluating the derivative of a product of polynomials at a point
6485+
without fully expanding the product; see the second example below.
64626486
64636487
INPUT:
64646488
64656489
- ``pairs`` -- a sequence of tuples `(f, \partial f)` of elements
64666490
of a common ring
64676491
6468-
ALGORITHM:
6469-
6470-
This function wraps the given pairs in a thin helper class that
6471-
automatically applies the product rule whenever multiplication
6472-
is invoked, then calls :func:`prod` on the wrapped pairs.
6492+
ALGORITHM: Repeated application of the product rule.
64736493
64746494
EXAMPLES::
64756495

0 commit comments

Comments
 (0)