IVSparse  v1.0
A sparse matrix compression library.
VCSC_Iterator.hpp
1 
9 #pragma once
10 
11 namespace IVSparse {
12 
21  template <typename T, typename indexT, bool columnMajor>
22  class SparseMatrix<T, indexT, 2, columnMajor>::InnerIterator {
23 
24  private:
25  //* Private Class Variables *//
26 
27  indexT outer = 0; // Outer dimension
28  indexT index = 0; // Current index
29  indexT newIndex = 0; // Next index
30  T *val = nullptr; // Current value
31 
32  bool firstIndex = true; // Is this the first index of the vector
33 
34  T *vals = nullptr; // Pointer to values
35  indexT *counts = nullptr; // Pointer to counts
36  indexT *indices = nullptr; // Pointer to indices
37 
38  indexT valsSize = 0; // Number of unique values
39  indexT indexSize = 0; // Number of indices
40 
41  indexT count = 0; // Current count
42  indexT countIndex = 0; // Current count of indices
43 
44  //* Private Class Methods *//
45 
46  public:
47  //* Constructors & Destructor *//
50 
56  InnerIterator(){};
57 
64  InnerIterator(SparseMatrix<T, indexT, 2, columnMajor> &mat, uint32_t col);
65 
71  InnerIterator(SparseMatrix<T, indexT, 2, columnMajor>::Vector &vec);
72 
74 
75  //* Getters *//
78 
83  indexT getIndex();
84 
88  indexT outerDim();
89 
93  indexT row();
94 
98  indexT col();
99 
103  T value();
104 
110  void coeff(T newValue);
111 
115  bool isNewRun();
116 
118 
119  //* Operator Overloads *//
120 
121  // Prefix increment operator
122  void __attribute__((hot)) operator++();
123 
124  // Equality operator
125  bool operator==(const InnerIterator &other);
126 
127  // Inequality operator
128  bool operator!=(const InnerIterator &other);
129 
130  // Less than operator
131  bool operator<(const InnerIterator &other);
132 
133  // Greater than operator
134  bool operator>(const InnerIterator &other);
135 
136  // Boolean operator
137  inline __attribute__((hot)) operator bool() { return countIndex < indexSize; }
138 
139  // Dereference operator
140  T &operator*();
141 
142  }; // End of VCSC Inner Iterator Class
143 
144 } // End of IVSparse Namespace
T coeff(uint32_t row, uint32_t col)
Definition: IVCSC_Methods.hpp:17