/* * 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: Jul 26, 2004 */ #include #include #include #include #include #include "routines/tsa.h" #define WID_STR "Performs a global PCA" unsigned long LENGTH=ULONG_MAX,exclude=0; unsigned int DIM=2,EMB=1,dimemb,LDIM=2,DELAY=1; unsigned int verbosity=0xff; char *outfile=NULL,stout=1,dim_set=0; unsigned int what_to_write=0,write_values=1,write_vectors=0; unsigned int write_comp=0,write_proj=0; unsigned int projection_set=0; char *infile=NULL,dimset=0,*column=NULL; 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,"Everything not being a valid option will be interpreted" " as a possible" " datafile.\nIf no datafile is given stdin is read. Just - also" " means stdin\n"); fprintf(stderr,"\t-l # of data to use [Default: whole file]\n"); fprintf(stderr,"\t-x # of lines to be ignore [Default: 0]\n"); fprintf(stderr,"\t-c columns to read [Default: 2]\n"); fprintf(stderr,"\t-m columns,embedding dim. to use [Default: 2,1]\n"); fprintf(stderr,"\t-d delay to use [Default: 1]\n"); fprintf(stderr,"\t-q projection dimension [Default: no projection]\n"); fprintf(stderr,"\t-W # what to write: [Default: 0]\n" "\t\t0 write eigenvalues only\n" "\t\t1 write eigenvectors\n" "\t\t2 write (projected) pca components\n" "\t\t3 write projected data\n"); fprintf(stderr,"\t-o output file name \n\t\t[Default: stdout; -o without " "value means 'datafile'.pca]\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"); 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,'x','u')) != NULL) sscanf(out,"%lu",&exclude); if ((out=check_option(in,n,'c','s')) != NULL) column=out; if ((out=check_option(in,n,'m','2')) != NULL) { sscanf(out,"%u,%u",&DIM,&EMB); dimset=1; } if ((out=check_option(in,n,'d','u')) != NULL) sscanf(out,"%u",&DELAY); if ((out=check_option(in,n,'q','u')) != NULL) { sscanf(out,"%u",&LDIM); projection_set=1; } if ((out=check_option(in,n,'V','u')) != NULL) sscanf(out,"%u",&verbosity); if ((out=check_option(in,n,'W','u')) != NULL) { sscanf(out,"%u",&what_to_write); switch(what_to_write) { case 0: write_values=1;break; case 1: write_values=0;write_vectors=1;break; case 2: write_values=0;write_comp=1;break; case 3: write_values=0;write_proj=1;break; default: { fprintf(stderr,"Wrong value for the -W flag. Exiting!\n"); exit(127); } } } if ((out=check_option(in,n,'o','o')) != NULL) { stout=0; if (strlen(out) > 0) outfile=out; } } void ordne(double *lyap,int *ord) { long i,j,maxi; double max; for (i=0;i dimemb) LDIM=dimemb; } check_alloc(av=(double*)malloc(sizeof(double)*DIM)); for (j=0;j