-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.h
More file actions
43 lines (31 loc) · 1.47 KB
/
functions.h
File metadata and controls
43 lines (31 loc) · 1.47 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
#ifndef FUNCTIONS_H
#define FUNCTIONS_H
// ###########################################################
// Do not change this part
typedef struct {
double *csr_data; // Array of non-zero values
int *col_ind; // Array of column indices
int *row_ptr; // Array of row pointers
int num_non_zeros; // Number of non-zero elements
int num_rows; // Number of rows in matrix
int num_cols; // Number of columns in matrix
} CSRMatrix;
void ReadMMtoCSR(const char *filename, CSRMatrix *matrix);
void spmv_csr(const CSRMatrix *A, const double *x, double *y);
void printCSRMatrix(const CSRMatrix *matrix);
double compute_norm(const double *r, int size);
void fullMatrix(CSRMatrix *A);
void solver(CSRMatrix *A, double *x, double *b, double omega, double max_iter, double tolerance);
void sorIteration(const CSRMatrix *A, double *x, double *b, double omega);
// ###########################################################
/* <Here you can add the declaration of functions you need.>
<The actual implementation must be in functions.c>
Here what "potentially" you need:
1. A function called "solver" receiving const CSRMatrix A, double *b, double *x
and solving the linear system
2. A function called "compute_residual" to compute the residual like r=Ax-b.
This shows how much x values you found are accurate, but
printing the whole vector r might not be a good idea. So
3. A function called compute_norm to compute the norm of vector residual
*/
#endif