piranha
0.10
|
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... | |
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.
SignedInteger
must be a C++ signed integral type.
Unless otherwise specified, this class provides the strong exception safety guarantee for all operations.
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.
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.
|
inlinestatic |
Decode into vector.
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.
retval | object that will store the decoded vector. |
n | code to be decoded. |
std::invalid_argument | if any of these conditions hold:
|
unspecified | any exception thrown by piranha::safe_cast(). |
Definition at line 330 of file kronecker_array.hpp.
|
inlinestatic |
Encode vector.
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.
v | vector to be encoded. |
v
encoded as a SignedInteger
using Kronecker substitution.std::invalid_argument | if any of these conditions hold:
|
unspecified | any exception thrown by piranha::safe_cast(). |
Definition at line 276 of file kronecker_array.hpp.
|
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:
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.
std::vector
of limits for the Kronecker codification of arrays of integers. Definition at line 252 of file kronecker_array.hpp.