Revision 1100
branches/threaded2/examples/threaded/mforest/qromb.c (revision 1100)  

1 
#include <math.h> 

2 
#define EPS 1.0e6 

3 
#define JMAX 20 

4 
#define JMAXP (JMAX+1) 

5 
#define K 5 

6  
7 
float qromb(float (*func)(float), float a, float b) 

8 
{ 

9 
void polint(float xa[], float ya[], int n, float x, float *y, float *dy); 

10 
float trapzd(float (*func)(float), float a, float b, int n); 

11 
void nrerror(char error_text[]); 

12 
float ss,dss; 

13 
float s[JMAXP],h[JMAXP+1]; 

14 
int j; 

15  
16 
h[1]=1.0; 

17 
for (j=1;j<=JMAX;j++) { 

18 
s[j]=trapzd(func,a,b,j); 

19 
if (j >= K) { 

20 
polint(&h[jK],&s[jK],K,0.0,&ss,&dss); 

21 
if (fabs(dss) <= EPS*fabs(ss)) return ss; 

22 
} 

23 
h[j+1]=0.25*h[j]; 

24 
} 

25 
nrerror("Too many steps in routine qromb"); 

26 
return 0.0; 

27 
} 

28 
#undef EPS 

29 
#undef JMAX 

30 
#undef JMAXP 

31 
#undef K 
branches/threaded2/examples/threaded/mforest/ders.dat (revision 1100)  

1 
index analytical finite % error 

2 
difference 

3 
1 2546.83 2546.83 2.94053e09 

4 
2 0.773261 0.773256 6.59409e06 
branches/threaded2/examples/threaded/mforest/t.out (revision 1100)  

1 
Error trying to open data input file ./mforestnothreads.dat 

2  
3 
z = 3; beta = 0.666667; sigma = 0.135335 

4 
tau = 1; nu = 1; a(a_index) 0.04 

5  
6 
z = 3; beta = 0.666667; sigma = 0.135335 

7 
tau = 1; nu = 1; a(a_index) 0.04 

8  
9 
z = 0; beta = 0.666667; sigma = 0.135335 

10 
tau = 1; nu = 1; a(a_index) 0.04 

11  
12 
z = 1.5; beta = 0.666667; sigma = 0.135335 

13 
tau = 1; nu = 1; a(a_index) 0.04 

14  
15 
z = 1.5; beta = 0.666667; sigma = 0.135335 

16 
tau = 1; nu = 1; a(a_index) 0.04 

17  
18 
z = 2.25; beta = 0.666667; sigma = 0.135335 

19 
tau = 1; nu = 1; a(a_index) 0.04 

20  
21 
z = 0.75; beta = 0.666667; sigma = 0.135335 

22 
tau = 1; nu = 1; a(a_index) 0.04 

23  
24 
z = 0.75; beta = 0.666667; sigma = 0.135335 

25 
tau = 1; nu = 1; a(a_index) 0.04 

26  
27 
z = 2.25; beta = 0.666667; sigma = 0.135335 

28 
tau = 1; nu = 1; a(a_index) 0.04 

29  
30 
z = 2.625; beta = 0.666667; sigma = 0.135335 

31 
tau = 1; nu = 1; a(a_index) 0.04 

32  
33 
z = 1.875; beta = 0.666667; sigma = 0.135335 

34 
tau = 1; nu = 1; a(a_index) 0.04 

35  
36 
z = 1.125; beta = 0.666667; sigma = 0.135335 

37 
tau = 1; nu = 1; a(a_index) 0.04 

38  
39 
z = 0.375; beta = 0.666667; sigma = 0.135335 

40 
tau = 1; nu = 1; a(a_index) 0.04 

41  
42 
z = 0.375; beta = 0.666667; sigma = 0.135335 

43 
tau = 1; nu = 1; a(a_index) 0.04 

44  
45 
z = 1.125; beta = 0.666667; sigma = 0.135335 

46 
tau = 1; nu = 1; a(a_index) 0.04 

47  
48 
z = 1.875; beta = 0.666667; sigma = 0.135335 

49 
tau = 1; nu = 1; a(a_index) 0.04 

50  
51 
z = 2.625; beta = 0.666667; sigma = 0.135335 
Also available in: Unified diff