とらりもんHOME  Index  Search  Changes  Login

とらりもん - GSL Diff

  • Added parts are displayed like this.
  • Deleted parts are displayed like this.

GSL (Gnu Scietific Library)
http://www.gnu.org/software/gsl/manual/html_node/index.html#Top

Ubuntu Linuxで...

sudo apt-get -yV install gsl-bin libgsl0-dbg libgsl0-dev libgsl0ldbl

gcc test.c -lgsl -lgslcblas


// ルジャンドル陪関数
// gcc test.c -lgsl -lgslcblas -lm
// ./a.out 6 2 >t
// gnuplot> splot "t" using ($4*sin($1)*cos($2)):($4*sin($1)*sin($2)):($4*cos($1)):($3) with pm3d

#include <stdio.h>
#include <math.h>
#include <gsl/gsl_sf_legendre.h>

int main (int argc, char** argv)
{int l, m;
  double t, p, x, y;
  l=atoi(argv[1]);
  m=atoi(argv[2]);
  for (t=0; t<M_PI; t+=0.01){
     x=gsl_sf_legendre_sphPlm(l,m,cos(t));
//     x=gsl_sf_legendre_Plm(l,m,cos(t));
     for (p=-M_PI; p<M_PI; p+=0.01){
        y=x*cos(m*p);
        printf("%lf  %lf  %lf  %lf\n", t, p, y, sqrt(y*y));
     }
   printf("\n");
  }
  return 0;
}