X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=website%2Farchive%2Fbinaries%2Fmac%2Fsrc%2Fdisembl%2FTisean_3.0.1%2Fsource_c%2Fboxcount.c;fp=website%2Farchive%2Fbinaries%2Fmac%2Fsrc%2Fdisembl%2FTisean_3.0.1%2Fsource_c%2Fboxcount.c;h=4ed1c94c1b3d3f04907e405969301051fe4ad6ab;hb=dbde3fb6f00b9bb770343631a517c0e599db8528;hp=0000000000000000000000000000000000000000;hpb=85f830bbd51a7277994bd4233141016304e210c9;p=jabaws.git diff --git a/website/archive/binaries/mac/src/disembl/Tisean_3.0.1/source_c/boxcount.c b/website/archive/binaries/mac/src/disembl/Tisean_3.0.1/source_c/boxcount.c new file mode 100644 index 0000000..4ed1c94 --- /dev/null +++ b/website/archive/binaries/mac/src/disembl/Tisean_3.0.1/source_c/boxcount.c @@ -0,0 +1,369 @@ +/* + * This file is part of TISEAN + * + * Copyright (c) 1998-2007 Rainer Hegger, Holger Kantz, Thomas Schreiber + * + * TISEAN is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * TISEAN is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TISEAN; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +/* Author: Rainer Hegger Last modified: Feb 22, 2006 */ +/* Changes: + 02/22/06: Remove this strange else in start_box that + did not compile anyways +*/ + +#include +#include +#include +#include +#include +#include "routines/tsa.h" + +#define WID_STR "Estimates the Renyi entropy of Qth order\n\t\ +using a partition instead of a covering." + +typedef struct { + double *hist; + void *ptr; +} hliste; + +unsigned long LENGTH=ULONG_MAX,exclude=0; +unsigned int maxembed=10,dimension=1,DELAY=1,EPSCOUNT=20; +unsigned int verbosity=0xff; +double Q=2.0,EPSMIN=1.e-3,EPSMAX=1.0; +char dimset=0,epsminset=0,epsmaxset=0; +char *outfile=NULL; +char *column=NULL; + +int epsi; +unsigned long length; +double EPSFAKTOR; +unsigned int **which_dims; +double *histo; +double **series; + +void show_options(char *progname) +{ + what_i_do(progname,WID_STR); + fprintf(stderr,"Usage: %s [Options]\n",progname); + fprintf(stderr,"Options:\n"); + fprintf(stderr,"\t-l # of datapoints [Default: whole file]\n"); + fprintf(stderr,"\t-x # of lines to ignore [Default: %lu]\n",exclude); + fprintf(stderr,"\t-M # of columns,maximal embedding dimension " + "[Default: %u,%u]\n",dimension,maxembed); + fprintf(stderr,"\t-c columns to read [Default: 1,...,#of compon.]\n"); + fprintf(stderr,"\t-d delay [Default: %u]\n",DELAY); + fprintf(stderr,"\t-Q order of the Renyi entropy [Default: %.1f]\n",Q); + fprintf(stderr,"\t-r minimal epsilon [Default: (data interval)/1000]\n"); + fprintf(stderr,"\t-R maximal epsilon [Default: data interval]\n"); + fprintf(stderr,"\t-# # of epsilons to use [Default: %u]\n",EPSCOUNT); + fprintf(stderr,"\t-o output file name [Default: 'datafile'.box]\n"); + fprintf(stderr,"\t-V verbosity level [Default: 1]\n\t\t" + "0='only panic messages'\n\t\t" + "1='+ input/output messages'\n"); + fprintf(stderr,"\t-h show these options\n\n"); + exit(0); +} + +void scan_options(int n,char **in) +{ + char *out; + + if ((out=check_option(in,n,'l','u')) != NULL) + sscanf(out,"%lu",&LENGTH); + if ((out=check_option(in,n,'c','s')) != NULL) + column=out; + if ((out=check_option(in,n,'x','u')) != NULL) + sscanf(out,"%lu",&exclude); + if ((out=check_option(in,n,'M','2')) != NULL) { + sscanf(out,"%u,%u",&dimension,&maxembed); + dimset=1; + } + if ((out=check_option(in,n,'d','u')) != NULL) + sscanf(out,"%u",&DELAY); + if ((out=check_option(in,n,'Q','f')) != NULL) + sscanf(out,"%lf",&Q); + if ((out=check_option(in,n,'r','f')) != NULL) { + sscanf(out,"%lf",&EPSMIN); + epsminset=1; + } + if ((out=check_option(in,n,'R','f')) != NULL) { + sscanf(out,"%lf",&EPSMAX); + epsmaxset=1; + } + if ((out=check_option(in,n,'#','u')) != NULL) + sscanf(out,"%u",&EPSCOUNT); + if ((out=check_option(in,n,'V','u')) != NULL) + sscanf(out,"%u",&verbosity); + if ((out=check_option(in,n,'o','s')) != NULL) + outfile=out; +} + +hliste *make_histo(void) +{ + int i; + hliste *element; + + check_alloc(element=(hliste*)malloc(sizeof(hliste))); + element->ptr=NULL; + check_alloc(element->hist=(double*)malloc(sizeof(double)*maxembed*dimension)); + for (i=0;ihist[i]=0.0; + + return element; +} + +void next_dim(int wd,int n,unsigned int *first) +{ + int i,which,d1,comp; + double epsinv,norm,p; + unsigned int **act; + int *found,hf; + + comp=which_dims[wd][0]; + d1=which_dims[wd][1]*DELAY; + + epsinv=(double)epsi; + norm=(double)length; + + check_alloc(act=(unsigned int**)malloc(epsi*sizeof(int*))); + check_alloc(found=(int*)malloc(epsi*sizeof(int))); + + for (i=0;i maxinterval) + maxinterval=interval; + } + if (epsminset) + EPSMIN /= maxinterval; + if (epsmaxset) + EPSMAX /= maxinterval; + for (i=0;i= 1.0) + series[i][j] -= EPSMIN/2.0; + } + + check_alloc(histo=(double*)malloc(sizeof(double)*maxembed*dimension)); + check_alloc(deps=(double*)malloc(sizeof(double)*EPSCOUNT)); + check_alloc(which_dims=(unsigned int**)malloc(sizeof(int*)* + maxembed*dimension)); + for (i=0;i1) + EPSFAKTOR=pow(EPSMAX/EPSMIN,1.0/(double)(EPSCOUNT-1)); + else + EPSFAKTOR=1.0; + + length=LENGTH-(maxembed-1)*DELAY; + + heps=EPSMAX*EPSFAKTOR; + + for (k=0;kptr != NULL) + histo_el=histo_el->ptr; + + for (i=0;ihist[i]=histo[i]; + else + histo_el->hist[i]=log(histo[i])/(1.0-Q); + + histo_el->ptr=make_histo(); + histo_el=histo_el->ptr; + fHq=fopen(outfile,"w"); + if (verbosity&VER_INPUT) + fprintf(stderr,"Opened %s for writing\n",outfile); + + for (i=0;ihist[i],histo_el->hist[i]); + else + fprintf(fHq,"%e %e %e\n",deps[j]*maxinterval, + histo_el->hist[i],histo_el->hist[i]-histo_el->hist[i-1]); + histo_el=histo_el->ptr; + } + fprintf(fHq,"\n"); + } + fclose(fHq); + } + + return 0; +}