IVSparse  v1.0
A sparse matrix compression library.
VCSC_Vector.hpp
Go to the documentation of this file.
1 
9 #pragma once
10 
11 namespace IVSparse {
12 
19 template <typename T, typename indexT, bool columnMajor>
20 class SparseMatrix<T, indexT, 2, columnMajor>::Vector {
21  private:
22  //* Private Class Variables *//
23 
24  size_t size = 0; // size of the vector in bytes
25 
26  T *values = nullptr; // values of the vector
27  indexT *counts = nullptr; // counts of the vectors values
28  indexT *indices = nullptr; // indices of the vectors values
29  indexT valuesSize = 0; // size of the values array
30  indexT indexSize = 0; // size of the indices array
31 
32  uint32_t length = 0; // length of the vector
33 
34  uint8_t indexWidth = 1; // width of the indices
35 
36  uint32_t nnz = 0; // number of non-zero elements in the vector
37 
38  //* Private Class Methods *//
39 
40  // User checks to confirm a valid vector
41  void userChecks();
42 
43  // Calculates the size of the vector in bytes
44  void calculateCompSize();
45 
46  public:
47  //* Constructors & Destructor *//
50 
56  Vector(){};
57 
65  Vector(IVSparse::SparseMatrix<T, indexT, 2, columnMajor> &mat, uint32_t vec);
66 
72 
76  ~Vector();
77 
79 
80  //* Getters *//
83 
88  T coeff(uint32_t index);
89 
93  size_t byteSize();
94 
98  uint32_t innerSize();
99 
103  uint32_t outerSize();
104 
108  uint32_t nonZeros();
109 
113  uint32_t getLength();
114 
118  T *getValues();
119 
123  indexT *getCounts();
124 
128  indexT *getIndices();
129 
133  indexT uniqueVals();
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  // Coefficient Access Operator
179  T operator[](uint32_t index);
180 
181  // Assignment Operator
184 
185  // Equality Operators
186  bool operator==(
188 
189  // Inequality Operators
190  bool operator!=(
192 
193  // Scalar Multiplication Operator (In Place)
194  void operator*=(T scalar);
195 
196  // Scalar Multiplication Operator (Copy)
198  T scalar);
199 
200 }; // class Vector
201 
202 } // namespace IVSparse
Definition: IVCSC_Vector.hpp:25
Definition: VCSC_SparseMatrix.hpp:21
uint32_t innerSize() const
Definition: IVSparse_Base_Methods.hpp:33
uint32_t nonZeros() const
Definition: IVSparse_Base_Methods.hpp:39
size_t byteSize() const
Definition: IVSparse_Base_Methods.hpp:42
uint32_t outerSize() const
Definition: IVSparse_Base_Methods.hpp:36
Definition: IVCSC_SparseMatrix.hpp:29
T coeff(uint32_t row, uint32_t col)
Definition: IVCSC_Methods.hpp:17
void print()
Definition: IVCSC_Methods.hpp:97
T sum()
Definition: IVCSC_BLAS.hpp:239
double norm()
Definition: IVCSC_BLAS.hpp:256