piranha
0.10
|
Root piranha namespace. More...
Namespaces | |
literals | |
Inline namespace for the definition of user-defined literals. | |
math | |
Math namespace. | |
Typedefs | |
using | k_monomial = kronecker_monomial<> |
Alias for piranha::kronecker_monomial with default type. | |
template<std::size_t SSize> | |
using | mp_integer = mppp::mp_integer< SSize > |
Alias for mppp::mp_integer. | |
using | integer = mp_integer< 1 > |
Alias for piranha::mp_integer with 1 limb of static storage. | |
using | rational = mp_rational< 1 > |
Alias for piranha::mp_rational with 1 static limb. | |
using | rtk_monomial = real_trigonometric_kronecker_monomial<> |
Alias for piranha::real_trigonometric_kronecker_monomial with default type. | |
template<typename T , typename Cf > | |
using | series_rebind = series_rebind_implementation< T, Cf > |
Rebind series. More... | |
using | settings = settings_<> |
Alias for piranha::settings_. More... | |
using | symbol_fset = boost::container::flat_set< std::string > |
Flat set of symbols. More... | |
template<typename T > | |
using | symbol_fmap = boost::container::flat_map< std::string, T > |
Flat map of symbols. More... | |
using | symbol_idx = symbol_fset::size_type |
Symbol index. More... | |
using | symbol_idx_fset = boost::container::flat_set< symbol_idx > |
Flat set of symbol indices. More... | |
template<typename T > | |
using | symbol_idx_fmap = boost::container::flat_map< symbol_idx, T > |
Flat map of symbol indices. More... | |
using | thread_pool = thread_pool_<> |
Alias for piranha::thread_pool_. More... | |
template<typename T , typename... Args> | |
using | min_int = typename detail::min_int_impl< T, Args... >::type |
Detect narrowest integer type. More... | |
template<typename T , typename... Args> | |
using | max_int = typename detail::max_int_impl< T, Args... >::type |
Detect widest integer type. More... | |
Enumerations | |
enum | msgpack_format { msgpack_format::portable, msgpack_format::binary } |
Serialization format for msgpack. More... | |
enum | data_format { data_format::boost_binary, data_format::boost_portable, data_format::msgpack_binary, data_format::msgpack_portable } |
Data format. More... | |
enum | compression { compression::none, compression::bzip2, compression::gzip, compression::zlib } |
Compression format. More... | |
Functions | |
template<typename To , typename From , detail::convert_to_enabler< To, From > = 0> | |
To | convert_to (const From &x) |
Generic conversion function. More... | |
void | init () |
Main initialisation function. More... | |
void * | aligned_palloc (const std::size_t &alignment, const std::size_t &size) |
Allocate memory aligned to a specific value. More... | |
void | aligned_pfree (const std::size_t &alignment, void *ptr) |
Free memory allocated via piranha::aligned_alloc. More... | |
template<typename T > | |
bool | alignment_check (const std::size_t &alignment) |
Alignment checks. More... | |
template<typename T , typename = typename std::enable_if<is_container_element<T>::value>::type> | |
void | parallel_value_init (T *ptr, const std::size_t &size, const unsigned &n_threads) |
Parallel value initialisation. More... | |
template<typename T , typename = typename std::enable_if<is_container_element<T>::value>::type> | |
void | parallel_destroy (T *ptr, const std::size_t &size, const unsigned &n_threads) |
Parallel destruction. More... | |
template<typename T , typename = typename std::enable_if<is_container_element<T>::value>::type> | |
std::unique_ptr< T[], detail::parallel_deleter< T > > | make_parallel_array (const std::size_t &size, const unsigned &n_threads) |
Create an array in parallel. More... | |
template<typename T > | |
auto | print_coefficient (std::ostream &os, const T &cf) -> decltype(print_coefficient_impl< T >()(os, cf)) |
Print series coefficient. More... | |
template<typename T > | |
auto | print_tex_coefficient (std::ostream &os, const T &cf) -> decltype(print_tex_coefficient_impl< T >()(os, cf)) |
Print series coefficient in TeX mode. More... | |
template<typename Archive , typename T , boost_save_enabler< Archive, T > = 0> | |
void | boost_save (Archive &ar, const T &x) |
Save to Boost archive. More... | |
template<typename Archive , typename T , boost_load_enabler< Archive, T > = 0> | |
void | boost_load (Archive &ar, T &x) |
Load from Boost archive. More... | |
template<typename Stream , typename T , msgpack_pack_enabler< Stream, T > = 0> | |
void | msgpack_pack (msgpack::packer< Stream > &packer, const T &x, msgpack_format f) |
Pack generic object in a msgpack stream. More... | |
template<typename T , msgpack_convert_enabler< T > = 0> | |
void | msgpack_convert (T &x, const msgpack::object &o, msgpack_format f) |
Convert msgpack object. More... | |
template<typename T > | |
void | save_file (const T &x, const std::string &filename, data_format f, compression c) |
Save to file. More... | |
template<typename T > | |
void | save_file (const T &x, const std::string &filename) |
Save to file. More... | |
template<typename T , load_file_enabler< T > = 0> | |
void | load_file (T &x, const std::string &filename, data_format f, compression c) |
Load from file. More... | |
template<typename T , load_file_enabler< T > = 0> | |
void | load_file (T &x, const std::string &filename) |
Load from file . More... | |
template<typename To , typename From > | |
safe_cast_type< To, From > | safe_cast (const From &x) |
Safe cast. More... | |
std::tuple< symbol_fset, symbol_idx_fmap< symbol_fset >, symbol_idx_fmap< symbol_fset > > | ss_merge (const symbol_fset &s1, const symbol_fset &s2) |
Merge two symbol_fset. More... | |
symbol_idx | ss_index_of (const symbol_fset &ref, const std::string &name) |
Identify the index of a symbol in a symbol_fset. More... | |
symbol_fset | ss_trim (const symbol_fset &s, const std::vector< char > &mask) |
Trim a symbol_fset. More... | |
symbol_idx_fset | ss_intersect_idx (const symbol_fset &s1, const symbol_fset &s2) |
Find the indices of the intersection of two symbol_fset. More... | |
template<typename T , sm_intersect_idx_enabler< T > = 0> | |
symbol_idx_fmap< T > | sm_intersect_idx (const symbol_fset &s, const symbol_fmap< T > &m) |
Find the indices of the intersection of a symbol_fset and a symbol_fmap. More... | |
void | bind_to_proc (unsigned n) |
Bind thread to specific processor. More... | |
std::pair< bool, unsigned > | bound_proc () |
Query if current thread is bound to a processor. More... | |
Root piranha namespace.
using piranha::max_int = typedef typename detail::max_int_impl<T, Args...>::type |
Detect widest integer type.
This type alias requires T
and Args
(if any) to be all signed or unsigned integer types. It will be defined as the input type with the widest numerical range.
Definition at line 846 of file type_traits.hpp.
using piranha::min_int = typedef typename detail::min_int_impl<T, Args...>::type |
Detect narrowest integer type.
This type alias requires T
and Args
(if any) to be all signed or unsigned integer types. It will be defined as the input type with the narrowest numerical range.
Definition at line 838 of file type_traits.hpp.
using piranha::series_rebind = typedef series_rebind_implementation<T, Cf> |
Rebind series.
Utility alias to rebind series T
to coefficient Cf
. See piranha::series_is_rebindable for an explanation. In addition to being a shortcut to the rebind
alias in T
(if present), the implementation will also check that T
and Cf
satisfy the piranha::series_is_rebindable type traits.
Definition at line 225 of file series.hpp.
using piranha::settings = typedef settings_<> |
Alias for piranha::settings_.
This is the alias through which the methods in piranha::settings_ should be called.
Definition at line 264 of file settings.hpp.
using piranha::symbol_fmap = typedef boost::container::flat_map<std::string, T> |
Flat map of symbols.
This data structure maps an ordered set of symbols to objects of type T
.
Definition at line 68 of file symbol_utils.hpp.
using piranha::symbol_fset = typedef boost::container::flat_set<std::string> |
Flat set of symbols.
This data structure represents an ordered set of symbols.
Definition at line 61 of file symbol_utils.hpp.
using piranha::symbol_idx = typedef symbol_fset::size_type |
Symbol index.
An unsigned integral type representing a position within a symbol_fset.
Definition at line 74 of file symbol_utils.hpp.
using piranha::symbol_idx_fmap = typedef boost::container::flat_map<symbol_idx, T> |
Flat map of symbol indices.
This sorted data structure maps symbol_idx instances to the generic type T
.
Definition at line 87 of file symbol_utils.hpp.
using piranha::symbol_idx_fset = typedef boost::container::flat_set<symbol_idx> |
Flat set of symbol indices.
This data structure represents an ordered set of indices into a symbol_fset.
Definition at line 80 of file symbol_utils.hpp.
using piranha::thread_pool = typedef thread_pool_<> |
Alias for piranha::thread_pool_.
This is the alias through which the methods in piranha::thread_pool_ should be called.
Definition at line 493 of file thread_pool.hpp.
|
strong |
Compression format.
Compression formats used by high-level serialization functions such as piranha::save_file() and piranha::load_file().
Enumerator | |
---|---|
none | No compression. |
bzip2 | bzip2 compression. |
gzip | gzip compression. |
zlib | zlib compression. |
|
strong |
Data format.
Data format used by high-level serialization functions such as piranha::save_file() and piranha::load_file(). The Boost formats are based on the Boost serialization library, while the msgpack formats are based on the msgpack serialization format.
The portable variants are intended to be usable across different architectures and Piranha versions, whereas the binary variants are non-portable high-performance serialization formats intended for temporary storage. That is, saving a binary archive created with Piranha version N
on architecture A
and then loading it on a different architecture B
or using a different Piranha version M
will result in undefined behaviour.
Enumerator | |
---|---|
boost_binary | Boost binary. This format is based on the Boost binary archives. |
boost_portable | Boost portable. This format is based on the Boost text archives. |
msgpack_binary | msgpack binary. This format will employ internally the msgpack_format::binary format. |
msgpack_portable | msgpack portable. This format will employ internally the msgpack_format::portable format. |
|
strong |
Serialization format for msgpack.
The serialization of non-primitive objects can often be performed in different ways, with different tradeoffs between performance, storage requirements and portability. The piranha::mp_integer class, for instance, can be serialized either via a string representation (slow and with high storage requirements, but portable across architectures, compilers and operating systems) or as an array of platform-dependent unsigned integrals (fast and compact, but not portable).
This enum establishes two strategies for msgpack serialization: a portable format, intended to be usable across different platforms and suitable for the long-term storage of serialized objects, and a binary format, intended for use in high-performance scenarios (e.g., as temporary on-disk storage during long or memory-intensive computations). These formats are used by the Piranha msgpack serialization functions (piranha::msgpack_pack(), piranha::msgpack_convert(), etc.).
Enumerator | |
---|---|
portable | Portable. |
binary | Binary. |
|
inline |
Allocate memory aligned to a specific value.
This function will allocate a block of memory of size
bytes aligned to alignment
. If size
is zero, nullptr
will be returned. If alignment
is zero, std::malloc()
will be used for the allocation. Otherwise, the allocation will be deferred to an implementation-defined and platform-dependent low-level routine (e.g., posix_memalign()
). If such a low level routine is not available, an exception will be raised.
alignment | desired alignment. |
size | number of bytes to allocate. |
nullptr
if size
is zero.std::bad_alloc | if the allocation fails for any reason (e.g., bad alignment value, failure in the low-level allocation routine, etc.). |
piranha::not_implemented_error | if alignment and size are both nonzero and the low-level allocation function is not available on the platform. |
Definition at line 134 of file memory.hpp.
|
inline |
Free memory allocated via piranha::aligned_alloc.
This function must be used to deallocate memory obtained via piranha::aligned_alloc(). If ptr
is nullptr
, this function will be a no-op. If alignment
is zero, std::free()
will be used. Otherwise, the deallocation will be deferred to an implementation-defined and platform-dependent low-level routine (e.g., _aligned_free()
). If such a low level routine is not available, an exception will be raised.
The value of alignment
must be the same used for the allocation.
alignment | alignment value used during allocation. |
ptr | pointer to the memory to be freed. |
piranha::not_implemented_error | if ptr is not nullptr , alignment is not zero and the low-level deallocation routine is not available on the platform. |
Definition at line 182 of file memory.hpp.
|
inline |
Alignment checks.
This function will run a series of checks on an alignment value to be used to allocate storage for objects of the decay type of T
using piranha::aligned_palloc(), and it will retun true
if the alignment value passes these checks, false
otherwise. An alignment of zero will always return true
.
The checks performed are the following:
T
, as reported by alignas()
,posix_memalign()
requires the alignment to be a multiple of sizeof(void *)
).Note that piranha::aligned_palloc() will not check the alignment via this function, and that even if this function returns true
on an alignment value, this will not guarantee that the allocation via piranha::aligned_palloc() will succeed.
alignment | alignment value to be checked. |
true
if the input value is zero or if it passes the alignment checks, false
otherwise. Definition at line 224 of file memory.hpp.
|
inline |
Bind thread to specific processor.
Upon successful completion of this method, the calling thread will be confined on the specified processor. This method requires platform-specific functions and thus might not be available on all configurations.
In case of exceptions, the thread will not have been bound to any processor.
n | index of the processor to which the thread will be bound (starting from index 0). |
std::invalid_argument | if one of these conditions arises:
|
piranha::not_implemented_error | if the method is not available on the current platform. |
std::system_error | in case of failure(s) by threading primitives. |
std::runtime_error | if the operation fails in an unspecified way. |
Definition at line 109 of file thread_management.hpp.
|
inline |
Load from Boost archive.
Archive
and T
satisfy piranha::is_boost_loading_archive, and the expression boost_load_impl<Archive, T>{}(ar, x)
is well-formed.This function will load the object x
from the Boost archive ar
. The implementation of this function is in the call operator of the piranha::boost_load_impl functor. The body of this function is equivalent to:
ar | the source Boost loading archive. |
x | the object that will be loaded from ar . |
unspecified | any exception thrown by the call operator of piranha::boost_load_impl. |
|
inline |
Save to Boost archive.
Archive
and T
satisfy piranha::is_boost_saving_archive, and the expression boost_save_impl<Archive, T>{}(ar, x)
is well-formed.This function will save to the Boost archive ar
the object x
. The implementation of this function is in the call operator of the piranha::boost_save_impl functor. The body of this function is equivalent to:
ar | target Boost saving archive. |
x | object to be saved. |
unspecified | any exception thrown by the call operator of piranha::boost_save_impl. |
|
inline |
Query if current thread is bound to a processor.
The complexity of the operation is at most linear in the maximum number of processors that can be represented on the system (e.g., in Unix-like system this number will typically correspond to the CPU_SETSIZE
macro). This method requires platform-specific functions and thus might not be available on all configurations. Note that if only a single core/cpu is available, the returned value will always be (true,0)
.
(true,n)
if the calling thread is bound to a single processor with index n
, (false,0)
otherwise.piranha::not_implemented_error | if the method is not available on the current platform. |
std::runtime_error | if the operation fails in an unspecified way. |
Definition at line 180 of file thread_management.hpp.
|
inline |
Generic conversion function.
To
, and if the decay type of To
satisfies piranha::is_returnable.This function is meant to convert an instance of type From
to an instance of the decay type of To
. It is intended to be a user-extensible replacement for static_cast
limited to value conversions (that is, the decay types of To
and From
are considered).
The actual implementation of this function is in the piranha::convert_to_impl functor's call operator. The decay type of To
is passed as first template parameter of piranha::convert_to_impl, whereas From
is passed as-is. The body of this function is equivalent to:
Any specialisation of piranha::convert_to_impl must have a call operator returning an instance of the decay type of To
, otherwise this function will be disabled.
x | conversion argument. |
To
converted from x
.unspecified | any exception thrown by the call operator of the piranha::convert_to_impl functor. |
Definition at line 117 of file convert_to.hpp.
|
inline |
Main initialisation function.
This function should be called before accessing any Piranha functionality. It will register cleanup functions that will be run on program exit (e.g., the MPFR mpfr_free_cache()
function).
It is allowed to call this function concurrently from multiple threads: after the first invocation, additional invocations will not perform any action.
|
inline |
Load from file.
T
is not const.This function will load the content of the file named filename
into the object x
, assuming that the data is stored in the format f
using the compression method c
. If c
is not piranha::compression::none, it will be assumed that the file is compressed.
This function is built on lower-level routines such as piranha::boost_load() and piranha::msgpack_convert(). The data format f
establishes both the lower level serialization method to be used and its variant (e.g., portable vs binary).
x | the object into which the content of the file name filename will be deserialized. |
filename | name of the input file. |
f | data format. |
c | compression format. |
piranha::not_implemented_error | in the following cases:
|
std::runtime_error | in case the file cannot be opened for reading. |
unspecified | any exception thrown by:
|
|
inline |
Load from file .
T
is not const.This is a convenience function that will invoke the other overload of piranha::load_file() trying to guess the data and compression formats from the filename. The heuristic is described in the second overload of piranha::save_file().
x | the object into which the file content will be loaded. |
filename | source file name. |
std::invalid_argument | if the compression and data formats cannot be deduced. |
unspecified | any exception thrown by the first overload of piranha::load_file(). |
|
inline |
Create an array in parallel.
T
satisfies the piranha::is_container_element type trait.This function will create an array whose values will be initialised in parallel using piranha::parallel_value_init(). The pointer to the array is returned wrapped inside an std::unique_ptr
that will take care of destroying the array elements (also in parallel using piranha::parallel_destroy()) and deallocating the memory when the destructor is called.
size | size of the array. |
n_threads | number of threads to use. |
std::unique_ptr
wrapping the array.std::bad_alloc | if size is greater than an implementation-defined value. |
unspecified | any exception thrown by:
|
Definition at line 475 of file memory.hpp.
|
inline |
Convert msgpack object.
T
is not const and if msgpack_convert_impl<T>{}(x, o, f)
is a valid expression.This function is intended to convert the msgpack object o
into an instance of type T
, and to write the converted value into x
. The actual implementation of this function is in the piranha::msgpack_convert_impl functor. The body of this function is equivalent to:
x | the output value. |
o | the msgpack object that will be converted into x . |
f | the serialization format. |
unspecified | any exception thrown by the call operator piranha::msgpack_convert_impl. |
|
inline |
Pack generic object in a msgpack stream.
Stream
satisfies piranha::is_msgpack_stream and if msgpack_pack_impl<Stream, T>{}(packer, x, f)
is a valid expression.This function is intended to pack the input value x
into a msgpack packer
using the format f
. The actual implementation of this function is in the piranha::msgpack_pack_impl functor. The body of this function is equivalent to:
packer | the msgpack packer object. |
x | the object to be packed into packer . |
f | the serialization format. |
unspecified | any exception thrown by the call operator piranha::msgpack_pack_impl. |
|
inline |
Parallel destruction.
T
satisfies the piranha::is_container_element type trait.This function will destroy in parallel the element of an array ptr
of size size
. If n_threads
is 0 or 1, the operation will be performed in the calling thread, otherwise the first n_threads
in piranha::thread_pool will be used to perform the operation concurrently.
The function is a no-op if ptr
is null or if T
has a trivial destructor.
ptr | pointer to the array. |
size | size of the array. |
n_threads | number of threads to use. |
Definition at line 349 of file memory.hpp.
|
inline |
Parallel value initialisation.
T
satisfies the piranha::is_container_element type trait.This function will value-initialise in parallel the array ptr
of size size
. The routine will use the first n_threads
from piranha::thread_pool to perform the operation concurrently. If n_threads
is 1 or 0, the operation will be performed in the calling thread. If ptr
is null, this function will be a no-op.
This function provides the strong exception safety guarantee: in case of errors, any constructed instance of T
will be destroyed before the error is re-thrown.
ptr | pointer to the array. |
size | size of the array. |
n_threads | number of threads to use. |
std::bad_alloc | in case of memory allocation errors in multithreaded mode. |
unspecified | any exception thrown by:
|
Definition at line 271 of file memory.hpp.
|
inline |
Print series coefficient.
This function is used in the stream operator overload for piranha::series when printing coefficients.
The implementation uses the call operator of the piranha::print_coefficient_impl functor. Specialisations of piranha::print_coefficient_impl can be defined to customize the behaviour.
os | target stream. |
cf | coefficient object to be printed. |
unspecified | any exception thrown by the call operator of piranha::print_coefficient_impl. |
Definition at line 83 of file print_coefficient.hpp.
|
inline |
Print series coefficient in TeX mode.
This function is used in to print coefficients in TeX mode.
The implementation uses the call operator of the piranha::print_tex_coefficient_impl functor. Specialisations of piranha::print_tex_coefficient_impl can be defined to customize the behaviour.
os | target stream. |
cf | coefficient object to be printed. |
unspecified | any exception thrown by the call operator of piranha::print_tex_coefficient_impl. |
Definition at line 79 of file print_tex_coefficient.hpp.
|
inline |
Safe cast.
This function is meant to be used when it is necessary to convert between two types while making sure that the value is preserved after the conversion. For instance, a safe cast between integral types will check that the input value is representable by the return type, otherwise an error will be raised.
The actual implementation of this function is in the piranha::safe_cast_impl functor's call operator. To
is passed as first template parameter of piranha::safe_cast_impl after the removal of cv/reference qualifiers, whereas From
is passed as-is. The body of this function is thus equivalent to:
(where uncvref_t<To>
refers to To
without cv/reference qualifiers).
Any specialisation of piranha::safe_cast_impl must have a call operator returning an instance of type uncvref_t<To>
, otherwise this function will be disabled. The function will also be disabled if uncvref_t<To>
does not satisfy piranha::is_returnable.
Specialisations of piranha::safe_cast_impl are encouraged to raise an exception of type piranha::safe_cast_failure in case the type conversion fails.
x | argument for the conversion. |
x
converted to To
.unspecified | any exception thrown by the call operator of piranha::safe_cast_impl. |
Definition at line 219 of file safe_cast.hpp.
|
inline |
Save to file.
This function will save the generic object x
to the file named filename
, using the data format f
and the compression method c
.
This function is built on lower-level routines such as piranha::boost_save() and piranha::msgpack_pack(). The data format f
establishes both the lower level serialization method to be used and its variant (e.g., portable vs binary). If requested (i.e., if c
is not piranha::compression::none), the output file will be compressed.
x | object to be saved to file. |
filename | name of the output file. |
f | data format. |
c | compression format. |
piranha::not_implemented_error | in the following cases:
|
std::runtime_error | in case the file cannot be opened for writing. |
unspecified | any exception thrown by:
|
|
inline |
Save to file.
This is a convenience function that will invoke the other overload of piranha::save_file() trying to guess the data and compression formats from the filename. The heuristic is as follows:
filename
ends in one of the suffixes .bz2
, .gz
or .zip
then the suffix is removed for further considerations from filename
, and the corresponding piranha::compression format is assumed (respectively, piranha::compression::bzip2, piranha::compression::gzip and piranha::compression::zlib). Otherwise, piranha::compression::none is assumed;filename
is examined again: if the extension is one of .boostp
, .boostb
, .mpackp
and .mpackb
, then the corresponding data format is selected (respectively, piranha::data_format::boost_portable, piranha::data_format::boost_binary, piranha::data_format::msgpack_portable, piranha::data_format::msgpack_binary). Othwewise, an error will be produced.Examples:
foo.boostb.bz2
deduces piranha::data_format::boost_binary and piranha::compression::bzip2;foo.mpackp
deduces piranha::data_format::msgpack_portable and piranha::compression::none;foo.txt
produces an error;foo.bz2
produces an error.x | the object that will be saved to file. |
filename | the desired file name. |
std::invalid_argument | if the compression and data formats cannot be deduced. |
unspecified | any exception thrown by the first overload of piranha::save_file(). |
|
inline |
Find the indices of the intersection of a symbol_fset and a symbol_fmap.
T
is default-constructible, copy-assignable and copy-constructible.This function first computes the intersection ix
of the set s
and the keys of m
, and then returns a map in which the keys are the positional indices of ix
in s
and the values are the corresponding values of ix
in m
.
For instance, if T
is int
, s
is ["b", "d", "e"]
and m
is [("a", 1), ("b", 2), ("c", 3), ("d", 4), ("g", 5)]
, the intersection ix
is ["b", "d"]
and the returned map is [(0, 2), (1, 4)]
.
s | the set operand. |
m | the map operand. |
s
of the intersection of s
and m
to the values in m
.std::overflow_error | if the size of s is larger than an implementation-defined value. |
unspecified | any exception thrown by:
|
Definition at line 425 of file symbol_utils.hpp.
|
inline |
Identify the index of a symbol in a symbol_fset.
This function will return the positional index of the symbol name
in the set ref
. If name
is not in ref
, the size of ref
will be returned.
ref | the input symbol_fset. |
name | the symbol whose index in ref will be returned. |
name
in ref
. Definition at line 237 of file symbol_utils.hpp.
|
inline |
Find the indices of the intersection of two symbol_fset.
This function first computes the intersection ix
of the two sets s1
and s2
, and then returns a set with the positional indices of ix
in s1
.
For instance, if s1
is ["b", "d", "e"]
and s2
is ["a", "b", "c", "d", "g"]
, the intersection ix
is ["b", "d"]
and the returned set is [0, 1]
.
s1 | the first operand. |
s2 | the second operand. |
s1
of the intersection of s1
and s2
.std::overflow_error | if the size of s1 is larger than an implementation-defined value. |
unspecified | any exception thrown by the public interface of symbol_fset, or by safe_cast(). |
Definition at line 329 of file symbol_utils.hpp.
|
inline |
Merge two symbol_fset.
This function will merge the input symbol_fset s1
and s2
, returning a tuple of three elements:
u
of s1
and s2
,m1
and m2
representing the set differences u\s1
and u\s2
respectively.The insertion maps contain the indices in s1
and s2
at which symbols must be added so that s1
and s2
, after the insertion of the symbols in m1
and m2
, become identical to u
.
For example, given the input sets s1 = ["b", "c", "e"]
and s2 = ["a", "c", "d", "f", "g"]
, the return values will be:
u = ["a", "b", "c", "d", "e", "f", "g"]
,m1 = [(0, ["a"]), (2, ["d"]), (3, ["f", "g"])]
,m2 = [(1, ["b"]), (3, ["e"])]
.s1 | the first set. |
s2 | the second set. |
u
of s1
and s2
and the set differences u\s1
and u\s2
.std::overflow_error | in case of internal overflows. |
unspecified | any exception thrown by memory allocation errors. |
Definition at line 170 of file symbol_utils.hpp.
|
inline |
Trim a symbol_fset.
This function will trim the input set s
according to the values in mask
. That is, a copy of s
is returned without the symbols whose corresponding values in mask
are nonzero.
For instance, if the input set s
is ["x", "y", "z"]
and the input mask is [0, 1, 0]
, then the return value of this function is the set ["x", "z"]
(i.e., the "y"
symbol was eliminated because its corresponding value in mask
is 1).
s | the input symbol_fset. |
mask | the trimming mask. |
s
trimmed according to mask
.std::invalid_argument | if the sizes of s and mask differ. |
unspecified | any exception thrown by the construction of the return value. |
Definition at line 287 of file symbol_utils.hpp.