IVSparse  v1.0
A sparse matrix compression library.
VCSC_Vector.hpp
1 
9 #pragma once
10 
11 namespace IVSparse
12 {
13 
20  template <typename T, typename indexT, bool columnMajor>
21  class SparseMatrix<T, indexT, 2, columnMajor>::Vector
22  {
23  private:
24  //* Private Class Variables *//
25 
26  size_t size = 0; // size of the vector in bytes
27 
28  T *values = nullptr; // values of the vector
29  indexT *counts = nullptr; // counts of the vectors values
30  indexT *indices = nullptr; // indices of the vectors values
31  indexT valuesSize = 0; // size of the values array
32  indexT indexSize = 0; // size of the indices array
33 
34  uint32_t length = 0; // length of the vector
35 
36  uint8_t indexWidth = 1; // width of the indices
37 
38  uint32_t nnz = 0; // number of non-zero elements in the vector
39 
40  //* Private Class Methods *//
41 
42  // User checks to confirm a valid vector
43  void userChecks();
44 
45  // Calculates the size of the vector in bytes
46  void calculateCompSize();
47 
48  public:
49  //* Constructors & Destructor *//
52 
58  Vector(){};
59 
66  Vector(IVSparse::SparseMatrix<T, indexT, 2, columnMajor> &mat, uint32_t vec);
67 
73 
77  ~Vector();
78 
80 
81  //* Getters *//
84 
89  T coeff(uint32_t index);
90 
94  size_t byteSize();
95 
99  uint32_t innerSize();
100 
104  uint32_t outerSize();
105 
109  uint32_t nonZeros();
110 
114  uint32_t getLength();
115 
119  T *getValues();
120 
124  indexT *getCounts();
125 
129  indexT *getIndices();
130 
134  indexT uniqueVals();
135 
137 
138  //* Utility Methods *//
141 
146  void print();
147 
149 
150  //* Calculations *//
153 
158  double norm();
159 
163  T sum();
164 
168  double dot(Eigen::Vector<T, -1> &other);
169 
173  double dot(Eigen::SparseVector<T, -1> &other);
174 
176 
177  //* Operator Overloads *//
178 
179  // Coefficient Access Operator
180  T operator[](uint32_t index);
181 
182  // Assignment Operator
184 
185  // Equality Operators
186  bool operator==(typename SparseMatrix<T, indexT, 2, columnMajor>::Vector &vec);
187 
188  // Inequality Operators
189  bool operator!=(typename SparseMatrix<T, indexT, 2, columnMajor>::Vector &vec);
190 
191  // Scalar Multiplication Operator (In Place)
192  void operator*=(T scalar);
193 
194  // Scalar Multiplication Operator (Copy)
196 
197  }; // class Vector
198 
199 } // namespace IVSparse
Definition: IVCSC_Vector.hpp:27
Definition: VCSC_SparseMatrix.hpp:22
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