-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCOO_Matrix.h
More file actions
48 lines (40 loc) · 1.35 KB
/
COO_Matrix.h
File metadata and controls
48 lines (40 loc) · 1.35 KB
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
45
46
47
48
#ifndef COO_MATRIX_H
#define COO_MATRIX_H
#include "CSR_Matrix.h"
#include <stddef.h>
/* COO (Coordinate) Sparse Matrix Format
*
* For an m x n matrix with nnz nonzeros:
* - rows: array of size nnz containing row indices
* - cols: array of size nnz containing column indices
* - x: array of size nnz containing values
* - value_map: array of size nnz mapping CSR entries to COO entries (for
* lower-triangular COO)
* - m: number of rows
* - n: number of columns
* - nnz: number of nonzero entries
*/
typedef struct COO_Matrix
{
int *rows;
int *cols;
double *x;
int *value_map;
int m;
int n;
int nnz;
} COO_Matrix;
/* Construct a COO matrix from a CSR matrix */
COO_Matrix *new_coo_matrix(const CSR_Matrix *A);
/* Construct a COO matrix containing only the lower-triangular
* entries (col <= row) of a symmetric CSR matrix. Populates
* value_map so that refresh_lower_triangular_coo can update
* values without recomputing structure. */
COO_Matrix *new_coo_matrix_lower_triangular(const CSR_Matrix *A);
/* Refresh COO values from a new CSR value array using value_map */
void refresh_lower_triangular_coo(COO_Matrix *coo, const double *vals);
void free_coo_matrix(COO_Matrix *matrix);
/* Returns total bytes used by rows, cols, x, value_map arrays
(0 if A is NULL) */
size_t coo_bytes(const COO_Matrix *A);
#endif /* COO_MATRIX_H */