IVSparse  v1.0
A sparse matrix compression library.
IVCSC_Iterator.hpp
1 
9 #pragma once
10 
11 namespace IVSparse {
12 
24  template <typename T, typename indexT, uint8_t compressionLevel, bool columnMajor>
25  class SparseMatrix<T, indexT, compressionLevel, columnMajor>::InnerIterator {
26 
27  private:
28  //* Private Class Variables *//
29 
30  indexT outer; // Outer dimension
31  indexT index; // Current index
32  T *val = nullptr; // Current value
33 
34  indexT newIndex; // Next index
35 
36  uint8_t indexWidth = 1; // Width of the current run
37 
38  void *data; // Pointer to the current data
39  void *endPtr; // Pointer to the end of the data
40 
41  bool firstIndex = true; // Is this the first index of the vector
42 
43  //* Private Class Methods *//
44 
45  // Decodes the index from the data pointer
46  void __attribute__((hot)) decodeIndex();
47 
48  public:
49  //* Constructors & Destructor *//
52 
59 
67 
74 
76 
77  //* Getters *//
80 
85  indexT getIndex();
86 
90  indexT outerDim();
91 
95  indexT row();
96 
100  indexT col();
101 
105  T value();
106 
112  void coeff(T newValue);
113 
117  bool isNewRun();
118 
120 
121  //* Operator Overloads *//
122 
123  // Increment Operator
124  void __attribute__((hot)) operator++();
125 
126  // Equality Operators
127  bool operator==(const InnerIterator &other);
128 
129  // Inequality Operators
130  bool operator!=(const InnerIterator &other);
131 
132  // Less Than Operator
133  bool operator<(const InnerIterator &other);
134 
135  // Greater Than Operator
136  bool operator>(const InnerIterator &other);
137 
138  // Bool Operator
139  inline __attribute__((hot)) operator bool() { return ((char *)endPtr - indexWidth > data); }
140 
141  // Dereference Operator
142  T &operator*();
143 
144  }; // End of InnerIterator Class
145 
146 } // End of IVSparse Namespace
Definition: IVCSC_Iterator.hpp:25
InnerIterator()
Definition: IVCSC_Iterator.hpp:58
Definition: IVCSC_Vector.hpp:27
Definition: IVCSC_SparseMatrix.hpp:27
T coeff(uint32_t row, uint32_t col)
Definition: IVCSC_Methods.hpp:17