-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsparse_matrix.h
More file actions
44 lines (39 loc) · 960 Bytes
/
sparse_matrix.h
File metadata and controls
44 lines (39 loc) · 960 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
33
34
35
36
37
38
39
40
41
42
43
44
#define ll long long int
enum matrix_descr{
CSR,
COO
};
enum matrix_order{
COLUMN_MAJOR,
ROW_MAJOR
};
enum matrix_index{
INDEX_BASE_ZERO,
INDEX_BASE_ONE
};
enum memory_type{
CPU,
GPU
};
typedef struct sparse_matrix_t {
enum matrix_descr descr;
enum matrix_order order;
enum matrix_index index;
enum memory_type memtype;
ll n,m,nnz;
ll *rows, *cols;
int *irows, *icols;
float *vals;
}sparse_matrix_t;
#ifdef __cplusplus
extern "C" {
#endif
void sparseMatrixMalloc(sparse_matrix_t* A);
void printMatrix(sparse_matrix_t* A);
void sparseMatrixCopy(sparse_matrix_t* A, sparse_matrix_t* B, enum memory_type mem);
void sparseMatrixFree(sparse_matrix_t* A);
void coo2csr(sparse_matrix_t* A);
void getSubMatrix(sparse_matrix_t* A, sparse_matrix_t* sub, sparse_matrix_t *d_A, sparse_matrix_t *d_sub, ll rowL, ll rowR, ll colL, ll colR, int cpy2cpu);
#ifdef __cplusplus
}
#endif