roadrunner  2.6.0
Fast simulator for SBML models
rrSparse.h
1 /*
2  * rrCSparse.h
3  *
4  * Created on: Jul 10, 2013
5  * Author: andy
6  */
7 
8 #ifndef RRCSPARSE_H_
9 #define RRCSPARSE_H_
10 
11 #include "rrOSSpecifics.h"
12 #include <vector>
13 #include <ostream>
14 
15 namespace rr
16 {
17 
27 typedef struct csr_matrix_t
28 {
32  unsigned m;
33 
37  unsigned n;
38 
42  unsigned nnz;
43 
49  double* values;
50 
55  unsigned* colidx;
56 
66  unsigned* rowptr;
67 
68 } csr_matrix;
80 csr_matrix* csr_matrix_new(unsigned m, unsigned n,
81  const std::vector<unsigned>& rowidx, const std::vector<unsigned>& colidx,
82  const std::vector<double>& values);
83 
88 void csr_matrix_delete(csr_matrix *mat);
89 
95 bool csr_matrix_set_nz(csr_matrix *mat, unsigned row, unsigned col, double val);
96 
102 double csr_matrix_get_nz(const csr_matrix *mat, unsigned row, unsigned col);
103 
112 void csr_matrix_dgemv(double alpha, const csr_matrix *A,
113  double const *x, double beta, double *y);
114 
121 double csr_matrix_ddot(size_t row, const csr_matrix *x, const double *y);
122 
126 void csr_matrix_fill_dense(const csr_matrix *x, double *dense);
127 
128 void csr_matrix_dump_binary(const csr_matrix *x, std::ostream& out);
129 csr_matrix* csr_matrix_new_from_binary(std::istream&);
133 std::ostream& operator<< (std::ostream& os, const csr_matrix* mat);
134 
135 
136 }
137 
138 #endif /* RRCSPARSE_H_ */