IVSparse  v1.0
A sparse matrix compression library.
IVSparse_Base_Methods.hpp
1 
9 #pragma once
10 
11 namespace IVSparse {
12 
13  // Calculates the number of bytes needed to store a value
14  inline uint8_t SparseMatrixBase::byteWidth(size_t size) {
15  if (size <= ONE_BYTE_MAX) { return 1; }
16  else if (size <= TWO_BYTE_MAX) { return 2; }
17  else if (size <= FOUR_BYTE_MAX) { return 4; }
18  else { return 8; }
19  }
20 
21  // Gets the number of rows in the matrix
22  uint32_t SparseMatrixBase::rows() const { return numRows; }
23 
24  // Gets the number of columns in the matrix
25  uint32_t SparseMatrixBase::cols() const { return numCols; }
26 
27  // Gets the inner dimension of the matrix
28  uint32_t SparseMatrixBase::innerSize() const { return innerDim; }
29 
30  // Gets the outer dimension of the matrix
31  uint32_t SparseMatrixBase::outerSize() const { return outerDim; }
32 
33  // Gets the number of non-zero elements in the matrix
34  uint32_t SparseMatrixBase::nonZeros() const { return nnz; }
35 
36  // Gets the number of bytes needed to store the matrix
37  size_t SparseMatrixBase::byteSize() const { return compSize; }
38 
39 } // namespace IVSparse
uint32_t innerSize() const
Definition: IVSparse_Base_Methods.hpp:28
uint32_t nonZeros() const
Definition: IVSparse_Base_Methods.hpp:34
uint32_t cols() const
Definition: IVSparse_Base_Methods.hpp:25
size_t byteSize() const
Definition: IVSparse_Base_Methods.hpp:37
uint32_t outerSize() const
Definition: IVSparse_Base_Methods.hpp:31
uint32_t rows() const
Definition: IVSparse_Base_Methods.hpp:22