egsl_misc.c
Go to the documentation of this file.
00001 #include <math.h>
00002 #include "egsl.h"
00003 
00004 val egsl_rot(double theta) {
00005         double R[2*2] = {
00006                 cos(theta), -sin(theta),
00007                 sin(theta),  cos(theta)
00008         };
00009         return egsl_vFda(2,2,R);
00010 }
00011 
00012 val egsl_zeros(size_t rows, size_t columns) {
00013         val v = egsl_alloc(rows,columns);
00014         gsl_matrix * m = egsl_gslm(v);
00015         gsl_matrix_set_all(m,0.0);
00016         return v;
00017 }
00018 
00019 val egsl_ones(size_t rows, size_t columns) {
00020         val v = egsl_alloc(rows,columns);
00021         gsl_matrix * m = egsl_gslm(v);
00022         gsl_matrix_set_all(m,1.0);
00023         return v;
00024 }
00025 
00026 val egsl_vers(double theta){
00027         double v[2] = { cos(theta), sin(theta)};
00028         return egsl_vFa(2,v);
00029 }
00030 
00031 void egsl_print_spectrum(const char*s, val v) {
00032         gsl_matrix *m = egsl_gslm(v);
00033         /* expect same size */
00034         size_t n = m->size1;
00035         double eval[n]; val evec[n];
00036         egsl_symm_eig(v, eval, evec);
00037         size_t i,j;
00038         for(j=0;j<n;j++) {
00039                 fprintf(stderr, "%s | eval[%d] = %+5.5f evec[%d]= ",
00040                         s, (int)j, eval[j],(int)j);
00041                 for(i=0;i<n;i++) 
00042                         fprintf(stderr, "%+4.4f ", egsl_atv(evec[j],i));
00043                 fprintf(stderr, " sqrt(eval[%d])=%5.5f  \n", (int)j, sqrt(eval[j]));
00044         }               
00045 }


csm
Author(s): Andrea Censi
autogenerated on Fri May 17 2019 02:28:33