|
ADS
Algorithms and Data Structures
|
The product of two polynomials of \( n \) coefficients each, the vectors \( p[ 0 .. n - 1 ] \) and \( q[ 0 .. n - 1 ] \) from the constant one, into the \( 2 n - 1 \) coefficients of \( r = p q \) (section 12.3): More...
#include "ADS/Contract.h"#include <algorithm>#include <cstddef>#include <vector>#include "ADS/numeric/impl/Polynomial.tpp"Go to the source code of this file.
Namespaces | |
| namespace | ADS |
Functions | |
| template<class T> | |
| std::vector< T > | ADS::multiplyNaive (const std::vector< T > &p, const std::vector< T > &q, long *mults=nullptr) |
| the product \( p q \) by all the products of two coefficients, \( \Theta( n^2 ) \) (the moltiplicaPolinomi() of the book); their number added to *mults, if given | |
| template<class T> | |
| std::vector< T > | ADS::multiplyFour (const std::vector< T > &p, const std::vector< T > &q, long *mults=nullptr) |
| the product \( p q \) by four recursive products of half size, \( \Theta( n^2 ) \) (the Prodotto4() of the book on polynomials); the products of two coefficients added to *mults, if given | |
| template<class T> | |
| std::vector< T > | ADS::multiplyKaratsuba (const std::vector< T > &p, const std::vector< T > &q, long *mults=nullptr) |
| the product \( p q \) by the three recursive products of Karatsuba, \( O( n^{1.59} ) \) (the moltiplicaPolinomiD&I() of the book); the products of two coefficients added to *mults, if given | |
The product of two polynomials of \( n \) coefficients each, the vectors \( p[ 0 .. n - 1 ] \) and \( q[ 0 .. n - 1 ] \) from the constant one, into the \( 2 n - 1 \) coefficients of \( r = p q \) (section 12.3):
The recursive ones split at \( h = \lfloor n / 2 \rfloor \), so that \( n \) need not be a power of two, and count in *mults, if given, the products of two coefficients.
The contracts [see Contract.h]: the recursion needs two polynomials of the same degree, and the products of the four and of the three halves equal the product of multiplyNaive(), an audit. The functions are defined in Polynomial.tpp.