Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
nf_Legendre_GaussianQuadrature.cc File Reference
#include "nf_Legendre.h"

Go to the source code of this file.

Classes

struct  nf_Legendre_GaussianQuadrature_degree
 

Macros

#define n_3   3
 
#define n_4   4
 
#define n_5   5
 
#define n_10   10
 
#define n_20   20
 
#define n_40   40
 
#define nSets   6
 

Functions

nfu_status nf_Legendre_GaussianQuadrature (int degree, double x1, double x2, nf_Legendre_GaussianQuadrature_callback func, void *argList, double *integral)
 

Macro Definition Documentation

◆ n_10

#define n_10   10

Definition at line 33 of file nf_Legendre_GaussianQuadrature.cc.

◆ n_20

#define n_20   20

Definition at line 37 of file nf_Legendre_GaussianQuadrature.cc.

◆ n_3

#define n_3   3

Definition at line 21 of file nf_Legendre_GaussianQuadrature.cc.

◆ n_4

#define n_4   4

Definition at line 25 of file nf_Legendre_GaussianQuadrature.cc.

◆ n_40

#define n_40   40

Definition at line 45 of file nf_Legendre_GaussianQuadrature.cc.

◆ n_5

#define n_5   5

Definition at line 29 of file nf_Legendre_GaussianQuadrature.cc.

◆ nSets

#define nSets   6

Definition at line 57 of file nf_Legendre_GaussianQuadrature.cc.

Function Documentation

◆ nf_Legendre_GaussianQuadrature()

nfu_status nf_Legendre_GaussianQuadrature ( int  degree,
double  x1,
double  x2,
nf_Legendre_GaussianQuadrature_callback  func,
void *  argList,
double *  integral 
)

Definition at line 63 of file nf_Legendre_GaussianQuadrature.cc.

63 {
64
65 int i, n;
66 double x, mu, sum, *weights, *xis;
67 nfu_status status = nfu_Okay;
68
69 *integral = 0;
70 if( degree < 2 ) {
71 status = func( 0.5 * ( x1 + x2 ), integral, argList );
72 *integral *= 2.; }
73 else if( degree < 4 ) {
74 x = 0.5 * ( -sqrt_inv3 * ( x2 - x1 ) + x1 + x2 );
75 if( ( status = func( x, integral, argList ) ) == nfu_Okay ) {
76 x = 0.5 * ( sqrt_inv3 * ( x2 - x1 ) + x1 + x2 );
77 status = func( x, &sum, argList );
78 *integral += sum;
79 } }
80 else {
81 for( i = 0; i < nSets - 1; i++ ) {
82 if( GaussianQuadrature_degrees[i].n > ( degree + 1 ) / 2 ) break;
83 }
84 n = ( GaussianQuadrature_degrees[i].n + 1 ) / 2;
85 weights = GaussianQuadrature_degrees[i].weights;
86 xis = GaussianQuadrature_degrees[i].xis;
87 for( i = 0; i < n; i++ ) {
88 mu = xis[i];
89 x = 0.5 * ( x1 * ( 1 - mu ) + x2 * ( mu + 1 ) );
90 if( ( status = func( x, &sum, argList ) ) != nfu_Okay ) break;
91 *integral += sum * weights[i];
92 if( mu == 0 ) continue;
93 x = x1 + x2 - x;
94 if( ( status = func( x, &sum, argList ) ) != nfu_Okay ) break;
95 *integral += sum * weights[i];
96 }
97 }
98 *integral *= 0.5 * ( x2 - x1 );
99 return( status );
100}
@ nfu_Okay
Definition: nf_utilities.h:25
enum nfu_status_e nfu_status

Referenced by nf_Legendre_from_ptwXY().