IVSparse  v1.0
A sparse matrix compression library.
IVSparse_Base_Methods.hpp
Go to the documentation of this file.
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) {
16  return 1;
17  } else if (size <= TWO_BYTE_MAX) {
18  return 2;
19  } else if (size <= FOUR_BYTE_MAX) {
20  return 4;
21  } else {
22  return 8;
23  }
24 }
25 
26 // Gets the number of rows in the matrix
27 uint32_t SparseMatrixBase::rows() const { return numRows; }
28 
29 // Gets the number of columns in the matrix
30 uint32_t SparseMatrixBase::cols() const { return numCols; }
31 
32 // Gets the inner dimension of the matrix
33 uint32_t SparseMatrixBase::innerSize() const { return innerDim; }
34 
35 // Gets the outer dimension of the matrix
36 uint32_t SparseMatrixBase::outerSize() const { return outerDim; }
37 
38 // Gets the number of non-zero elements in the matrix
39 uint32_t SparseMatrixBase::nonZeros() const { return nnz; }
40 
41 // Gets the number of bytes needed to store the matrix
42 size_t SparseMatrixBase::byteSize() const { return compSize; }
43 
44 } // namespace IVSparse
uint32_t innerSize() const
Definition: IVSparse_Base_Methods.hpp:33
uint32_t nonZeros() const
Definition: IVSparse_Base_Methods.hpp:39
uint32_t cols() const
Definition: IVSparse_Base_Methods.hpp:30
size_t byteSize() const
Definition: IVSparse_Base_Methods.hpp:42
uint32_t outerSize() const
Definition: IVSparse_Base_Methods.hpp:36
uint32_t rows() const
Definition: IVSparse_Base_Methods.hpp:27