1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
#ifndef sundarmain_c
#define sundarmain_c
/* Driver for routine vegas */
#define NRANSI
#include "subroutines.h"
#include "sundarmain.h"
#include "subs.h"
#include "sundarf2.h"
#include "dnr.h"
#include "dnrutil.h"
#include "sundarcom.h"
int main()
{
long init,itmax,j,ncall,nprn,itype;
double avgi,chi2a,sd,xoff;
double *regn;
if ((data_file = fopen("vegas.dat","r")) == NULL) nrerror("data file Error");
output_file = fopen("vegas.out","w");
summary_file = fopen("vegas.sum","w");
plot_file = fopen("vegas.plot","w");
regn=vector(1,20);
idum = -10;
ReadLong(&itype,"itype");
ReadLong(&ndim,"ndim");
ReadDouble(&xoff,"xoff");
ReadLong(&ncall,"ncall");
ReadLong(&itmax,"itmax");
ReadLong(&nprn,"nprn");
ReadLong(&iwrite,"iwrite");
avgi=sd=chi2a=0.0;
for (j=1;j<=ndim;j++)
{
regn[j]=0.0;
regn[j+ndim]=1.0;
}
init = -1;
if (itype == 0) vegas(regn,ndim,fxn,init,ncall,itmax,nprn,&avgi,&sd,&chi2a); /* checking version */
if (itype == 1) vegas(regn,ndim,func,init,ncall,itmax,nprn,&avgi,&sd,&chi2a); /* real version */
printf("Number of iterations performed: %d\n",itmax);
printf("Integral, Standard Dev., Chi-sq. = %12.6f %12.6f% 12.6f\n",
avgi,sd,chi2a);
fprintf(output_file,"Number of iterations performed: %d\n",itmax);
fprintf(output_file," Standard Dev., Chi-sq. = %12.6f %12.6f% 12.6f\n",avgi,sd,chi2a);
init = 1;
if (itype == 0) vegas(regn,ndim,fxn,init,ncall,itmax,nprn,&avgi,&sd,&chi2a); /* checking version */
if (itype == 1) vegas(regn,ndim,func,init,ncall,itmax,nprn,&avgi,&sd,&chi2a); /* real version */
fprintf(output_file,"Additional iterations performed: %d \n",itmax);
fprintf(output_file,"Integral, Standard Dev., Chi-sq. = %12.6f %12.6f% 12.6f\n",
avgi,sd,chi2a);
exit(1);
free_vector(regn,1,20);
printf("Normal completion\n");
return 0;
}
#undef NRANSI
#endif
| |