egsl_conversions.c
Go to the documentation of this file.
1 #include "egsl.h"
2 
3 val egsl_vFda(size_t rows, size_t cols, const double *a) {
4  val v = egsl_alloc(rows, cols);
5 
6  size_t i; size_t j;
7  for(i=0;i<rows;i++)
8  for(j=0;j<cols;j++) {
9  *egsl_atmp(v,i,j) = a[j+i*cols];
10  }
11  return v;
12 }
13 
14 val egsl_vFa(size_t rows, const double*a) {
15  val v = egsl_alloc(rows,1);
16  size_t i;
17  for(i=0;i<rows;i++)
18  *egsl_atmp(v,i,0) = a[i];
19  return v;
20 }
21 
22 void egsl_v2a(val v, double*vec) {
23  gsl_matrix *m = egsl_gslm(v);
24  size_t i;
25  for(i=0; i < m->size1; i++)
26  vec[i] = gsl_matrix_get(m,i,0);
27 }
28 
29 void egsl_v2da(val v, double*a){
30  gsl_matrix *m = egsl_gslm(v);
31  size_t i,j;
32  for(i=0;i<m->size1;i++)
33  for(j=0;j<m->size2;j++)
34  a[j*m->size1 +i] = gsl_matrix_get(m,i,j);
35 }
36 
37 void egsl_v2vec(val v, gsl_vector*vec) {
38  size_t i;
39  for(i=0;i<vec->size;i++)
40  gsl_vector_set(vec,i, *egsl_atmp(v,i,0));
41 }
42 
43 
44 val egsl_vFgslv(const gsl_vector*vec){
45  val v = egsl_alloc(vec->size,1);
46  size_t i;
47  for(i=0;i<vec->size;i++)
48  *egsl_atmp(v,i,0) = gsl_vector_get(vec,i);
49  return v;
50 }
51 
52 val egsl_vFgslm(const gsl_matrix*m){
53  val v = egsl_alloc(m->size1,m->size2);
54  gsl_matrix * m2 = egsl_gslm(v);
55  gsl_matrix_memcpy(m2,m);
56  return v;
57 }
58 
59 gsl_matrix* egsl_v2gslm(val v){
60  gsl_matrix * m = egsl_gslm(v);
61  gsl_matrix * m2 = gsl_matrix_alloc(m->size1,m->size2);
62  gsl_matrix_memcpy(m2,m);
63  return m2;
64 }
Definition: egsl.h:12
void egsl_v2a(val v, double *vec)
void egsl_v2vec(val v, gsl_vector *vec)
gsl_matrix * egsl_v2gslm(val v)
val egsl_alloc(size_t rows, size_t columns)
Definition: egsl.c:159
#define m(v1, v2)
Definition: egsl_macros.h:13
val egsl_vFgslv(const gsl_vector *vec)
val egsl_vFgslm(const gsl_matrix *m)
gsl_matrix * egsl_gslm(val v)
Definition: egsl.c:83
void egsl_v2da(val v, double *a)
double * egsl_atmp(val v, size_t i, size_t j)
Definition: egsl.c:276
val egsl_vFda(size_t rows, size_t cols, const double *a)
val egsl_vFa(size_t rows, const double *a)


csm
Author(s): Andrea Censi
autogenerated on Tue May 11 2021 02:18:23