piranha
0.10
|
Specialisation of piranha::series_multiplier for piranha::divisor_series. More...
#include <piranha/divisor_series.hpp>
Public Types | |
using | v_ptr = std::vector< typename Series::term_type const * > |
Alias for a vector of const pointers to series terms. | |
using | size_type = typename v_ptr::size_type |
The size type of base_series_multiplier::v_ptr. | |
using | bucket_size_type = typename Series::size_type |
The size type of Series . | |
Public Member Functions | |
template<typename T = Series, call_enabler< T > = 0> | |
Series | operator() () const |
Call operator. More... | |
Protected Member Functions | |
template<typename MultFunctor , typename LimitFunctor > | |
void | blocked_multiplication (const MultFunctor &mf, const size_type &start1, const size_type &end1, const LimitFunctor &lf) const |
Blocked multiplication. More... | |
template<typename MultFunctor > | |
void | blocked_multiplication (const MultFunctor &mf, const size_type &start1, const size_type &end1) const |
Blocked multiplication (convenience overload). More... | |
template<std::size_t MultArity, typename MultFunctor , typename LimitFunctor > | |
bucket_size_type | estimate_final_series_size (const LimitFunctor &lf) const |
Estimate size of series multiplication. More... | |
template<std::size_t MultArity, typename MultFunctor > | |
bucket_size_type | estimate_final_series_size () const |
Estimate size of series multiplication (convenience overload) More... | |
template<typename LimitFunctor > | |
Series | plain_multiplication (const LimitFunctor &lf) const |
A plain series multiplication routine. More... | |
Series | plain_multiplication () const |
A plain series multiplication routine (convenience overload). More... | |
void | finalise_series (Series &s) const |
Finalise series. More... | |
Static Protected Member Functions | |
static void | sanitise_series (Series &retval, unsigned n_threads) |
Sanitise series. More... | |
Protected Attributes | |
v_ptr | m_v1 |
Vector of const pointers to the terms in the larger series. | |
v_ptr | m_v2 |
Vector of const pointers to the terms in the smaller series. | |
const symbol_fset | m_ss |
The symbol set of the series used during construction. | |
unsigned | m_n_threads |
Number of threads. More... | |
Specialisation of piranha::series_multiplier for piranha::divisor_series.
Definition at line 568 of file divisor_series.hpp.
|
inlineprotectedinherited |
Blocked multiplication.
MultFunctor
or LimitFunctor
do not satisfy the requirements outlined below, a compile-time error will be produced.This method is logically equivalent to the following double loop:
mf
must be a function object with a call operator accepting two instances of base_series_multiplier::size_type and returning void
. lf
must be a function object with a call operator accepting and returning a base_series_multiplier::size_type.
Internally, the double loops is decomposed in blocks of size tuning::get_multiplication_block_size() in an attempt to optimise cache memory access patterns.
This method is meant to be used for series multiplication. mf
is intended to be a function object that multiplies the i
-th term of the first series by the j
-th term of the second series. lf
is intended to be a functor that establishes how many terms in the second series have to be multiplied by the i
-th term of the first series.
mf | the multiplication functor. |
start1 | start index in the first series. |
end1 | end index in the first series. |
lf | the limit functor. |
std::invalid_argument | if start1 is greater than end1 or greater than the size of base_series_multiplier::m_v1, or if end1 is greater than the size of base_series_multiplier::m_v1. |
unspecified | any exception thrown by the call operator of mf or sf , or piranha::safe_cast. |
Definition at line 442 of file base_series_multiplier.hpp.
|
inlineprotectedinherited |
Blocked multiplication (convenience overload).
This method is equivalent to the other overload with a limit functor that will unconditionally always return the size of the second series.
mf | the multiplication functor. |
start1 | start index in the first series. |
end1 | end index in the first series. |
unspecified | any exception thrown by the other overload. |
Definition at line 509 of file base_series_multiplier.hpp.
|
inlineprotectedinherited |
Estimate size of series multiplication.
MultArity
, MultFunctor
or LimitFunctor
do not satisfy the requirements outlined below, a compile-time error will be produced.This method expects a MultFunctor
type exposing the same inteface as explained in blocked_multiplication(). Additionally, MultFunctor
must be constructible from a const reference to piranha::base_series_multiplier and a mutable reference to Series
. MultFunctor
objects will be constructed internally by this method, passing this
and a temporary local Series
object as construction parameters. It will be assumed that a call mf(i,j)
multiplies the i
-th term of the first series by the j
-th term of the second series, accumulating the result into the Series
passed as second parameter for construction.
This method will apply a statistical approach to estimate the final size of the result of the multiplication of the first series by the second. It will perform random term-by-term multiplications and deduce the estimate from the number of term multiplications performed before finding the first duplicate term. The MultArity
parameter represents the arity of term multiplications - that is, the number of terms generated by a single term-by-term multiplication. It must be strictly positive.
The lf
parameter must be a function object exposing the same inteface as explained in blocked_multiplication(). This functor establishes how many terms in the second series must be multiplied by the i
-th term of the first series.
The number returned by this function is always at least 1. Multiple threads might be used by this method: in such a case, different instances of MultFunctor
are constructed in different threads, but lf
is shared among all threads.
lf | the limit functor. |
std::overflow_error | in case of (unlikely) overflows in integral arithmetics. |
unspecified | any exception thrown by:
|
Definition at line 556 of file base_series_multiplier.hpp.
|
inlineprotectedinherited |
Estimate size of series multiplication (convenience overload)
unspecified | any exception thrown by the other overload of estimate_final_series_size(). |
Definition at line 719 of file base_series_multiplier.hpp.
|
inlineprotectedinherited |
Finalise series.
This method will finalise the output s
of a series multiplication undertaken via piranha::base_series_multiplier. Currently, this method will not do anything unless the coefficient type of Series
is an instance of piranha::mp_rational. In this case, the coefficients of s
will be normalised with respect to the least common multiplier computed in the constructor of piranha::base_series_multiplier.
s | the Series to be finalised. |
unspecified | any exception thrown by: |
Definition at line 1120 of file base_series_multiplier.hpp.
|
inline |
Call operator.
Series
satisfy piranha::key_is_multipliable.The call operator will use base_series_multiplier::plain_multiplication().
unspecified | any exception thrown by base_series_multiplier::plain_multiplication(). |
Definition at line 592 of file divisor_series.hpp.
|
inlineprotectedinherited |
A plain series multiplication routine.
Series
do not satisfy piranha::key_is_multipliable, or LimitFunctor
does not satisfy the requirements outlined in base_series_multiplier::blocked_multiplication(), a compile-time error will be produced.This method implements a generic series multiplication routine suitable for key types that satisfy piranha::key_is_multipliable. The implementation is either single-threaded or multi-threaded, depending on the sizes of the input series, and it will use either base_series_multiplier::plain_multiplier or a similar thread-safe multiplier for the term-by-term multiplications. The lf
functor will be forwarded as limit functor to base_series_multiplier::blocked_multiplication() and base_series_multiplier::estimate_final_series_size().
Note that, in multithreaded mode, lf
will be shared among (and called concurrently from) all the threads.
lf | the limit functor (see base_series_multiplier::blocked_multiplication()). |
this
.unspecified | any exception thrown by:
|
Definition at line 978 of file base_series_multiplier.hpp.
|
inlineprotectedinherited |
A plain series multiplication routine (convenience overload).
unspecified | any exception thrown by the other overload of plain_multiplication(). |
Definition at line 1100 of file base_series_multiplier.hpp.
|
inlinestaticprotectedinherited |
Sanitise series.
When using the low-level interface of piranha::hash_set for term insertion, invariants might be violated both in piranha::hash_set and piranha::series. In particular:
This method can be used to fix these invariants: it will check whether each term of retval
is incompatible and/or zero, and the total count of terms in the series will be set to the number of nonzero terms. Zero terms will be erased.
Note that in case of exceptions retval
will likely be left in an inconsistent state which violates internal invariants. Calls to this function should always be wrapped in a try/catch block that makes sure that retval
is cleared before re-throwing.
retval | the series to be sanitised. |
n_threads | the number of threads to be used. |
std::invalid_argument | if n_threads is zero, or if one of the terms in retval is not compatible with the symbol set of retval . |
std::overflow_error | if the number of terms in retval overflows the maximum value representable by base_series_multiplier::bucket_size_type. |
unspecified | any exception thrown by:
|
Definition at line 845 of file base_series_multiplier.hpp.
|
protectedinherited |
Number of threads.
This value will be set by the constructor, and it represents the number of threads that will be used by the multiplier. The value is always at least 1 and it is calculated via thread_pool::use_threads().
Definition at line 1138 of file base_series_multiplier.hpp.