-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathspmat.h
More file actions
29 lines (21 loc) · 841 Bytes
/
Copy pathspmat.h
File metadata and controls
29 lines (21 loc) · 841 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
#ifndef _SPMAT_H
#define _SPMAT_H
typedef struct _spmat {
/* Matrix size (n*n) */
int n;
/* Adds row i the matrix. Called before any other call,
* exactly n times in order (i = 0 to n-1) */
void (*add_row)(struct _spmat *A, double *row, int i);
/* Frees all resources used by A */
void (*free)(struct _spmat *A);
/* Multiplies matrix A by vector v, into result (result is pre-allocated) */
void (*mult)(struct _spmat *A, double *v, double *result);
/* Private field for inner implementation.
* Should not be read or modified externally */
void *private;
} spmat;
/* Allocates a new linked-lists sparse matrix of size n */
spmat* spmat_allocate_list(int n);
/* Allocates a new arrays sparse matrix of size n with nnz non-zero elements */
spmat* spmat_allocate_array(int n, int nnz);
#endif