Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:13:30

0001 //Simpson integrator, written to mirror CERNLIBS one
0002 
0003 #include <cmath>
0004 
0005 double dsimps_(double* F,double* A,double* B,int* N){
0006   
0007   double a = *A;
0008   double b = *B;
0009   int n = *N;
0010   double deltaX = (b-a)/n;
0011   double I=F[0] + F[n];
0012   
0013   for(int i=1;i<=n/2;i++){
0014     int j=2*i;
0015     int k =2*i-1;
0016     if(j<n) I += 2*F[j];
0017     if(k<n) I += 4*F[k];
0018     
0019   }
0020   return(I*deltaX/3);
0021 }