IVSparse  v1.0
A sparse matrix compression library.
IVCSC_Vector.hpp
1 
9 #pragma once
10 
11 namespace IVSparse
12 {
13 
25  template <typename T, typename indexT, uint8_t compressionLevel, bool columnMajor>
26  class SparseMatrix<T, indexT, compressionLevel, columnMajor>::Vector
27  {
28 
29  private:
30  //* Private Class Variables *//
31 
32  size_t size = 0; // size of the vector in bytes
33 
34  void *data = nullptr; // data of the vector
35  void *endPtr = nullptr; // pointer to the end of the vector
36 
37  uint32_t length = 0; // length of the vector
38 
39  uint8_t indexWidth = 1; // width of the indices
40 
41  uint32_t nnz = 0; // number of non-zero elements in the vector
42 
43  //* Private Class Methods *//
44 
45  // User checks to confirm a valid vector
46  void userChecks();
47 
48  // Calculates the size of the vector in bytes
49  void calculateCompSize();
50 
51  public:
52  //* Constructors & Destructor *//
55 
61  Vector(){};
62 
67  Vector(uint32_t length);
68 
76 
82 
86  ~Vector();
87 
89 
90  //* Getters *//
93 
98  T coeff(uint32_t index);
99 
103  void *begin();
104 
108  void *end();
109 
113  size_t byteSize();
114 
118  uint32_t innerSize();
119 
123  uint32_t outerSize();
124 
128  uint32_t nonZeros();
129 
133  uint32_t getLength();
134 
136 
137  //* Utility Methods *//
140 
145  void print();
146 
148 
149  //* Calculations *//
152 
157  double norm();
158 
162  T sum();
163 
167  double dot(Eigen::Vector<T, -1> &other);
168 
172  double dot(Eigen::SparseVector<T, -1> &other);
173 
175 
176  //* Operator Overloads *//
177 
178  // In place scalar multiplication
179  void operator*=(T scalar);
180 
181  // scalar multiplication
183 
184  // equality operator
186 
187  // inequality operator
189 
190  // coefficient access
191  T operator[](uint32_t index);
192 
193  // boolean operator
194  operator bool() { return (char *)endPtr - indexWidth > data; };
195 
196  // assignment operator
198 
199  }; // class Vector
200 
201 } // namespace IVSparse
Definition: IVCSC_Vector.hpp:27
Vector()
Definition: IVCSC_Vector.hpp:61
uint32_t innerSize() const
Definition: IVSparse_Base_Methods.hpp:28
uint32_t nonZeros() const
Definition: IVSparse_Base_Methods.hpp:34
size_t byteSize() const
Definition: IVSparse_Base_Methods.hpp:37
uint32_t outerSize() const
Definition: IVSparse_Base_Methods.hpp:31
Definition: IVCSC_SparseMatrix.hpp:27
T coeff(uint32_t row, uint32_t col)
Definition: IVCSC_Methods.hpp:17
void print()
Definition: IVCSC_Methods.hpp:64
T sum()
Definition: IVCSC_BLAS.hpp:219
double norm()
Definition: IVCSC_BLAS.hpp:232