#include "stdio.h" #include "stdlib.h" #include "math.h" #include "paulslib.h" #include "bitmaplib.h" /* Calculate recurrence plots */ long CalcRecurrence(double *,int,int,int,double,char *); #define N 400 double *data; int npoints = 0; int main(int argc,char **argv) { int i; int delay,dimension; int dimstart=2,dimstop=5,dimstep=1; int delstart=1,delstop=10,delstep=1; long count; double radius = 0.05; double x,sum=0,sum2=0,mean,std; char basename[100]; FILE *fptr; /* Check there are enough arguments */ if (argc < 2) { fprintf(stderr,"Usage: %s datafilename\n",argv[0]); fprintf(stderr," [-dim1 %d] [-dim2 %d] [-dim3 %d]\n", dimstart,dimstop,dimstep); fprintf(stderr," [-del1 %d] [-del2 %d] [-del3 %d]\n", delstart,delstop,delstep); fprintf(stderr," [-rad %g]\n",radius); exit(0); } /* Handle the arguments */ for (i=0;i= i+1) dimstart = atoi(argv[i+1]); if (strcmp(argv[i],"-dim2") == 0 && argc >= i+1) dimstop = atoi(argv[i+1]); if (strcmp(argv[i],"-dim3") == 0 && argc >= i+1) dimstep = atoi(argv[i+1]); if (strcmp(argv[i],"-del1") == 0 && argc >= i+1) delstart = atoi(argv[i+1]); if (strcmp(argv[i],"-del2") == 0 && argc >= i+1) delstop = atoi(argv[i+1]); if (strcmp(argv[i],"-del3") == 0 && argc >= i+1) delstep = atoi(argv[i+1]); if (strcmp(argv[i],"-rad") == 0 && argc >= i+1) radius = atof(argv[i+1]); } /* Form the basename */ strcpy(basename,argv[1]); for (i=0;i= n || indexj >= n) { fprintf(stderr,"Unexpectedly passed the end of the data\n"); exit(0); } delta = data[indexi] - data[indexj]; distance += delta * delta; } distance = sqrt(distance); /* Are the two points close enough */ if (distance < radius * 2.0) { buffer2[x0][y0]++; buffer2[x1][y1]++; } if (distance < radius) { buffer1[x0][y0]++; buffer1[x1][y1]++; count++; } if (distance < radius / 2.0) { buffer0[x0][y0]++; buffer0[x1][y1]++; } } } /* Open and write bitmaps */ for (k=0;k<=2;k++) { sprintf(fname,"bw_%s_%d_%d_%d.tga",base,dim,delay,k); if ((fptr = fopen(fname,"wb")) == NULL) { fprintf(stderr,"Unable to open tga file %s\n",fname); exit(0); } Erase_Bitmap(image,N,N,cwhite); for (j=0;j 0) Draw_Pixel(image,N,N,i,j,cblack); if (k == 1 && buffer1[i][j] > 0) Draw_Pixel(image,N,N,i,j,cblack); if (k == 2 && buffer2[i][j] > 0) Draw_Pixel(image,N,N,i,j,cblack); } } Write_Bitmap(fptr,image,N,N,12); fclose(fptr); } Destroy_Bitmap(image); return(count); }