piranha  0.10
Public Types | Static Public Member Functions | List of all members
piranha::kronecker_array< SignedInteger > Class Template Reference

Kronecker array. More...

#include <piranha/kronecker_array.hpp>

Public Types

typedef SignedInteger int_type
 Signed integer type used for encoding.
 
typedef std::size_t size_type
 Size type. More...
 

Static Public Member Functions

static const limits_type & get_limits ()
 Get the limits of the Kronecker codification. More...
 
template<typename Vector >
static int_type encode (const Vector &v)
 Encode vector. More...
 
template<typename Vector >
static void decode (Vector &retval, const int_type &n)
 Decode into vector. More...
 

Detailed Description

template<typename SignedInteger>
class piranha::kronecker_array< SignedInteger >

Kronecker array.

This class offers static methods to encode (and decode) arrays of integral values as instances of SignedInteger type, using a technique known as "Kronecker substitution".

Depending on the bit width and numerical limits of SignedInteger, the class will be able to operate on vectors of integers up to a certain dimension and within certain bounds on the vector's components. Such limits can be queried with the get_limits() static method.

Type requirements

SignedInteger must be a C++ signed integral type.

Exception safety guarantee

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

Move semantics

This class does not have any non-static data members, hence it has trivial move semantics.

Definition at line 87 of file kronecker_array.hpp.

Member Typedef Documentation

◆ size_type

template<typename SignedInteger >
typedef std::size_t piranha::kronecker_array< SignedInteger >::size_type

Size type.

Equivalent to std::size_t, used to represent the dimension of the vectors on which the class can operate.

Definition at line 111 of file kronecker_array.hpp.

Member Function Documentation

◆ decode()

template<typename SignedInteger >
template<typename Vector >
static void piranha::kronecker_array< SignedInteger >::decode ( Vector &  retval,
const int_type n 
)
inlinestatic

Decode into vector.

Note
This method can be called only if Vector is a type with a vector-like interface. Specifically, it must have a size() method and overloaded mutable index operator.

Decode input code n into retval. If the value type of Vector is not SignedInteger, the components decoded from n will be converted to the value type of Vector using piranha::safe_cast().

In case of exceptions, retval will be left in a valid but undefined state.

Parameters
retvalobject that will store the decoded vector.
ncode to be decoded.
Exceptions
std::invalid_argumentif any of these conditions hold:
  • the size of retval is equal to or greater than the size of the output of get_limits(),
  • the size of retval is zero and n is not zero,
  • n is out of the allowed bounds reported by get_limits().
unspecifiedany exception thrown by piranha::safe_cast().

Definition at line 330 of file kronecker_array.hpp.

◆ encode()

template<typename SignedInteger >
template<typename Vector >
static int_type piranha::kronecker_array< SignedInteger >::encode ( const Vector &  v)
inlinestatic

Encode vector.

Note
This method can be called only if Vector is a type with a vector-like interface. Specifically, it must have a size() method and overloaded const index operator.

Encode input vector v into an instance of SignedInteger. If the value type of Vector is not SignedInteger, the values of v will be converted to SignedInteger using piranha::safe_cast(). A vector of size 0 is always encoded as 0.

Parameters
vvector to be encoded.
Returns
v encoded as a SignedInteger using Kronecker substitution.
Exceptions
std::invalid_argumentif any of these conditions hold:
  • the size of v is equal to or greater than the size of the output of get_limits(),
  • one of the components of v is outside the bounds reported by get_limits().
unspecifiedany exception thrown by piranha::safe_cast().

Definition at line 276 of file kronecker_array.hpp.

◆ get_limits()

template<typename SignedInteger >
static const limits_type& piranha::kronecker_array< SignedInteger >::get_limits ( )
inlinestatic

Get the limits of the Kronecker codification.

Will return a const reference to an std::vector of tuples describing the limits for the Kronecker codification of arrays of integer. The indices in this vector correspond to the dimension of the array to be encoded, so that the object at index \(i\) in the returned vector describes the limits for the codification of \(i\)-dimensional arrays of integers.

Each element of the returned vector is an std::tuple of 4 elements built as follows:

  • position 0: a vector containing the absolute value of the lower/upper bounds for each component,
  • position 1: \(h_\textnormal{min}\), the minimum value for the integer encoding the array,
  • position 2: \(h_\textnormal{max}\), the maximum value for the integer encoding the array,
  • position 3: \(h_\textnormal{max}-h_\textnormal{min}\).

The tuple at index 0 of the returned vector is filled with zeroes. The size of the returned vector determines the maximum dimension of the vectors to be encoded.

Returns
const reference to an std::vector of limits for the Kronecker codification of arrays of integers.

Definition at line 252 of file kronecker_array.hpp.


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