-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmtx_loader.h
More file actions
32 lines (27 loc) · 932 Bytes
/
mtx_loader.h
File metadata and controls
32 lines (27 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once
#include <cstdint>
#include <string>
#include <vector>
namespace sbfft {
// Binary sparse matrix in CSR form. Values are implicit 1 (any numeric
// values in the .mtx are discarded). After load, the matrix is
// symmetrically expanded if the .mtx had `symmetric` qualifier, sorted by
// (row, col), and deduplicated.
struct CsrBinary {
int N = 0;
int64_t nnz = 0;
std::vector<int> rowPtr; // length N+1
std::vector<int> colIdx; // length nnz
};
// Loads `path` (a .mtx file). On first load, parses the .mtx and writes a
// `path + ".bin"` cache; on subsequent loads, reads the cache directly.
CsrBinary load_mtx(const std::string& path, bool verbose = true);
// Statistics helper (max / min / mean nonzeros per row, empty rows).
struct RowStats {
int min_k;
int max_k;
double mean_k;
int empty_rows;
};
RowStats compute_row_stats(const CsrBinary& csr);
} // namespace sbfft