ReFRACtor
rf_gauleg.cc
Go to the documentation of this file.
1 #include "rf_gauleg.h"
2 
3 // Gauss-Legendre Integration
5 
6  X.resize(KNUM);
7  W.resize(KNUM);
8 
9  int I2, M;
10  double P1,P2,P3,PP,Z,Z1,ZM1,ZP1,HELP,ZH;
11  const double EPS = 3.e-14;
12 
13  AutoDerivative<double> XL = 0.5e0 * ( X2 - X1 );
14  M=(KNUM+1)/2;
15  for(int I1 = 1; I1 <= M; I1++) {
16  I2 = KNUM + 1 - I1;
17  Z = cos(3.141592654E0 * (I1-.25E0) / (KNUM +.5E0));
18  do {
19  P1=1.E0;
20  P2=0.E0;
21  for(int L=1; L <= KNUM; L++) {
22  P3=P2;
23  P2=P1;
24  P1=((2.E0*L-1.E0)*Z*P2-(L-1.E0)*P3)/L;
25  }
26  PP=KNUM*(Z*P1-P2)/(Z*Z-1.E0);
27  Z1=Z;
28  Z=Z1-P1/PP;
29  } while (fabs(Z-Z1) > EPS);
30  ZH = 0.5e0 * Z;
31  ZP1 = 0.5e0 + ZH;
32  ZM1 = 0.5e0 - ZH;
33  X(I1-1) = ZM1 * X2 + ZP1 * X1;
34  X(I2-1) = ZP1 * X2 + ZM1 * X1;
35  HELP = 2.E0/((1.E0-Z*Z)*PP*PP);
36  W(I1-1) = HELP * XL;
37  W(I2-1) = W(I1-1);
38  }
39 }
void rf_gauleg(AutoDerivative< double > X1, AutoDerivative< double > X2, blitz::Array< AutoDerivative< double >, 1 > &X, blitz::Array< AutoDerivative< double >, 1 > &W, int KNUM)
Definition: rf_gauleg.cc:4
const Unit W("W", J/s)

Copyright © 2017, California Institute of Technology.
ALL RIGHTS RESERVED.
U.S. Government Sponsorship acknowledged.
Generated Fri Aug 24 2018 15:44:11