piranha  0.10
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
piranha::kronecker_monomial< T > Class Template Reference

Kronecker monomial class. More...

#include <piranha/kronecker_monomial.hpp>

Public Types

using value_type = T
 Alias for T.
 
using size_type = typename ka::size_type
 Size type. More...
 
using v_type = static_vector< T, 255u >
 Vector type used for temporary packing/unpacking.
 

Public Member Functions

 kronecker_monomial ()
 Default constructor. More...
 
 kronecker_monomial (const kronecker_monomial &)=default
 Defaulted copy constructor.
 
 kronecker_monomial (kronecker_monomial &&)=default
 Defaulted move constructor.
 
template<typename U , container_ctor_enabler< U > = 0>
 kronecker_monomial (const U &c)
 Constructor from container. More...
 
template<typename U , init_list_ctor_enabler< U > = 0>
 kronecker_monomial (std::initializer_list< U > list)
 Constructor from initializer list. More...
 
template<typename Iterator , it_ctor_enabler< Iterator > = 0>
 kronecker_monomial (Iterator begin, Iterator end)
 Constructor from range. More...
 
template<typename Iterator , it_ctor_enabler< Iterator > = 0>
 kronecker_monomial (Iterator begin, Iterator end, const symbol_fset &s)
 Constructor from range and symbol set. More...
 
 kronecker_monomial (const symbol_fset &)
 Constructor from set of symbols. More...
 
 kronecker_monomial (const kronecker_monomial &other, const symbol_fset &)
 Converting constructor. More...
 
 kronecker_monomial (const T &n)
 Constructor from T. More...
 
 ~kronecker_monomial ()
 Destructor.
 
kronecker_monomialoperator= (const kronecker_monomial &other)=default
 Copy assignment operator. More...
 
kronecker_monomialoperator= (kronecker_monomial &&other)=default
 Defaulted move assignment operator. More...
 
void set_int (const T &n)
 Set the internal integer instance. More...
 
get_int () const
 Get internal instance. More...
 
bool is_compatible (const symbol_fset &args) const noexcept
 Compatibility check. More...
 
bool is_zero (const symbol_fset &) const noexcept
 Zero check. More...
 
kronecker_monomial merge_symbols (const symbol_idx_fmap< symbol_fset > &ins_map, const symbol_fset &args) const
 Merge symbols. More...
 
bool is_unitary (const symbol_fset &) const
 Check if monomial is unitary. More...
 
degree_type degree (const symbol_fset &args) const
 Degree. More...
 
degree_type ldegree (const symbol_fset &args) const
 Low degree (equivalent to the degree). More...
 
degree_type degree (const symbol_idx_fset &p, const symbol_fset &args) const
 Partial degree. More...
 
degree_type ldegree (const symbol_idx_fset &p, const symbol_fset &args) const
 Partial low degree (equivalent to the partial degree). More...
 
std::size_t hash () const
 Hash value. More...
 
bool operator== (const kronecker_monomial &other) const
 Equality operator. More...
 
bool operator!= (const kronecker_monomial &other) const
 Inequality operator. More...
 
std::pair< bool, symbol_idxis_linear (const symbol_fset &args) const
 Detect linear monomial. More...
 
template<typename U , pow_enabler< U > = 0>
kronecker_monomial pow (const U &x, const symbol_fset &args) const
 Exponentiation. More...
 
v_type unpack (const symbol_fset &args) const
 Unpack internal integer instance. More...
 
void print (std::ostream &os, const symbol_fset &args) const
 Print. More...
 
void print_tex (std::ostream &os, const symbol_fset &args) const
 Print in TeX mode. More...
 
std::pair< T, kronecker_monomialpartial (const symbol_idx &p, const symbol_fset &args) const
 Partial derivative. More...
 
std::pair< T, kronecker_monomialintegrate (const std::string &s, const symbol_fset &args) const
 Integration. More...
 
template<typename U >
eval_type< U > evaluate (const std::vector< U > &values, const symbol_fset &args) const
 Evaluation. More...
 
template<typename U >
std::vector< std::pair< subs_type< U >, kronecker_monomial > > subs (const symbol_idx_fmap< U > &smap, const symbol_fset &args) const
 Substitution. More...
 
template<typename U >
std::vector< std::pair< ipow_subs_type< U >, kronecker_monomial > > ipow_subs (const symbol_idx &p, const integer &n, const U &x, const symbol_fset &args) const
 Substitution of integral power. More...
 
void trim_identify (std::vector< char > &trim_mask, const symbol_fset &args) const
 Identify symbols that can be trimmed. More...
 
kronecker_monomial trim (const std::vector< char > &trim_mask, const symbol_fset &args) const
 Trim. More...
 
bool operator< (const kronecker_monomial &other) const
 Comparison operator. More...
 
template<typename Stream , msgpack_pack_enabler< Stream > = 0>
void msgpack_pack (msgpack::packer< Stream > &packer, msgpack_format f, const symbol_fset &s) const
 Serialize in msgpack format. More...
 
template<typename U = kronecker_monomial, msgpack_convert_enabler< U > = 0>
void msgpack_convert (const msgpack::object &o, msgpack_format f, const symbol_fset &s)
 Deserialize from msgpack object. More...
 

Static Public Member Functions

template<typename Cf , multiply_enabler< Cf > = 0>
static void multiply (std::array< term< Cf, kronecker_monomial >, multiply_arity > &res, const term< Cf, kronecker_monomial > &t1, const term< Cf, kronecker_monomial > &t2, const symbol_fset &)
 Multiply terms with a Kronecker monomial key. More...
 

Static Public Attributes

static const std::size_t multiply_arity = 1u
 Arity of the multiply() method.
 

Detailed Description

template<typename T = std::make_signed<std::size_t>::type>
class piranha::kronecker_monomial< T >

Kronecker monomial class.

This class represents a multivariate monomial with integral exponents. The values of the exponents are packed in a signed integer using Kronecker substitution, using the facilities provided by piranha::kronecker_array.

This class satisfies the piranha::is_key, piranha::key_has_degree, piranha::key_has_ldegree and piranha::key_is_differentiable type traits.

Type requirements

T must be suitable for use in piranha::kronecker_array. The default type for T is the signed counterpart of std::size_t.

Exception safety guarantee

Unless otherwise specified, this class provides the strong exception safety guarantee for all operations.

Move semantics

The move semantics of this class are equivalent to the move semantics of C++ signed integral types.

Definition at line 119 of file kronecker_monomial.hpp.

Member Typedef Documentation

◆ size_type

template<typename T = std::make_signed<std::size_t>::type>
using piranha::kronecker_monomial< T >::size_type = typename ka::size_type

Size type.

Used to represent the number of variables in the monomial. Equivalent to the size type of piranha::kronecker_array.

Definition at line 134 of file kronecker_monomial.hpp.

Constructor & Destructor Documentation

◆ kronecker_monomial() [1/8]

template<typename T = std::make_signed<std::size_t>::type>
piranha::kronecker_monomial< T >::kronecker_monomial ( )
inline

Default constructor.

After construction all exponents in the monomial will be zero.

Definition at line 147 of file kronecker_monomial.hpp.

◆ kronecker_monomial() [2/8]

template<typename T = std::make_signed<std::size_t>::type>
template<typename U , container_ctor_enabler< U > = 0>
piranha::kronecker_monomial< T >::kronecker_monomial ( const U &  c)
inlineexplicit

Constructor from container.

Note
This constructor is enabled only if U satisfies piranha::has_input_begin_end, and the value type of the iterator type of U can be safely cast to T.

This constructor will build internally a vector of values from the input container c, encode it and assign the result to the internal integer instance. The value type of the container is converted to T using piranha::safe_cast().

Parameters
cthe input container.
Exceptions
unspecifiedany exception thrown by kronecker_monomial::kronecker_monomial(Iterator, Iterator).

Definition at line 188 of file kronecker_monomial.hpp.

◆ kronecker_monomial() [3/8]

template<typename T = std::make_signed<std::size_t>::type>
template<typename U , init_list_ctor_enabler< U > = 0>
piranha::kronecker_monomial< T >::kronecker_monomial ( std::initializer_list< U >  list)
inlineexplicit

Constructor from initializer list.

Note
This constructor is enabled only if U can be safely cast to T.
Parameters
listthe input initializer list.
Exceptions
unspecifiedany exception thrown by kronecker_monomial::kronecker_monomial(Iterator, Iterator).

Definition at line 207 of file kronecker_monomial.hpp.

◆ kronecker_monomial() [4/8]

template<typename T = std::make_signed<std::size_t>::type>
template<typename Iterator , it_ctor_enabler< Iterator > = 0>
piranha::kronecker_monomial< T >::kronecker_monomial ( Iterator  begin,
Iterator  end 
)
inlineexplicit

Constructor from range.

Note
This constructor is enabled only if Iterator is an input iterator whose value type is safely convertible to T.

This constructor will build internally a vector of values from the input iterators, encode it and assign the result to the internal integer instance. The value type of the iterator is converted to T using piranha::safe_cast().

Parameters
beginthe beginning of the range.
endthe end of the range.
Exceptions
unspecifiedany exception thrown by:

Definition at line 239 of file kronecker_monomial.hpp.

◆ kronecker_monomial() [5/8]

template<typename T = std::make_signed<std::size_t>::type>
template<typename Iterator , it_ctor_enabler< Iterator > = 0>
piranha::kronecker_monomial< T >::kronecker_monomial ( Iterator  begin,
Iterator  end,
const symbol_fset s 
)
inlineexplicit

Constructor from range and symbol set.

Note
This constructor is enabled only if Iterator is an input iterator whose value type is safely convertible to T.

This constructor is identical to the constructor from range. In addition, after construction it will also check that the distance between begin and end is equal to the size of s.

Parameters
beginthe beginning of the range.
endthe end of the range.
sthe reference piranha::symbol_fset.
Exceptions
std::invalid_argumentif the distance between begin and end is different from the size of s.
unspecifiedany exception thrown by kronecker_monomial::kronecker_monomial(Iterator, Iterator)

Definition at line 261 of file kronecker_monomial.hpp.

◆ kronecker_monomial() [6/8]

template<typename T = std::make_signed<std::size_t>::type>
piranha::kronecker_monomial< T >::kronecker_monomial ( const symbol_fset )
inlineexplicit

Constructor from set of symbols.

After construction all exponents in the monomial will be zero.

Definition at line 276 of file kronecker_monomial.hpp.

◆ kronecker_monomial() [7/8]

template<typename T = std::make_signed<std::size_t>::type>
piranha::kronecker_monomial< T >::kronecker_monomial ( const kronecker_monomial< T > &  other,
const symbol_fset  
)
inlineexplicit

Converting constructor.

This constructor is for use when converting from one term type to another in piranha::series. It will set the internal integer instance to the same value of other.

Parameters
otherthe construction argument.

Definition at line 284 of file kronecker_monomial.hpp.

◆ kronecker_monomial() [8/8]

template<typename T = std::make_signed<std::size_t>::type>
piranha::kronecker_monomial< T >::kronecker_monomial ( const T &  n)
inlineexplicit

Constructor from T.

This constructor will initialise the internal integer instance to n.

Parameters
nthe value that will be used to construct the internal integer instance.

Definition at line 292 of file kronecker_monomial.hpp.

Member Function Documentation

◆ degree() [1/2]

template<typename T = std::make_signed<std::size_t>::type>
degree_type piranha::kronecker_monomial< T >::degree ( const symbol_fset args) const
inline

Degree.

The type returned by this method is the type resulting from the addition of two instances of T.

Parameters
argsthe reference piranha::symbol_fset.
Returns
the degree of the monomial.
Exceptions
std::overflow_errorif the computation of the degree overflows.
unspecifiedany exception thrown by unpack().

Definition at line 432 of file kronecker_monomial.hpp.

◆ degree() [2/2]

template<typename T = std::make_signed<std::size_t>::type>
degree_type piranha::kronecker_monomial< T >::degree ( const symbol_idx_fset p,
const symbol_fset args 
) const
inline

Partial degree.

Partial degree of the monomial: only the symbols at the positions specified by p are considered. The type returned by this method is the type resulting from the addition of two instances of T.

Parameters
pthe positions of the symbols to be considered in the calculation of the degree.
argsthe reference piranha::symbol_fset.
Returns
the summation of the exponents of the monomial at the positions specified by p.
Exceptions
std::invalid_argumentif the last element of p, if existing, is not less than the size of args.
std::overflow_errorif the computation of the degree overflows.
unspecifiedany exception thrown by unpack().

Definition at line 473 of file kronecker_monomial.hpp.

◆ evaluate()

template<typename T = std::make_signed<std::size_t>::type>
template<typename U >
eval_type<U> piranha::kronecker_monomial< T >::evaluate ( const std::vector< U > &  values,
const symbol_fset args 
) const
inline

Evaluation.

Note
This method is available only if U satisfies the following requirements:
  • it can be used in piranha::math::pow() with the monomial exponents as powers, yielding a type eval_type,
  • eval_type is constructible from int,
  • eval_type is multipliable in place,
  • eval_type satisfies piranha::is_returnable.

The return value will be built by iteratively applying piranha::math::pow() using the values provided by values as bases and the values in the monomial as exponents. If the size of the monomial is zero, 1 will be returned.

Parameters
valuesthe values will be used for the evaluation.
argsthe reference piranha::symbol_fset.
Returns
the result of evaluating this with the values provided in values.
Exceptions
std::invalid_argumentif the sizes of values and args differ.
unspecifiedany exception thrown by:

Definition at line 858 of file kronecker_monomial.hpp.

◆ get_int()

template<typename T = std::make_signed<std::size_t>::type>
T piranha::kronecker_monomial< T >::get_int ( ) const
inline

Get internal instance.

Returns
value of the internal integer instance.

Definition at line 327 of file kronecker_monomial.hpp.

◆ hash()

template<typename T = std::make_signed<std::size_t>::type>
std::size_t piranha::kronecker_monomial< T >::hash ( ) const
inline

Hash value.

Returns
the internal integer instance, cast to std::size_t.

Definition at line 543 of file kronecker_monomial.hpp.

◆ integrate()

template<typename T = std::make_signed<std::size_t>::type>
std::pair<T, kronecker_monomial> piranha::kronecker_monomial< T >::integrate ( const std::string &  s,
const symbol_fset args 
) const
inline

Integration.

This method will return the antiderivative of this with respect to the symbol s. The result is a pair consisting of the exponent associated to s increased by one and the monomial itself after integration. If s is not in args, the returned monomial will have an extra exponent set to 1 in the same position s would have if it were added to args. If the exponent corresponding to s is -1, an error will be produced.

Parameters
sthe symbol with respect to which the integration will be calculated.
argsthe reference piranha::symbol_fset.
Returns
the result of the integration.
Exceptions
std::invalid_argumentif the exponent associated to s is -1.
std::overflow_errorif the integration leads to integer overflow.
unspecifiedany exception thrown by:

Definition at line 780 of file kronecker_monomial.hpp.

◆ ipow_subs()

template<typename T = std::make_signed<std::size_t>::type>
template<typename U >
std::vector<std::pair<ipow_subs_type<U>, kronecker_monomial> > piranha::kronecker_monomial< T >::ipow_subs ( const symbol_idx p,
const integer n,
const U &  x,
const symbol_fset args 
) const
inline

Substitution of integral power.

Note
This method is enabled only if:

This method will substitute the n-th power of the symbol at the position p with the quantity x. The return value is a vector containing a single pair in which the first element is the result of the substitution, and the second element the monomial after the substitution has been performed. If p is not less than the size of args, the return value will be (1,this) (i.e., the monomial is unchanged and the substitution yields 1).

The method will substitute also powers higher than n in absolute value. For instance, the substitution of y**2 with a in the monomial y**7 will produce a**3 * y, and the substitution of y**-2 with a in the monomial y**-7 will produce a**3 * y**-1.

Parameters
pthe position of the symbol that will be substituted.
nthe integral power that will be substituted.
xthe quantity that will be substituted.
argsthe reference piranha::symbol_fset.
Returns
the result of substituting x for the n-th power of the symbol at the position p.
Exceptions
std::invalid_argumentis n is zero.
unspecifiedany exception thrown by:

Definition at line 1003 of file kronecker_monomial.hpp.

◆ is_compatible()

template<typename T = std::make_signed<std::size_t>::type>
bool piranha::kronecker_monomial< T >::is_compatible ( const symbol_fset args) const
inlinenoexcept

Compatibility check.

A monomial is considered incompatible with a piranha::symbol_fset if any of these conditions holds:

Otherwise, the monomial is considered to be incompatible.

Parameters
argsthe reference piranha::symbol_fset.
Returns
compatibility flag for the monomial.

Definition at line 346 of file kronecker_monomial.hpp.

◆ is_linear()

template<typename T = std::make_signed<std::size_t>::type>
std::pair<bool, symbol_idx> piranha::kronecker_monomial< T >::is_linear ( const symbol_fset args) const
inline

Detect linear monomial.

If the monomial is linear in a variable (i.e., all exponents are zero apart from a single unitary exponent), then this method will return a pair formed by the true value and the position, in args, of the linear variable. Otherwise, the returned value will be a pair formed by the false value and an unspecified position value.

Parameters
argsthe reference piranha::symbol_fset.
Returns
a pair indicating if the monomial is linear.
Exceptions
unspecifiedany exception thrown by unpack().

Definition at line 581 of file kronecker_monomial.hpp.

◆ is_unitary()

template<typename T = std::make_signed<std::size_t>::type>
bool piranha::kronecker_monomial< T >::is_unitary ( const symbol_fset ) const
inline

Check if monomial is unitary.

Returns
true if all the exponents are zero, false otherwise.

Definition at line 409 of file kronecker_monomial.hpp.

◆ is_zero()

template<typename T = std::make_signed<std::size_t>::type>
bool piranha::kronecker_monomial< T >::is_zero ( const symbol_fset ) const
inlinenoexcept

Zero check.

A monomial is never zero.

Returns
false.

Definition at line 371 of file kronecker_monomial.hpp.

◆ ldegree() [1/2]

template<typename T = std::make_signed<std::size_t>::type>
degree_type piranha::kronecker_monomial< T >::ldegree ( const symbol_fset args) const
inline

Low degree (equivalent to the degree).

Parameters
argsthe reference piranha::symbol_fset.
Returns
the output of degree(const symbol_fset &) const.
Exceptions
unspecifiedany exception thrown by degree(const symbol_fset &) const.

Definition at line 453 of file kronecker_monomial.hpp.

◆ ldegree() [2/2]

template<typename T = std::make_signed<std::size_t>::type>
degree_type piranha::kronecker_monomial< T >::ldegree ( const symbol_idx_fset p,
const symbol_fset args 
) const
inline

Partial low degree (equivalent to the partial degree).

Parameters
pthe positions of the symbols to be considered in the calculation of the degree.
argsthe reference piranha::symbol_fset.
Returns
the output of degree(const symbol_idx_fset &, const symbol_fset &) const.
Exceptions
unspecifiedany exception thrown by degree(const symbol_idx_fset &, const symbol_fset &) const.

Definition at line 499 of file kronecker_monomial.hpp.

◆ merge_symbols()

template<typename T = std::make_signed<std::size_t>::type>
kronecker_monomial piranha::kronecker_monomial< T >::merge_symbols ( const symbol_idx_fmap< symbol_fset > &  ins_map,
const symbol_fset args 
) const
inline

Merge symbols.

This method will return a copy of this in which 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.

For instance, given a piranha::kronecker_monomial containing the values [1,2,3,4], a symbol set args containing ["c","e","g","h"] and an insertion map ins_map containing the pairs [(0,["a","b"]),(1,["d"]),(2,["f"]),(4,["i"])], the output of this method will be [0,0,1,0,2,0,3,4,0]. That is, the symbols appearing in ins_map are merged into this with a value of zero at the specified positions.

Parameters
ins_mapthe insertion map.
argsthe reference symbol set for this.
Returns
a piranha::kronecker_monomial resulting from inserting into this zeroes at the positions specified by ins_map.
Exceptions
std::invalid_argumentin the following cases:
  • the size of ins_map is zero,
  • the last index in ins_map is greater than the size of args.
unspecifiedany exception thrown by:

Definition at line 401 of file kronecker_monomial.hpp.

◆ msgpack_convert()

template<typename T = std::make_signed<std::size_t>::type>
template<typename U = kronecker_monomial, msgpack_convert_enabler< U > = 0>
void piranha::kronecker_monomial< T >::msgpack_convert ( const msgpack::object &  o,
msgpack_format  f,
const symbol_fset s 
)
inline

Deserialize from msgpack object.

Note
This method is activated only if both T and piranha::kronecker_monomial::v_type satisfy piranha::has_msgpack_convert.

This method will deserialize o into this. In binary mode, no check is performed on the content of o, and calling this method will result in undefined behaviour if o does not contain a monomial serialized via msgpack_pack().

Parameters
omsgpack object that will be deserialized.
fserialization format.
sreference piranha::symbol_fset.
Exceptions
std::invalid_argumentif the size of the deserialized array differs from the size of s.
unspecifiedany exception thrown by:

Definition at line 1151 of file kronecker_monomial.hpp.

◆ msgpack_pack()

template<typename T = std::make_signed<std::size_t>::type>
template<typename Stream , msgpack_pack_enabler< Stream > = 0>
void piranha::kronecker_monomial< T >::msgpack_pack ( msgpack::packer< Stream > &  packer,
msgpack_format  f,
const symbol_fset s 
) const
inline

Serialize in msgpack format.

Note
This method is activated only if Stream satisfies piranha::is_msgpack_stream and both T and piranha::kronecker_monomial::v_type satisfy piranha::has_msgpack_pack.

This method will pack this into packer. The packed object is the internal integral instance in binary format, an array of exponents in portable format.

Parameters
packerthe target packer.
fthe serialization format.
sreference piranha::symbol_fset.
Exceptions
unspecifiedany exception thrown by unpack() or piranha::msgpack_pack().

Definition at line 1122 of file kronecker_monomial.hpp.

◆ multiply()

template<typename T = std::make_signed<std::size_t>::type>
template<typename Cf , multiply_enabler< Cf > = 0>
static void piranha::kronecker_monomial< T >::multiply ( std::array< term< Cf, kronecker_monomial< T > >, multiply_arity > &  res,
const term< Cf, kronecker_monomial< T > > &  t1,
const term< Cf, kronecker_monomial< T > > &  t2,
const symbol_fset  
)
inlinestatic

Multiply terms with a Kronecker monomial key.

Note
This method is enabled only if Cf satisfies piranha::has_mul3.

Multiply t1 by t2, storing the result in the only element of res. This method offers the basic exception safety guarantee. If Cf is an instance of piranha::mp_rational, then only the numerators of the coefficients will be multiplied.

Note that the key of the return value is generated directly from the addition of the values of the input keys. No check is performed for overflow of either the limits of the integral type or the limits of the Kronecker codification.

Parameters
resthe return value.
t1the first argument.
t2the second argument.
Exceptions
unspecifiedany exception thrown by piranha::math::mul3().

Definition at line 530 of file kronecker_monomial.hpp.

◆ operator!=()

template<typename T = std::make_signed<std::size_t>::type>
bool piranha::kronecker_monomial< T >::operator!= ( const kronecker_monomial< T > &  other) const
inline

Inequality operator.

Parameters
otherthe comparison argument.
Returns
the opposite of operator==().

Definition at line 564 of file kronecker_monomial.hpp.

◆ operator<()

template<typename T = std::make_signed<std::size_t>::type>
bool piranha::kronecker_monomial< T >::operator< ( const kronecker_monomial< T > &  other) const
inline

Comparison operator.

Parameters
othercomparison argument.
Returns
true if the internal integral value of this is less than the internal integral value of other, false otherwise.

Definition at line 1089 of file kronecker_monomial.hpp.

◆ operator=() [1/2]

template<typename T = std::make_signed<std::size_t>::type>
kronecker_monomial& piranha::kronecker_monomial< T >::operator= ( const kronecker_monomial< T > &  other)
default

Copy assignment operator.

Parameters
otherthe assignment argument.
Returns
a reference to this.

◆ operator=() [2/2]

template<typename T = std::make_signed<std::size_t>::type>
kronecker_monomial& piranha::kronecker_monomial< T >::operator= ( kronecker_monomial< T > &&  other)
default

Defaulted move assignment operator.

Parameters
otherthe assignment argument.
Returns
a reference to this.

◆ operator==()

template<typename T = std::make_signed<std::size_t>::type>
bool piranha::kronecker_monomial< T >::operator== ( const kronecker_monomial< T > &  other) const
inline

Equality operator.

Parameters
otherthe comparison argument.
Returns
true if the internal integral instance of this is equal to the integral instance of other, false otherwise.

Definition at line 554 of file kronecker_monomial.hpp.

◆ partial()

template<typename T = std::make_signed<std::size_t>::type>
std::pair<T, kronecker_monomial> piranha::kronecker_monomial< T >::partial ( const symbol_idx p,
const symbol_fset args 
) const
inline

Partial derivative.

This method will return the partial derivative of this with respect to the symbol at the position indicated by p. The result is a pair consisting of the exponent associated to p before differentiation and the monomial itself after differentiation. If p is not smaller than the size of args or if its corresponding exponent is zero, the returned pair will be (0,kronecker_monomial{args}).

Parameters
pthe position of the symbol with respect to which the differentiation will be calculated.
argsthe reference piranha::symbol_fset.
Returns
the result of the differentiation.
Exceptions
std::overflow_errorif the computation of the derivative causes a negative overflow.
unspecifiedany exception thrown by:

Definition at line 740 of file kronecker_monomial.hpp.

◆ pow()

template<typename T = std::make_signed<std::size_t>::type>
template<typename U , pow_enabler< U > = 0>
kronecker_monomial piranha::kronecker_monomial< T >::pow ( const U &  x,
const symbol_fset args 
) const
inline

Exponentiation.

This method will return a monomial corresponding to this raised to the x-th power. The exponentiation is computed via the multiplication of the exponents by x. The multiplication is performed in different ways, depending on the type U:

  • if U is a C++ integral type, then the multiplication is checked for overflow; otherwise,
  • if the multiplication of T by U results in another type T2, then the multiplication is performed via the binary multiplication operator and the result is cast back to T via piranha::safe_cast().

If the type U cannot be used as indicated above (e.g., because the multiplication of T by U is not available, or T2 does not support piranha::safe_cast()), then the method will be disabled.

Parameters
xthe exponent.
argsthe reference piranha::symbol_fset.
Returns
this to the power of x.
Exceptions
std::overflow_errorif U is an integral type and the exponentiation causes overflow.
unspecifiedany exception thrown by:

Definition at line 635 of file kronecker_monomial.hpp.

◆ print()

template<typename T = std::make_signed<std::size_t>::type>
void piranha::kronecker_monomial< T >::print ( std::ostream &  os,
const symbol_fset args 
) const
inline

Print.

This method will print to stream a human-readable representation of the monomial.

Parameters
osthe target stream.
argsthe reference piranha::symbol_fset.
Exceptions
unspecifiedany exception thrown by unpack() or by streaming instances of T.

Definition at line 669 of file kronecker_monomial.hpp.

◆ print_tex()

template<typename T = std::make_signed<std::size_t>::type>
void piranha::kronecker_monomial< T >::print_tex ( std::ostream &  os,
const symbol_fset args 
) const
inline

Print in TeX mode.

This method will print to stream a TeX representation of the monomial.

Parameters
osthe target stream.
argsthe reference piranha::symbol_fset.
Exceptions
unspecifiedany exception thrown by unpack() or by streaming instances of T.

Definition at line 697 of file kronecker_monomial.hpp.

◆ set_int()

template<typename T = std::make_signed<std::size_t>::type>
void piranha::kronecker_monomial< T >::set_int ( const T &  n)
inline

Set the internal integer instance.

Parameters
nthe value to which the internal integer instance will be set.

Definition at line 319 of file kronecker_monomial.hpp.

◆ subs()

template<typename T = std::make_signed<std::size_t>::type>
template<typename U >
std::vector<std::pair<subs_type<U>, kronecker_monomial> > piranha::kronecker_monomial< T >::subs ( const symbol_idx_fmap< U > &  smap,
const symbol_fset args 
) const
inline

Substitution.

Note
This method is available only if U satisfies the following requirements:
  • it can be used in piranha::math::pow() with the monomial exponents as powers, yielding a type subs_type,
  • subs_type is constructible from int,
  • subs_type is multipliable in place,
  • subs_type satisfies piranha::is_returnable.

This method will substitute the symbols at the positions specified in the keys of smap with the mapped values. The return value is a vector containing one pair in which the first element is the result of the substitution (i.e., the product of the values of smap raised to the corresponding exponents in the monomial), and the second element is the monomial after the substitution has been performed (i.e., with the exponents at the positions specified by the keys of smap set to zero). If smap is empty, the return value will be (1,this) (i.e., the monomial is unchanged and the substitution yields 1).

For instance, given the monomial [2,3,4], the reference piranha::symbol_fset ["x","y","z"] and the substitution map [(0,1),(2,-3)], then the return value will be a vector containing the single pair (81,[0,3,0]).

Parameters
smapthe map relating the positions of the symbols to be substituted to the values they will be substituted with.
argsthe reference piranha::symbol_fset.
Returns
the result of the substitution.
Exceptions
std::invalid_argumentif the last element of the substitution map is not smaller than the size of args.
unspecifiedany exception thrown by:

Definition at line 923 of file kronecker_monomial.hpp.

◆ trim()

template<typename T = std::make_signed<std::size_t>::type>
kronecker_monomial piranha::kronecker_monomial< T >::trim ( const std::vector< char > &  trim_mask,
const symbol_fset args 
) const
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) elements of this to be removed. The method will return a copy of this in which the specified elements have been removed.

For instance, if this contains the values [0,5,3,0,4] and trim_mask contains the values [false,false,false,true,false], then the output of this method will be the array of values [0,5,3,4] (that is, the fourth element has been removed as indicated by a true value in trim_mask's fourth element).

Parameters
trim_maska mask indicating which element will be removed.
argsthe reference piranha::symbol_fset.
Returns
a trimmed copy of this.
Exceptions
std::invalid_argumentif the size of trim_mask differs from the size of args.
unspecifiedany exception thrown by unpack() or piranha::static_vector::push_back().

Definition at line 1078 of file kronecker_monomial.hpp.

◆ trim_identify()

template<typename T = std::make_signed<std::size_t>::type>
void piranha::kronecker_monomial< T >::trim_identify ( std::vector< char > &  trim_mask,
const symbol_fset args 
) const
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 (i.e., a zero value means that the symbol at the corresponding position in args is not a candidate for trimming, while a nonzero value means that the symbol is a candidate for trimming). This method will set to zero those values in trim_mask for which the corresponding element in this is nonzero.

For instance, if this contains the values [0,5,3,0,4] and trim_mask originally contains the values [1,1,0,1,0], after a call to this method trim_mask will contain [1,0,0,1,0] (that is, the second element was set from 1 to 0 as the corresponding element in this has a value of 5 and thus must not be trimmed).

Parameters
trim_maska mask signalling candidate elements for trimming.
argsthe reference piranha::symbol_fset.
Exceptions
std::invalid_argumentif the size of trim_mask differs from the size of args.
unspecifiedany exception thrown by unpack().

Definition at line 1054 of file kronecker_monomial.hpp.

◆ unpack()

template<typename T = std::make_signed<std::size_t>::type>
v_type piranha::kronecker_monomial< T >::unpack ( const symbol_fset args) const
inline

Unpack internal integer instance.

This method will decode the internal integral instance into a piranha::static_vector of size equal to the size of args.

Parameters
argsthe reference piranha::symbol_fset.
Returns
piranha::static_vector containing the result of decoding the internal integral instance via piranha::kronecker_array.
Exceptions
std::invalid_argumentif the size of args is larger than the maximum size of piranha::static_vector.
unspecifiedany exception thrown by piranha::kronecker_array::decode().

Definition at line 656 of file kronecker_monomial.hpp.


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