File: specfun2.c

package info (click to toggle)
gsl 2.8%2Bdfsg-5.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 29,088 kB
  • sloc: ansic: 269,984; sh: 4,535; makefile: 902; python: 69
file content (29 lines) | stat: -rw-r--r-- 748 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <stdio.h>
#include <gsl/gsl_math.h>
#include <gsl/gsl_sf_legendre.h>
#include <gsl/gsl_sf_alf.h>

int
main(void)
{
  const size_t lmax = 5;
  const size_t plm_size = gsl_sf_legendre_array_n(lmax);
  const size_t nlm = gsl_sf_legendre_nlm(lmax);
  const size_t idx21 = gsl_sf_legendre_array_index(2, 1);
  double * Plm = malloc(plm_size * sizeof(double));
  double * dPlm = malloc(nlm * sizeof(double));
  double * d2Plm = malloc(nlm * sizeof(double));
  double x;

  for (x = -0.99; x <= 0.99; x += 0.01)
    {
      gsl_sf_legendre_deriv2_alt_array(GSL_SF_LEGENDRE_SPHARM, lmax, x, Plm, dPlm, d2Plm);
      printf("%f %e %e %e\n", x, Plm[idx21], dPlm[idx21], d2Plm[idx21]);
    }

  free(Plm);
  free(dPlm);
  free(d2Plm);

  return 0;
}