File: jacobi.C

package info (click to toggle)
lorene 0.0.0~cvs20161116%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 26,472 kB
  • sloc: cpp: 212,946; fortran: 21,645; makefile: 1,750; sh: 4
file content (24 lines) | stat: -rw-r--r-- 385 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
namespace Lorene {

double* jacobi(int n, double x) {

  int i ;
  double* J = new double[n+1] ;

  if (n==0) {

    J[0] = double(1) ;
  }
  else {

    J[0] = double(1) ;
    J[1] = double(2) * x - 1 ;
    for ( i = 2 ; i < n+1 ; i++) {
      double l = double(i) ;
      J[i] = ((2*l + 1)*(l*(l+1)*x - 1)*J[i-1] - (l-1)*(l+1)*(l+1)*J[i-2])/(l*l*(l+2)) ;

    }
  }
  return J ;
}
}