piranha
0.10
|
Divisor class. More...
#include <piranha/divisor.hpp>
Public Types | |
using | value_type = T |
Alias for T . | |
using | container_type = hash_set< p_type, p_type_hasher > |
Underlying container type. | |
using | size_type = typename container_type::size_type |
Size type. More... | |
Public Member Functions | |
divisor ()=default | |
Defaulted default constructor. More... | |
divisor (const divisor &)=default | |
Defaulted copy constructor. | |
divisor (divisor &&)=default | |
Defaulted move constructor. | |
divisor (const divisor &other, const symbol_fset &args) | |
Converting constructor. More... | |
divisor (const symbol_fset &) | |
Constructor from piranha::symbol_fset. More... | |
~divisor () | |
Trivial destructor. | |
divisor & | operator= (const divisor &other)=default |
Copy assignment operator. More... | |
divisor & | operator= (divisor &&other)=default |
Move assignment operator. More... | |
template<typename It , typename Exponent , insert_enabler< It, Exponent > = 0> | |
void | insert (It begin, It end, const Exponent &e) |
Create and insert a term from range and exponent. More... | |
size_type | size () const |
Size. More... | |
const container_type & | _container () const |
Const access to the internal container. More... | |
container_type & | _container () |
Mutable access to the internal container. More... | |
void | clear () |
Clear. More... | |
bool | operator== (const divisor &other) const |
Equality operator. More... | |
bool | operator!= (const divisor &other) const |
Inequality operator. More... | |
std::size_t | hash () const |
Hash value. More... | |
bool | is_compatible (const symbol_fset &args) const noexcept |
Compatibility check. More... | |
bool | is_zero (const symbol_fset &) const noexcept |
Zero check. More... | |
bool | is_unitary (const symbol_fset &) const |
Check if divisor is unitary. More... | |
divisor | merge_symbols (const symbol_idx_fmap< symbol_fset > &ins_map, const symbol_fset &args) const |
Merge symbols. More... | |
void | print (std::ostream &os, const symbol_fset &args) const |
Print to stream. More... | |
void | print_tex (std::ostream &os, const symbol_fset &args) const |
Print to stream in TeX mode. More... | |
template<typename U > | |
eval_type< U > | evaluate (const std::vector< U > &values, const symbol_fset &args) const |
Evaluation. More... | |
void | trim_identify (std::vector< char > &trim_mask, const symbol_fset &args) const |
Identify symbols that can be trimmed. More... | |
divisor | trim (const std::vector< char > &trim_mask, const symbol_fset &args) const |
Trim. More... | |
std::pair< divisor, divisor > | split (const symbol_idx &p, const symbol_fset &args) const |
Split divisor. More... | |
template<typename Stream , msgpack_pack_enabler< Stream > = 0> | |
void | msgpack_pack (msgpack::packer< Stream > &p, msgpack_format f, const symbol_fset &args) const |
Pack in msgpack format. More... | |
template<typename U = divisor, msgpack_convert_enabler< U > = 0> | |
void | msgpack_convert (const msgpack::object &o, msgpack_format f, const symbol_fset &args) |
Convert from msgpack object. More... | |
Static Public Member Functions | |
template<typename Cf , multiply_enabler< Cf > = 0> | |
static void | multiply (std::array< term< Cf, divisor >, multiply_arity > &res, const term< Cf, divisor > &t1, const term< Cf, divisor > &t2, const symbol_fset &args) |
Multiply terms with a divisor key. More... | |
Static Public Attributes | |
static const std::size_t | multiply_arity = 1u |
Arity of the multiply() method. | |
Divisor class.
This class is used to represent keys of the form
\[ \prod_j\frac{1}{\left(a_{0,j}x_0+a_{1,j}x_1+\ldots+a_{n,j}x_n\right)^{e_j}}, \]
where \( a_{i,j} \) are integers, \( x_i \) are symbols, and \( e_j \) are positive integers. The type of \( a_{i,j} \) and \( e_j \) is T
. The terms of the product are stored in a piranha::hash_set and they are guaranteed to be in a canonical form defined by the following properties:
T
is a C++ integral type, the values of \( a_{i,j} \) and \( e_j \) are within implementation-defined ranges,T
must be either a C++ signed integral type or an instance of piranha::mp_integer.
Unless otherwise specified, this class provides the strong exception safety guarantee for all operations.
Move semantics is equivalent to the move semantics of piranha::hash_set.
Definition at line 182 of file divisor.hpp.
using piranha::divisor< T >::size_type = typename container_type::size_type |
Size type.
It corresponds to the size type of the internal container.
Definition at line 334 of file divisor.hpp.
|
default |
Defaulted default constructor.
This constructor will initialise an empty divisor.
|
inlineexplicit |
Converting constructor.
This constructor is used in the generic constructor of piranha::series. It is equivalent to a copy constructor with extra checking.
other | the construction argument. |
args | the reference piranha::symbol_fset. |
std::invalid_argument | if other is not compatible with args . |
unspecified | any exception thrown by the copy constructor. |
Definition at line 355 of file divisor.hpp.
|
inlineexplicit |
Constructor from piranha::symbol_fset.
Equivalent to the default constructor.
Definition at line 366 of file divisor.hpp.
|
inline |
Const access to the internal container.
Definition at line 455 of file divisor.hpp.
|
inline |
Mutable access to the internal container.
Definition at line 463 of file divisor.hpp.
|
inline |
Clear.
This method will remove all terms from the divisor.
Definition at line 471 of file divisor.hpp.
|
inline |
Evaluation.
U
supports the arithmetic operations necessary to construct the return type.The return value will be built via multiplications of the \( a_{i,j} \) by the input values, additions, divisions and exponentiations via piranha::math::pow(). If the divisor has no terms, 1 will be returned.
values | the values will be used for the evaluation. |
args | the reference piranha::symbol_fset. |
this
with the values provided in values
.std::invalid_argument | if there exist an incompatibility between this , args or pmap . |
unspecified | any exception thrown by the construction of the return type. |
Definition at line 761 of file divisor.hpp.
|
inline |
Hash value.
The hash value is computed by combining the hash values of all terms. An empty divisor has a hash value of 0. Two equal divisors have the same hash value.
Definition at line 517 of file divisor.hpp.
|
inline |
Create and insert a term from range and exponent.
It
is an input iterator,It
can be safely cast to piranha::divisor::value_type,Exponent
can be safely cast to piranha::divisor::value_type.This method will construct and insert a term into the divisor. The elements in the range [begin,end)
will be used to construct the \( a_{i,j} \) of the term, while e
will be used to construct the exponent (after a call to piranha::safe_cast()). If no term with the same set of \( a_{i,j} \) exists, then a new term will be inserted; otherwise, e
will be added to the exponent of the existing term.
This method provides the basic exception safety guarantee.
begin | start of the range of \( a_{i,j} \). |
end | end of the range of \( a_{i,j} \). |
e | exponent. |
std::invalid_argument | if the term to be inserted is not in canonical form, or if the insertion leads to an overflow in the value of an exponent. |
std::overflow_error | if the insertion results in the container to be resized over an implementation-defined limit. |
unspecified | any exception thrown by:
|
Definition at line 420 of file divisor.hpp.
|
inlinenoexcept |
Compatibility check.
An empty divisor is considered compatible with any set of symbols. Otherwise, a non-empty divisor is compatible if the number of variables in the terms is the same as the number of symbols in args
.
args | the reference piranha::symbol_fset. |
true
if this
is compatible with args
, false
otherwise. Definition at line 546 of file divisor.hpp.
|
inline |
Check if divisor is unitary.
Only an empty divisor is considered unitary.
true
if this
is empty, false
otherwise. Definition at line 566 of file divisor.hpp.
|
inlinenoexcept |
|
inline |
Merge symbols.
This method will return a copy of this
in which, for every factor of the divisor, the value 0 has been inserted at the positions specified by ins_map
. Specifically, before each index appearing in ins_map
a number of zeroes equal to the size of the mapped piranha::symbol_fset will be inserted.
ins_map | the insertion map. |
args | the reference symbol set for this . |
this
zeroes at the positions specified by ins_map
.std::invalid_argument | in the following cases:
|
unspecified | any exception thrown by:
|
Definition at line 592 of file divisor.hpp.
|
inline |
Convert from msgpack object.
This method will convert the input msgpack object o
into this
, using the format f
. The method provides the basic exception safety guarantee.
o | the input msgpack::object . |
f | the desired piranha::msgpack_format. |
args | the reference piranha::symbol_fset. |
std::invalid_argument | if the deserialized divisor fails internal consistency checks, or if it is not compatible with args . |
unspecified | any exception thrown by piranha::msgpack_convert(). |
Definition at line 1025 of file divisor.hpp.
|
inline |
Pack in msgpack format.
Stream
satisfies piranha::is_msgpack_stream and the internal container type satisfies piranha::has_msgpack_pack.This method will pack this
in to p
using the format f.
p | the target msgpack::packer . |
f | the desired piranha::msgpack_format. |
args | the reference piranha::symbol_fset. |
std::invalid_argument | if args is not compatible with this . |
unspecified | any exception thrown by piranha::msgpack_pack(). |
Definition at line 1000 of file divisor.hpp.
|
inlinestatic |
Multiply terms with a divisor key.
Cf
satisfies piranha::has_mul3.Multiply t1
by t2
, storing the result in the only element of res
. If Cf
is an instance of piranha::mp_rational, then only the numerators of the coefficients will be multiplied.
This method offers the basic exception safety guarantee.
res | the return value. |
t1 | the first argument. |
t2 | the second argument. |
args | the reference piranha::symbol_fset. |
std::invalid_argument | if the key of t1 and/or the key of t2 are incompatible with args , or if the multiplication of the keys results in an exponent exceeding the allowed range. |
std::overflow_error | if the multiplication of the keys results in the container of the result key to be resized over an implementation-defined limit. |
unspecified | any exception thrown by:
|
Definition at line 826 of file divisor.hpp.
|
inline |
Inequality operator.
other | comparison argument. |
Definition at line 506 of file divisor.hpp.
|
default |
Copy assignment operator.
other | the assignment argument. |
this
.unspecified | any exception thrown by the assignment operator of piranha::hash_set. |
|
default |
Move assignment operator.
other | the assignment argument. |
this
.
|
inline |
Equality operator.
Two divisors are considered equal if:
other | comparison argument. |
true
if this
is equal to other
, false
otherwise. Definition at line 486 of file divisor.hpp.
|
inline |
Print to stream.
This method will print to the stream os
a text representation of this
.
os | the target stream. |
args | the reference symbol set for this . |
std::invalid_argument | if the number of variables in the terms of this is different from the size of args . |
unspecified | any exception thrown by printing to os piranha::divisor::value_type, strings or characters. |
Definition at line 619 of file divisor.hpp.
|
inline |
Print to stream in TeX mode.
This method will print to the stream os
a TeX representation of this
.
os | the target stream. |
args | the reference symbol set for this . |
std::invalid_argument | if the number of variables in the terms of this is different from the size of args . |
unspecified | any exception thrown by printing to os piranha::divisor::value_type, strings or characters. |
Definition at line 681 of file divisor.hpp.
|
inline |
Size.
Definition at line 447 of file divisor.hpp.
|
inline |
Split divisor.
This method will split this
into two parts: the first one will contain the terms of the divisor whose \( a_{i,j} \) values at the position p
are not zero, the second one the remaining terms.
p | the position of the splitting symbol. |
args | the reference piranha::symbol_fset. |
std::invalid_argument | if args is not compatible with this or p , or p is not less than the size of args . |
unspecified | any exception thrown by: |
Definition at line 940 of file divisor.hpp.
|
inline |
Trim.
This method is used in piranha::series::trim(). The input mask trim_mask
is a vector of boolean flags signalling (with nonzero values) symbols to be removed. The method will return a copy of this
in which the specified elements have been removed from each term of the divisor.
trim_mask | a mask indicating which elements will be removed. |
args | the reference piranha::symbol_fset. |
this
.std::invalid_argument | if this is not compatible with args or if the sizes of args and trim_mask differ. |
unspecified | any exception thrown by piranha::small_vector::push_back() or piranha::divisor::insert(). |
Definition at line 900 of file divisor.hpp.
|
inline |
Identify symbols that can be trimmed.
This method is used in piranha::series::trim(). The input parameter trim_mask
is a vector of boolean flags (i.e., a mask) which signals which elements in args
are candidates for trimming: a nonzero value means that the symbol at the corresponding position is a candidate for trimming, while a zero value means that the symbol is not a candidate for trimming. The method will set to zero in trim_mask
those symbols whose \( a_{i,j} \) in this
are not all zeroes.
trim_mask | a mask signalling candidate elements for trimming. |
args | the reference piranha::symbol_fset. |
std::invalid_argument | if this is not compatible with args , or if the sizes of trim_mask and args differ. |
unspecified | any exception thrown by piranha::math::is_zero(). |
Definition at line 863 of file divisor.hpp.