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