egsl_misc.c
Go to the documentation of this file.
1 #include <math.h>
2 #include "egsl.h"
3 
4 val egsl_rot(double theta) {
5  double R[2*2] = {
6  cos(theta), -sin(theta),
7  sin(theta), cos(theta)
8  };
9  return egsl_vFda(2,2,R);
10 }
11 
12 val egsl_zeros(size_t rows, size_t columns) {
13  val v = egsl_alloc(rows,columns);
14  gsl_matrix * m = egsl_gslm(v);
15  gsl_matrix_set_all(m,0.0);
16  return v;
17 }
18 
19 val egsl_ones(size_t rows, size_t columns) {
20  val v = egsl_alloc(rows,columns);
21  gsl_matrix * m = egsl_gslm(v);
22  gsl_matrix_set_all(m,1.0);
23  return v;
24 }
25 
26 val egsl_vers(double theta){
27  double v[2] = { cos(theta), sin(theta)};
28  return egsl_vFa(2,v);
29 }
30 
31 void egsl_print_spectrum(const char*s, val v) {
32  gsl_matrix *m = egsl_gslm(v);
33  /* expect same size */
34  size_t n = m->size1;
35  double eval[n]; val evec[n];
36  egsl_symm_eig(v, eval, evec);
37  size_t i,j;
38  for(j=0;j<n;j++) {
39  fprintf(stderr, "%s | eval[%d] = %+5.5f evec[%d]= ",
40  s, (int)j, eval[j],(int)j);
41  for(i=0;i<n;i++)
42  fprintf(stderr, "%+4.4f ", egsl_atv(evec[j],i));
43  fprintf(stderr, " sqrt(eval[%d])=%5.5f \n", (int)j, sqrt(eval[j]));
44  }
45 }
void egsl_print_spectrum(const char *s, val v)
Definition: egsl_misc.c:31
val egsl_zeros(size_t rows, size_t columns)
Definition: egsl_misc.c:12
Definition: egsl.h:12
val egsl_ones(size_t rows, size_t columns)
Definition: egsl_misc.c:19
val egsl_alloc(size_t rows, size_t columns)
Definition: egsl.c:159
#define m(v1, v2)
Definition: egsl_macros.h:13
val egsl_rot(double theta)
Definition: egsl_misc.c:4
val egsl_vFa(size_t rows, const double *)
gsl_matrix * egsl_gslm(val v)
Definition: egsl.c:83
double egsl_atv(val v1, size_t i)
Definition: egsl.c:294
val egsl_vers(double theta)
Definition: egsl_misc.c:26
void egsl_symm_eig(val v, double *eigenvalues, val *eigenvectors)
Definition: egsl_ops.c:133
val egsl_vFda(size_t rows, size_t columns, const double *)


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