egsl_conversions.c
Go to the documentation of this file.
00001 #include "egsl.h"
00002 
00003 val egsl_vFda(size_t rows, size_t cols, const double *a) {
00004         val v = egsl_alloc(rows, cols);
00005 
00006         size_t i; size_t j;
00007         for(i=0;i<rows;i++)
00008         for(j=0;j<cols;j++) {
00009                 *egsl_atmp(v,i,j) = a[j+i*cols];
00010         }
00011         return v;
00012 }
00013 
00014 val egsl_vFa(size_t rows, const double*a) {
00015         val v = egsl_alloc(rows,1);
00016         size_t i;
00017         for(i=0;i<rows;i++)
00018                 *egsl_atmp(v,i,0) =  a[i];
00019         return v;
00020 }
00021 
00022 void egsl_v2a(val v, double*vec) {
00023         gsl_matrix *m = egsl_gslm(v);
00024         size_t i;
00025         for(i=0; i < m->size1; i++)
00026                 vec[i] = gsl_matrix_get(m,i,0);
00027 }
00028 
00029 void egsl_v2da(val v, double*a){
00030         gsl_matrix *m = egsl_gslm(v);
00031         size_t i,j;
00032         for(i=0;i<m->size1;i++)
00033                 for(j=0;j<m->size2;j++)
00034                         a[j*m->size1 +i] = gsl_matrix_get(m,i,j);
00035 }
00036 
00037 void egsl_v2vec(val v, gsl_vector*vec) {
00038         size_t i;
00039         for(i=0;i<vec->size;i++)
00040                 gsl_vector_set(vec,i, *egsl_atmp(v,i,0));
00041 }
00042 
00043 
00044 val egsl_vFgslv(const gsl_vector*vec){
00045         val v = egsl_alloc(vec->size,1);
00046         size_t i;
00047         for(i=0;i<vec->size;i++)
00048                 *egsl_atmp(v,i,0) = gsl_vector_get(vec,i);
00049         return v;
00050 }
00051 
00052 val egsl_vFgslm(const gsl_matrix*m){
00053         val v = egsl_alloc(m->size1,m->size2);
00054         gsl_matrix * m2 = egsl_gslm(v);
00055         gsl_matrix_memcpy(m2,m);
00056         return v;
00057 }
00058 
00059 gsl_matrix* egsl_v2gslm(val v){
00060         gsl_matrix * m = egsl_gslm(v); 
00061         gsl_matrix * m2 = gsl_matrix_alloc(m->size1,m->size2);
00062         gsl_matrix_memcpy(m2,m);
00063         return m2;
00064 }


csm
Author(s): Andrea Censi
autogenerated on Mon Jan 16 2017 03:48:29