IVSparse  v1.0
A sparse matrix compression library.
IVSparse_SparseMatrixBase.hpp
Go to the documentation of this file.
1 
9 #pragma once
10 
11 namespace IVSparse {
12 
21  private:
22  //* The Matrix Info *//
23 
24  uint32_t innerDim = 0; // The inner dimension of the matrix
25  uint32_t outerDim = 0; // The outer dimension of the matrix
26 
27  uint32_t numRows = 0; // The number of rows in the matrix
28  uint32_t numCols = 0; // The number of columns in the matrix
29 
30  uint32_t nnz = 0; // The number of non-zero values in the matrix
31 
32  size_t compSize = 0; // The size of the compressed matrix in bytes
33 
34  //* The Value and Index Types *//
35 
36  uint32_t val_t; // Information about the value type (size, signededness, etc.)
37  uint32_t index_t; // Information about the index type (size)
38 
39  uint32_t *metadata = nullptr; // The metadata of the matrix
40 
41  //* Private Methods *//
42 
43  // Calculates the number of bytes needed to store a value
44  inline uint8_t byteWidth(size_t size);
45 
46  // Creates value type information
47  virtual void encodeValueType() = 0;
48 
49  // Checks the value type information
50  virtual void checkValueType() = 0;
51 
52  // User checks to confirm a valid matrix
53  virtual void userChecks() = 0;
54 
55  // Calculates the size of the matrix in bytes
56  virtual void calculateCompSize() = 0;
57 
58  public:
59  //* Friends *//
60 
61  // IVSparse Sparse Matrix Class
62  template <typename T, typename indexT, uint8_t compressionLevel, bool columnMajor>
63  friend class SparseMatrix;
64 
65  //* Constructors *//
66 
67  // Default Constructor
68  SparseMatrixBase(){};
69 
70  //* Getters *//
71 
75  template <typename T>
76  T coeff(uint32_t row, uint32_t col);
77 
81  uint32_t rows() const;
82 
86  uint32_t cols() const;
87 
91  uint32_t innerSize() const;
92 
96  uint32_t outerSize() const;
97 
101  uint32_t nonZeros() const;
102 
106  size_t byteSize() const;
107 
108  //* Utility Methods *//
109 
113  virtual void write(const char *filename) = 0;
114 
118  virtual void print() = 0;
119 
120 }; // class SparseMatrixBase
121 
122 } // namespace IVSparse
Definition: IVSparse_SparseMatrixBase.hpp:20
virtual void print()=0
uint32_t innerSize() const
Definition: IVSparse_Base_Methods.hpp:33
uint32_t nonZeros() const
Definition: IVSparse_Base_Methods.hpp:39
T coeff(uint32_t row, uint32_t col)
uint32_t cols() const
Definition: IVSparse_Base_Methods.hpp:30
size_t byteSize() const
Definition: IVSparse_Base_Methods.hpp:42
virtual void write(const char *filename)=0
uint32_t outerSize() const
Definition: IVSparse_Base_Methods.hpp:36
uint32_t rows() const
Definition: IVSparse_Base_Methods.hpp:27
Definition: IVCSC_SparseMatrix.hpp:29