@@ -6290,7 +6290,34 @@ def dedekind_psi(N):
6290
6290
6291
6291
class ProductTree :
6292
6292
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.
6294
6321
6295
6322
INPUT:
6296
6323
@@ -6327,11 +6354,6 @@ class ProductTree:
6327
6354
(9699690, 3359814435017, 729345064647247, 97),
6328
6355
(32589158477190044730, 70746471270782959),
6329
6356
(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.
6335
6357
"""
6336
6358
def __init__ (self , leaves ):
6337
6359
r"""
@@ -6458,18 +6480,16 @@ def prod_with_derivative(pairs):
6458
6480
6459
6481
This function is entirely algebraic, hence still works when the
6460
6482
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.
6462
6486
6463
6487
INPUT:
6464
6488
6465
6489
- ``pairs`` -- a sequence of tuples `(f, \partial f)` of elements
6466
6490
of a common ring
6467
6491
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.
6473
6493
6474
6494
EXAMPLES::
6475
6495
0 commit comments