IVSparse  v1.0
A sparse matrix compression library.
IVCSC_Iterator.hpp
Go to the documentation of this file.
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  private:
27  //* Private Class Variables *//
28 
29  indexT outer; // Outer dimension
30  indexT index; // Current index
31  T *val = nullptr; // Current value
32 
33  indexT newIndex = 0; // Next index
34 
35  uint8_t indexWidth = 1; // Width of the current run
36 
37  void *data; // Pointer to the current data
38  void *endPtr; // Pointer to the end of the data
39 
40  bool firstIndex = true; // Is this the first index of the vector
41 
42  //* Private Class Methods *//
43 
44  // Decodes the index from the data pointer
45  void __attribute__((hot)) decodeIndex();
46 
47  public:
48  //* Constructors & Destructor *//
51 
58 
66  uint32_t col);
67 
75 
77 
78  //* Getters *//
81 
86  indexT getIndex();
87 
91  indexT outerDim();
92 
96  indexT row();
97 
101  indexT col();
102 
106  T value();
107 
113  void coeff(T newValue);
114 
118  bool isNewRun();
119 
121 
122  //* Operator Overloads *//
123 
124  // Increment Operator
125  void __attribute__((hot)) operator++();
126 
127  // Equality Operators
128  bool operator==(const InnerIterator &other);
129 
130  // Inequality Operators
131  bool operator!=(const InnerIterator &other);
132 
133  // Less Than Operator
134  bool operator<(const InnerIterator &other);
135 
136  // Greater Than Operator
137  bool operator>(const InnerIterator &other);
138 
139  // Bool Operator
140  inline __attribute__((hot)) operator bool() {
141  return ((char *)endPtr - indexWidth > data);
142  }
143 
144  // Dereference Operator
145  T &operator*();
146 
147 }; // End of InnerIterator Class
148 
149 } // namespace IVSparse
Definition: IVCSC_Iterator.hpp:25
InnerIterator()
Definition: IVCSC_Iterator.hpp:57
Definition: IVCSC_Vector.hpp:25
Definition: IVCSC_SparseMatrix.hpp:29
T coeff(uint32_t row, uint32_t col)
Definition: IVCSC_Methods.hpp:17