piranha  0.10
piranha::series_operators Class Reference

Series operators. More...

#include <piranha/series.hpp>

Inheritance diagram for piranha::series_operators:
[legend]

## Friends

template<typename T , typename... U>
binary_add_type< T, U... > operator+ (T &&x, U &&... y)

template<typename T , typename... U, in_place_add_enabler< T, U... > = 0>
T & operator+= (T &x, U &&... y)

template<typename T , typename... U>
binary_sub_type< T, U... > operator- (T &&x, U &&... y)
Binary subtraction involving piranha::series. More...

template<typename T , typename... U, in_place_sub_enabler< T, U... > = 0>
T & operator-= (T &x, U &&... y)
In-place subtraction involving piranha::series. More...

template<typename T , typename... U>
binary_mul_type< T, U... > operator* (T &&x, U &&... y)
Binary multiplication involving piranha::series. More...

template<typename T , typename... U, in_place_mul_enabler< T, U... > = 0>
T & operator*= (T &x, U &&... y)
In-place multiplication involving piranha::series. More...

template<typename T , typename... U>
binary_div_type< T, U... > operator/ (T &&x, U &&... y)
Binary division involving piranha::series. More...

template<typename T , typename... U, in_place_div_enabler< T, U... > = 0>
T & operator/= (T &x, U &&... y)
In-place division involving piranha::series. More...

template<typename T , typename... U, eq_enabler< T, U... > = 0>
bool operator== (const T &x, const U &... y)
Equality operator involving piranha::series. More...

template<typename T , typename... U, eq_enabler< T, U... > = 0>
bool operator!= (const T &x, const U &... y)
Inequality operator involving piranha::series. More...

## Detailed Description

Series operators.

This class contains the arithmetic and comparison operator overloads for piranha::series instances. The operators are implemented as inline friend functions and they will be found via argument-dependent name lookup when at least one of the two operands is an instance of piranha::series.

The operators defined here, similarly to the builtin operators in C++, promote one or both operands to a common type, if necessary, before actually performing the operation. The promotion rules are dependent on the recursion indices and coefficient types of the series, and they rely on the series rebinding mechanism to promote a series as needed (see piranha::series_is_rebindable and piranha::series_recursion_index).

These are the scenarios handled by the type promotion mechanism:

• the two arguments are of the same series type and the operator on the coefficient type of the series results in the same coefficient type. In this case there is no type promotion;
• both series arguments have the same recursion index, different coefficients, and the operator on the coefficient types results in the first (resp. second) coefficient type. In this case the result of the operations is the first (resp. second) series type;
• both series arguments have the same recursion index, different coefficients, and the operator on the coefficient types results in something other than the first or second coefficient type. In this case both series are promoted to a type resulting from the rebinding of the two series to the resulting coefficient type;
• the first (resp. second) argument has recursion index greater than the second (resp. first) one, and the result type of the operator on the coefficient type of the first (resp. second) argument and the second (resp. first) argument is the coefficient type of the first (resp. second) argument. In this case, the second (resp. first) argument is promoted to the first (resp. second);
• the first (resp. second) argument has recursion index greater than the second (resp. first) one, and the result type of the operator on the coefficient type of the first (resp. second) argument and the second (resp. first) argument is something other than the coefficient type of the first (resp. second) argument. In this case, both arguments are promoted to a type resulting from the rebinding of the first (resp. second) argument to the resulting coefficient type.

If any necessary conversion is not possible, either because the series are not rebindable or they do not support the needed constructors, the operators are disabled. The operators are also disabled if any operation needed by the implementation is not supported, or if an ambiguity arises in the type promotion algorithm (e.g., two series with same recursion index, same coefficient type which does not trigger any promotion, and different key types).

A few things to note about the operators implemented within this class:

• in case two series arguments have different symbol sets, either one or both series will be copied in a new series in which the symbols have been merged, and the operation will be performed on those series instead;
• in-place arithmetic operators are implemented as binary operators plus move-assignment (and they are thus disabled if either the corresponding binary operation or the assignment are invalid);
• series multiplication requires the coefficient types to be multipliable and a valid specialisation of piranha::series_multiplier for the promoted series type;
• division is implemented only when it reduces to coefficient division (true series division may be implemented in specific series types, e.g., piranha::polynomial);
• the comparison operators will use operator+() on the coefficient types to determine if any type promotion is necessary before performing the comparison.

Definition at line 539 of file series.hpp.

## ◆ operator!=

template<typename T , typename... U, eq_enabler< T, U... > = 0>
 bool operator!= ( const T & x, const U &... y )
friend

Inequality operator involving piranha::series.

Note
This operator is enabled only if the algorithm outlined in piranha::series_operators is supported by the arguments.
Parameters
 x first argument. y second argument.
Returns
true if x != y, false otherwise.
Exceptions
 unspecified any exception thrown by operator==().

Definition at line 1225 of file series.hpp.

## ◆ operator*

template<typename T , typename... U>
 binary_mul_type operator* ( T && x, U &&... y )
friend

Binary multiplication involving piranha::series.

Note
This operator is enabled only if the algorithm outlined in piranha::series_operators is supported by the arguments.
Parameters
 x first argument. y second argument.
Returns
x * y.
Exceptions
 unspecified any exception thrown by: any invoked series, coefficient or key constructor, construction, assignment and other operations on piranha::symbol_fset, piranha::series::insert(), the call operator of piranha::series_multiplier.

Definition at line 1124 of file series.hpp.

## ◆ operator*=

template<typename T , typename... U, in_place_mul_enabler< T, U... > = 0>
 T& operator*= ( T & x, U &&... y )
friend

In-place multiplication involving piranha::series.

Note
This operator is enabled only if the algorithm outlined in piranha::series_operators is supported by the arguments.
Parameters
 x first argument. y second argument.
Returns
reference to this.
Exceptions
 unspecified any exception thrown by operator*().

Definition at line 1142 of file series.hpp.

## ◆ operator+

template<typename T , typename... U>
 binary_add_type operator+ ( T && x, U &&... y )
friend

Note
This operator is enabled only if the algorithm outlined in piranha::series_operators is supported by the arguments.
Parameters
 x first argument. y second argument.
Returns
x + y.
Exceptions
 unspecified any exception thrown by: any invoked series, coefficient or key constructor, construction, assignment and other operations on piranha::symbol_fset, piranha::series::insert().

Definition at line 1044 of file series.hpp.

## ◆ operator+=

template<typename T , typename... U, in_place_add_enabler< T, U... > = 0>
 T& operator+= ( T & x, U &&... y )
friend

Note
This operator is enabled only if the algorithm outlined in piranha::series_operators is supported by the arguments.
Parameters
 x first argument. y second argument.
Returns
reference to this.
Exceptions
 unspecified any exception thrown by operator+().

Definition at line 1062 of file series.hpp.

## ◆ operator-

template<typename T , typename... U>
 binary_sub_type operator- ( T && x, U &&... y )
friend

Binary subtraction involving piranha::series.

Note
This operator is enabled only if the algorithm outlined in piranha::series_operators is supported by the arguments.
Parameters
 x first argument. y second argument.
Returns
x - y.
Exceptions
 unspecified any exception thrown by: any invoked series, coefficient or key constructor, construction, assignment and other operations on piranha::symbol_fset, piranha::series::insert(), piranha::series::negate().

Definition at line 1084 of file series.hpp.

## ◆ operator-=

template<typename T , typename... U, in_place_sub_enabler< T, U... > = 0>
 T& operator-= ( T & x, U &&... y )
friend

In-place subtraction involving piranha::series.

Note
This operator is enabled only if the algorithm outlined in piranha::series_operators is supported by the arguments.
Parameters
 x first argument. y second argument.
Returns
reference to this.
Exceptions
 unspecified any exception thrown by operator-().

Definition at line 1102 of file series.hpp.

## ◆ operator/

template<typename T , typename... U>
 binary_div_type operator/ ( T && x, U &&... y )
friend

Binary division involving piranha::series.

Note
This operator is enabled only if the algorithm outlined in piranha::series_operators is supported by the arguments.
Parameters
 x first argument. y second argument.
Returns
x / y.
Exceptions
 unspecified any exception thrown by: any invoked series, coefficient, term and key constructor, piranha::series::insert(), piranha::hash_set::erase(), the division operator on the coefficient type of the result.

Definition at line 1164 of file series.hpp.

## ◆ operator/=

template<typename T , typename... U, in_place_div_enabler< T, U... > = 0>
 T& operator/= ( T & x, U &&... y )
friend

In-place division involving piranha::series.

Note
This operator is enabled only if the algorithm outlined in piranha::series_operators is supported by the arguments.
Parameters
 x first argument. y second argument.
Returns
reference to this.
Exceptions
 unspecified any exception thrown by operator/().

Definition at line 1182 of file series.hpp.

## ◆ operator==

template<typename T , typename... U, eq_enabler< T, U... > = 0>
 bool operator== ( const T & x, const U &... y )
friend

Equality operator involving piranha::series.

Note
This operator is enabled only if the algorithm outlined in piranha::series_operators is supported by the arguments.

Two series are considered equal if they have the same number of terms and all terms in one series appear in the other.

Parameters
 x first argument. y second argument.
Returns
true if x == y, false otherwise.
Exceptions
 unspecified any exception thrown by: piranha::hash_set::find(), the comparison operator of the coefficient type, any invoked series, coefficient or key constructor, construction, assignment and other operations on piranha::symbol_fset.

Definition at line 1207 of file series.hpp.

The documentation for this class was generated from the following file: