Category : C Source Code
Archive   : RECIPEX.ZIP
Filename : XHUNT.C

 
Output of file : XHUNT.C contained in archive : RECIPEX.ZIP
/* Driver for routine HUNT */

#include
#include
#include "nr.h"
#include "nrutil.h"

#define N 100

main()
{
int i,j,ji;
float x,*xx;

xx=vector(1,N);
/* create array to be searched */
for (i=1;i<=N;i++)
xx[i]=exp(i/20.0)-74.0;
printf("\n result of: j=0 indicates x too small\n");
printf("%14s j=100 indicates x too large"," ");
printf("\n%12s %8s %4s %11s %13s \n",
"locate:","guess","j","xx(j)","xx(j+1)");
/* do test */
for (i=1;i<=19;i++) {
x = -100.0+10.0*i;
/* trial parameter */
j=(ji=5*i);
/* begin search */
hunt(xx,N,x,&j);
if ((j < N) && (j > 0))
printf("%12.5f %6d %6d %12.6f %12.6f \n",
x,ji,j,xx[j],xx[j+1]);
else if (j == N)
printf("%12.5f %6d %6d %12.6f %s \n",
x,ji,j,xx[j]," upper lim");
else
printf("%12.5f %6d %6d %s %12.6f \n",
x,ji,j," lower lim",xx[j+1]);
}
free_vector(xx,1,N);
}


  3 Responses to “Category : C Source Code
Archive   : RECIPEX.ZIP
Filename : XHUNT.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/