1 #include <gsl/gsl_matrix.h> 2 #include <gsl/gsl_blas.h> 3 #include <gsl/gsl_linalg.h> 12 #define MAX_CONTEXTS 1024 71 fprintf(stderr,
"Val is from invalid context (%d>%d)\n",context,
cid);
76 fprintf(stderr,
"Val is invalid (%d>%d)\n",var_index,
104 fprintf(stderr,
"egsl: maximum number of contexts reached \n");
121 fprintf(stderr,
"egsl: context mismatch. You want to pop '%s', you are still at '%s'\n",
148 fprintf(stderr,
"egsl: total allocations: %d cache hits: %d\n",
154 fprintf(stderr,
"egsl: context #%d allocations: %d active: %d name: '%s' \n",
166 fprintf(stderr,
"Limit reached, in context %d, nvars is %d\n",cid,c->
nvars);
169 int index = c->
nvars;
172 if(m->size1 == rows && m->size2 == columns) {
179 c->
vars[index].
gsl_m = gsl_matrix_alloc((
size_t)rows,(
size_t)columns);
185 c->
vars[index].
gsl_m = gsl_matrix_alloc((
size_t)rows,(
size_t)columns);
196 fprintf(stderr,
"Limit reached, in context %d, nvars is %d\n",context,c->
nvars);
199 int index = c->
nvars;
202 if(m->size1 == rows && m->size2 == columns) {
209 c->
vars[index].
gsl_m = gsl_matrix_alloc((
size_t)rows,(
size_t)columns);
215 c->
vars[index].
gsl_m = gsl_matrix_alloc((
size_t)rows,(
size_t)columns);
231 gsl_matrix_memcpy(m2, m);
241 int bad = (rows && (m->size1!=rows)) || (cols && (m->size2!=cols));
243 fprintf(stderr,
"Matrix size is %d,%d while I expect %d,%d",
244 (
int)m->size1,(
int)m->size2,(
int)rows,(
int)cols);
256 fprintf(stderr,
"%s = (%d x %d) context=%d index=%d\n",
257 str,(
int)m->size1,(
int)m->size2, context, var_index);
259 for(i=0;i<m->size1;i++) {
261 fprintf(stderr,
" [ ");
263 fprintf(stderr,
" ");
265 for(j=0;j<m->size2;j++)
266 fprintf(stderr,
"%f ", gsl_matrix_get(m,i,j));
270 fprintf(stderr,
"] \n");
272 fprintf(stderr,
"; \n");
278 return gsl_matrix_ptr(m,(
size_t)i,(
size_t)j);
287 for(i=0;i<m->size1;i++) {
288 double v = gsl_matrix_get(m,i,0);
static struct egsl_context egsl_contexts[MAX_CONTEXTS]
struct egsl_variable vars[MAX_VALS]
int egsl_total_allocations
val egsl_alloc(size_t rows, size_t columns)
void check_valid_val(val v)
val egsl_alloc_in_context(int context, size_t rows, size_t columns)
double egsl_atm(val v1, size_t i, size_t j)
void egsl_expect_size(val v, size_t rows, size_t cols)
gsl_matrix * egsl_gslm(val v)
void egsl_push_named(const char *name)
double * egsl_atmp(val v, size_t i, size_t j)
double egsl_atv(val v1, size_t i)
val assemble_val(int cid, int index, gsl_matrix *m)
void egsl_pop_named(const char *name)
void egsl_print(const char *str, val v)