Ginkgo
Generated from pipelines/1570051012 branch based on develop. Ginkgo version 1.9.0
A numerical linear algebra library targeting many-core architectures
|
An index set class represents an ordered set of intervals. More...
#include <ginkgo/core/base/index_set.hpp>
Public Types | |
using | index_type = IndexType |
The type of elements stored in the index set. | |
Public Member Functions | |
index_set (std::shared_ptr< const Executor > exec) noexcept | |
Creates an empty index_set tied to the specified Executor. More... | |
index_set (std::shared_ptr< const gko::Executor > exec, std::initializer_list< IndexType > init_list, const bool is_sorted=false) | |
Creates an index set on the specified executor from the initializer list. More... | |
index_set (std::shared_ptr< const gko::Executor > exec, const index_type size, const gko::array< index_type > &indices, const bool is_sorted=false) | |
Creates an index set on the specified executor and the given size. More... | |
index_set (std::shared_ptr< const Executor > exec, const index_set &other) | |
Creates a copy of the input index_set on a different executor. More... | |
index_set (const index_set &other) | |
Creates a copy of the input index_set. More... | |
index_set (std::shared_ptr< const Executor > exec, index_set &&other) | |
Moves the input index_set to a different executor. More... | |
index_set (index_set &&other) | |
Moves the input index_set. More... | |
index_set & | operator= (const index_set &other) |
Copies data from another index_set. More... | |
index_set & | operator= (index_set &&other) |
Moves data from another index_set. More... | |
void | clear () noexcept |
Deallocates all data used by the index_set. More... | |
std::shared_ptr< const Executor > | get_executor () const |
Returns the executor of the index_set. More... | |
index_type | get_size () const |
Returns the size of the index set space. More... | |
bool | is_contiguous () const |
Returns if the index set is contiguous. More... | |
index_type | get_num_elems () const |
Return the actual number of indices stored in the index set. More... | |
index_type | get_global_index (index_type local_index) const |
Return the global index given a local index. More... | |
index_type | get_local_index (index_type global_index) const |
Return the local index given a global index. More... | |
array< index_type > | map_local_to_global (const array< index_type > &local_indices, const bool is_sorted=false) const |
This is an array version of the scalar function above. More... | |
array< index_type > | map_global_to_local (const array< index_type > &global_indices, const bool is_sorted=false) const |
This is an array version of the scalar function above. More... | |
array< index_type > | to_global_indices () const |
This function allows the user obtain a decompressed global_indices array from the indices stored in the index set. More... | |
array< bool > | contains (const array< index_type > &global_indices, const bool is_sorted=false) const |
Checks if the individual global indeices exist in the index set. More... | |
bool | contains (const index_type global_index) const |
Checks if the global index exists in the index set. More... | |
index_type | get_num_subsets () const |
Returns the number of subsets stored in the index set. More... | |
const index_type * | get_subsets_begin () const |
Returns a pointer to the beginning indices of the subsets. More... | |
const index_type * | get_subsets_end () const |
Returns a pointer to the end indices of the subsets. More... | |
const index_type * | get_superset_indices () const |
Returns a pointer to the cumulative indices of the superset of the subsets. More... | |
An index set class represents an ordered set of intervals.
The index set contains subsets which store the starting and end points of a range, [a,b), storing the first index and one past the last index. As the index set only stores the end-points of ranges, it can be quite efficient in terms of storage.
This class is particularly useful in storing continuous ranges. For example, consider the index set (1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 18, 19, 20, 21, 42). Instead of storing the entire array of indices, one can store intervals ([1,9), [10,13), [18,22), [42,43)), thereby only using half the storage.
We store three arrays, one (subsets_begin) with the starting indices of the subsets in the index set, another (subsets_end) storing one index beyond the end indices of the subsets and the last (superset_cumulative_indices) storing the cumulative number of indices in the subsequent subsets with an initial zero which speeds up the querying. Additionally, the arrays conataining the range boundaries (subsets_begin, subsets_end) are stored in a sorted fashion.
Therefore the storage would look as follows
index_set = (1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 18, 19, 20, 21, 42) subsets_begin = {1, 10, 18, 42} subsets_end = {9, 13, 22, 43} superset_cumulative_indices = {0, 8, 11, 15, 16}
index_type | type of the indices being stored in the index set. |
|
inlineexplicitnoexcept |
|
inlineexplicit |
Creates an index set on the specified executor from the initializer list.
exec | the Executor where the index set data will be allocated |
init_list | the indices that the index set should hold in an initializer_list. |
is_sorted | a parameter that specifies if the indices array is sorted or not. true if sorted. |
|
inlineexplicit |
Creates an index set on the specified executor and the given size.
exec | the Executor where the index set data will be allocated |
size | the maximum index the index set it allowed to hold. This is the size of the index space. |
indices | the indices that the index set should hold. |
is_sorted | a parameter that specifies if the indices array is sorted or not. true if sorted. |
References gko::array< ValueType >::get_size().
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinenoexcept |
Deallocates all data used by the index_set.
The index_set is left in a valid, but empty state, so the same index_set can be used to allocate new memory. Calls to index_set::get_subsets_begin() will return a nullptr
.
References gko::array< ValueType >::clear().
array<bool> gko::index_set< IndexType >::contains | ( | const array< index_type > & | global_indices, |
const bool | is_sorted = false |
||
) | const |
Checks if the individual global indeices exist in the index set.
global_indices | the indices to check. |
is_sorted | a parameter that specifies if the query array is sorted or not. true if sorted. |
bool gko::index_set< IndexType >::contains | ( | const index_type | global_index | ) | const |
Checks if the global index exists in the index set.
global_index | the index to check. |
|
inline |
Returns the executor of the index_set.
index_type gko::index_set< IndexType >::get_global_index | ( | index_type | local_index | ) | const |
Return the global index given a local index.
Consider the set idx_set = (0, 1, 2, 4, 6, 7, 8, 9). This function returns the element at the global index k stored in the index set. For example, idx_set.get_global_index(0) == 0
idx_set.get_global_index(3) == 4
and idx_set.get_global_index(7) == 9
local_index | the local index. |
index_type gko::index_set< IndexType >::get_local_index | ( | index_type | global_index | ) | const |
Return the local index given a global index.
Consider the set idx_set = (0, 1, 2, 4, 6, 7, 8, 9). This function returns the local index in the index set of the provided index set. For example, idx_set.get_local_index(0) == 0
idx_set.get_local_index(4) == 3
and idx_set.get_local_index(6) == 4
.
global_index | the global index. |
|
inline |
Return the actual number of indices stored in the index set.
|
inline |
Returns the number of subsets stored in the index set.
References gko::array< ValueType >::get_size().
Referenced by gko::index_set< IndexType >::is_contiguous().
|
inline |
Returns the size of the index set space.
|
inline |
Returns a pointer to the beginning indices of the subsets.
References gko::array< ValueType >::get_const_data().
|
inline |
Returns a pointer to the end indices of the subsets.
References gko::array< ValueType >::get_const_data().
|
inline |
Returns a pointer to the cumulative indices of the superset of the subsets.
References gko::array< ValueType >::get_const_data().
|
inline |
Returns if the index set is contiguous.
References gko::index_set< IndexType >::get_num_subsets().
array<index_type> gko::index_set< IndexType >::map_global_to_local | ( | const array< index_type > & | global_indices, |
const bool | is_sorted = false |
||
) | const |
This is an array version of the scalar function above.
global_indices | the global index array. |
is_sorted | a parameter that specifies if the query array is sorted or not. true if sorted. |
array<index_type> gko::index_set< IndexType >::map_local_to_global | ( | const array< index_type > & | local_indices, |
const bool | is_sorted = false |
||
) | const |
This is an array version of the scalar function above.
local_indices | the local index array. |
is_sorted | a parameter that specifies if the query array is sorted or not. true if sorted . |
|
inline |
|
inline |
array<index_type> gko::index_set< IndexType >::to_global_indices | ( | ) | const |
This function allows the user obtain a decompressed global_indices array from the indices stored in the index set.