sparse_sys.h
Go to the documentation of this file.
1 /*
2  Copyright 2010 SINTEF ICT, Applied Mathematics.
3 
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef OPM_SPARSE_SYS_HEADER_INCLUDED
21 #define OPM_SPARSE_SYS_HEADER_INCLUDED
22 
28 #include <stddef.h>
29 #include <stdio.h>
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
38 struct CSRMatrix
39 {
40  size_t m;
41  size_t nnz;
43  int *ia;
44  int *ja;
46  double *sa;
47 };
48 
49 
65 struct CSRMatrix *
67 
68 
88 struct CSRMatrix *
89 csrmatrix_new_known_nnz(size_t m, size_t nnz);
90 
91 
114 size_t
116 
117 
129 size_t
130 csrmatrix_elm_index(int i, int j, const struct CSRMatrix *A);
131 
132 
147 void
148 csrmatrix_sortrows(struct CSRMatrix *A);
149 
150 
161 void
162 csrmatrix_delete(struct CSRMatrix *A);
163 
164 
171 void
172 csrmatrix_zero(struct CSRMatrix *A);
173 
174 
181 void
182 vector_zero(size_t n, double *v);
183 
184 
198 void
199 csrmatrix_write(const struct CSRMatrix *A, const char *fn);
200 
201 
214 void
215 csrmatrix_write_stream(const struct CSRMatrix *A, FILE *fp);
216 
217 
230 void
231 vector_write(size_t n, const double *v, const char *fn);
232 
233 
245 void
246 vector_write_stream(size_t n, const double *v, FILE *fp);
247 
248 #ifdef __cplusplus
249 }
250 #endif
251 
252 #endif /* OPM_SPARSE_SYS_HEADER_INCLUDED */
int * ja
Definition: sparse_sys.h:44
int * ia
Definition: sparse_sys.h:43
Definition: sparse_sys.h:38
void vector_zero(size_t n, double *v)
size_t m
Definition: sparse_sys.h:40
void csrmatrix_delete(struct CSRMatrix *A)
void csrmatrix_write(const struct CSRMatrix *A, const char *fn)
struct CSRMatrix * csrmatrix_new_known_nnz(size_t m, size_t nnz)
size_t nnz
Definition: sparse_sys.h:41
void vector_write(size_t n, const double *v, const char *fn)
size_t csrmatrix_elm_index(int i, int j, const struct CSRMatrix *A)
void csrmatrix_write_stream(const struct CSRMatrix *A, FILE *fp)
double * sa
Definition: sparse_sys.h:46
void csrmatrix_zero(struct CSRMatrix *A)
size_t csrmatrix_new_elms_pushback(struct CSRMatrix *A)
struct CSRMatrix * csrmatrix_new_count_nnz(size_t m)
void vector_write_stream(size_t n, const double *v, FILE *fp)
void csrmatrix_sortrows(struct CSRMatrix *A)