ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
Polynomial.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*--------------------------- File Polynomial.h ----------------------------*/
3/*--------------------------------------------------------------------------*/
42/*--------------------------------------------------------------------------*/
43/*----------------------------- DEFINITIONS --------------------------------*/
44/*--------------------------------------------------------------------------*/
45
46#ifndef __ADS_Polynomial
47 #define __ADS_Polynomial
48/* self-identification: #endif constant */
49
50/*--------------------------------------------------------------------------*/
51/*------------------------------ INCLUDES ----------------------------------*/
52/*--------------------------------------------------------------------------*/
53
54#include "ADS/Contract.h"
55
56#include <algorithm>
57#include <cstddef>
58#include <vector>
59
60/*--------------------------------------------------------------------------*/
61/*--------------------------- NAMESPACE ------------------------------------*/
62/*--------------------------------------------------------------------------*/
63
64namespace ADS
65{
66
81template< class T >
82std::vector< T > multiplyNaive( const std::vector< T > & p ,
83 const std::vector< T > & q ,
84 long * mults = nullptr );
85
86namespace detail
87{
88
90template< class T >
91void addShifted( std::vector< T > & r , const std::vector< T > & a ,
92 std::size_t s , T sign = T( 1 ) );
93
96template< class T >
97std::vector< T > multiplyRec( const std::vector< T > & p ,
98 const std::vector< T > & q , bool three ,
99 long * mults );
100
103template< class T >
104std::vector< T > multiplySame( std::vector< T > p , std::vector< T > q ,
105 bool three , long * mults );
106
107} // end( namespace detail )
108
130template< class T >
131std::vector< T > multiplyFour( const std::vector< T > & p ,
132 const std::vector< T > & q ,
133 long * mults = nullptr );
134
155template< class T >
156std::vector< T > multiplyKaratsuba( const std::vector< T > & p ,
157 const std::vector< T > & q ,
158 long * mults = nullptr );
159
160/*--------------------------------------------------------------------------*/
161
162} // end( namespace ADS )
163
164/*--------------------------------------------------------------------------*/
165/*-------------------------- IMPLEMENTATION --------------------------------*/
166/*--------------------------------------------------------------------------*/
167
168#include "ADS/numeric/impl/Polynomial.tpp"
169
170/*--------------------------------------------------------------------------*/
171
172#endif /* Polynomial.h included */
173
174/*--------------------------------------------------------------------------*/
175/*------------------------- End File Polynomial.h --------------------------*/
176/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
Matrix< T > multiplyNaive(const Matrix< T > &A, const Matrix< T > &B, long *mults=nullptr)
the product of two matrices by the definition, (the moltiplicaMatrici() of the book); the products...
std::vector< T > multiplyKaratsuba(const std::vector< T > &p, const std::vector< T > &q, long *mults=nullptr)
the product by the three recursive products of Karatsuba, (the moltiplicaPolinomiD&I() of the book)...
std::vector< T > multiplyFour(const std::vector< T > &p, const std::vector< T > &q, long *mults=nullptr)
the product by four recursive products of half size, (the Prodotto4() of the book on polynomials); ...
Definition ADT.h:96