42 #ifndef SPVEC_INDEX_LOOKUP_CLASS_DECL_H
43 #define SPVEC_INDEX_LOOKUP_CLASS_DECL_H
47 #include "AbstractLinAlgPack_Types.hpp"
49 namespace AbstractLinAlgPack {
51 namespace SparseVectorUtilityPack {
63 template <
class T_Element>
78 {
public:
explicit NoSpVecSetException(
const std::string& what_arg) : std::logic_error(what_arg) {}};
88 poss_type() : poss(0), rel(EQUAL_TO_ELE) {}
101 : ele_(0), nz_(0), offset_(0), index_cached_(0)
106 : ele_(ele), nz_(nz), offset_(offset), index_cached_(0)
138 size_type
nz()
const {
198 size_type
find_element( index_type index,
bool is_sorted )
const;
237 mutable index_type index_cached_;
238 mutable size_type poss_cached_;
249 void assert_sp_vec_setup()
const {
251 throw NoSpVecSetException(
"The sparse vector (ele, nz, offset) has not been set yet");
255 size_type adjust_cached_poss(
UpperLower uplow)
const;
274 poss_type binary_ele_search(index_type index,
UpperLower uplow)
const;
283 #endif // SPVEC_INDEX_LOOKUP_CLASS_DECL_H
difference_type offset() const
poss_type find_poss(index_type index, UpperLower uplow) const
Lookup an element and cache the result if a binary search was performed.
void incr_nz()
Increment nz only.
element_type * ele() const
void set_sp_vec(element_type *ele, size_type nz, difference_type offset)
Set a new sparse vector.
element_type::index_type index_type
void sp_vec_was_modified()
Called by client to inform the object that the sparse vector was modified so that the cache may be in...
SpVecIndexLookup(element_type *ele, size_type nz, difference_type offset)
Construct initialize with a sparse vector.
Struct with members: size_type poss; ElementRelation rel;.
SpVecIndexLookup()
Construct uninitialized with not sparse vector set (ele() == 0#)
ptrdiff_t difference_type
Sparse Vector Index Lookup and Caching class.
size_type find_element(index_type index, bool is_sorted) const
Lookup an element.
void validate_state() const
Called by client to ensure that the internal state is valid.