int scan_help
(int argc,char **argv)
This routine just scans the options for a -h and returns a 1 if found
and a 0 if not.
double *get_series
(char *name,
unsigned long *l,unsigned long ex, unsigned int col,
unsigned int verbosity)
This routine reads
a scalar time series from the file name into
the array which is returned.l is the number of
data read (will on return be the minimum of the file size and the value
given). The first ex lines of the
file are ignored and the time series is supposed to be the cols column. verbosity
specifies the verbosity level of the program.
double **get_multi_series(char *name,
unsigned long *l,unsigned long ex, unsigned int *col,
char *which,char colfix,unsigned int verbosity)
Reads a multivariate time series
and returns a
pointer to it. The first three parameters are the same as in
get_series. *col is the number
of columns to read and which is a string which
contains the columns to be read, separated by commas. colfix determines whether *col can be modified within the routine.
Example: to read the first three columns:
which=1,2,3 or if the columns should be permuted
which=3,2,1 means: x=third column, ...
If which contains less columns than specified in
col it is extended in such a way that columns are
appended that are larger than the largest given in
which.
Example: col=3
which=1,2 -which=1,2,3
or
which=5,1 -which=5,1,6
If which contains more columns than
specified in *col, then which determines the number of columns to read
unless the dimension was specified on the command line, explicitely.
verbosity
specifies the verbosity level of the program.
void rescale_data
(double *s,unsigned long l,double *min,double *interval)
This routine rescales the data
in the array s, which has a length
l, to the interval [0:1]. On return
min is the minimum of the original data set and
interval its original interval.
void variance
(double *s,
unsigned long l,double *av,double *var)
Simply calculates
the average av and the variance
var of a time series s,
which has length l.
void make_box
(double *s,long **box,long *list,
unsigned long l,unsigned int bs,unsigned int dim,unsigned int
del,double eps)
This routine together with the
routine find_neighbors
constitute the
box-assisted search algorithm. The parameters are: The time series
s of length
l, a two dimensional box of dimension bs, where
bs has to be a power of 2, the search list,
also of length l, the dimension dim of the
embedding vectors, which are build with delay del and the size eps of
the boxes.
unsigned long find_neighbors
(double *s,long **box,long *list,double *x,
unsigned long l,unsigned int bs,unsigned int dim,
unsigned int del,double eps,unsigned long *flist)
This routine searches for all neighbors of a vector
x within the time series s. The indexes of the neighbors found are
stored in the array flist, which has length
l and the number of neighbors found is
returned. All other parameters have the same meaning as in the
routine
make_box.
char* search_datafile(int n,char
**names,unsinged int *col,unsigned int verbosity)
This routines gets an array of strings names
of size n and scans it for a name of an existing
file. It returns the filename in case it found one or a NULL pointer if
not. If the filename is given like filename,i the i is
interpreted as the column and is returned in col, if col was not a pointer
to NULL. verbosity specifies the verbosity level of the program.
char* check_option
(char **str,int n,int flag,int type)
This routine looks for the flag flag in the
string array str (typically argv) which has
n (typically argc) entries. The flag is
supposed to be of type type. See the sources
for the valid types. The return string contains the parameter for
the flag or NULL if none was found.
void solvele(double **mat,double *vec,unsigned
int dim)
Solves a dim-dimensional
system of linear equations given by mat*x=vec. It uses a Gaussian elimination
scheme. On return vec contains x.
void test_outfile(char *name)
This routine just checks whether the program can write to the file
named name. If not the program exits.
double
**invert_matrix
(double **mat,unsigned int size)
Inverts the
matrix mat which is sizexsize. It uses the
routine solvele.
The inverse matrix is returned.
unsigned long exclude_interval(unsigned long
found,long ex0,long ex1,long *before,long *newlist)
This
routine is meant to be used in connection with the find_neighbors
routine. After having found found neighbors
which are stored in before, this new routine
allows to exclude an interval of time indexes
limited from ex0 to ex1
from this list. In other words: All neighbors having a time index in
the above range are removed from the list. The modified list is
returned in newlist and the new number of neigbors is the
return value of the routine.
void make_multi_box(double **series,long
**box,long *list,unsigned long length,unsigned int bs,unsigned int
dim, unsigned int emb, unsigned int del,double eps)
This
routine is used to create the mesh for the box assisted search
algorithm in case you have multivariate data. The parameter dim determines the number of components of the
vector. All other parameter have the same meaning as in make_box.
unsigned long find_multi_neighbors
(double *s,long **box,long *list,double **x,
unsigned long l,unsigned int bs,unsigned int dim,
unsigned int emb,unsigned int del,double eps,unsigned long
*flist)
This routine searches for all neighbors of a multicomponent vector
x within the multicomponent time series s. dim is the number of
components. All other parameters have the same meaning as the ones
of
find_neighbors.
unsigned
int **make_multi_index(unsigned int comps, unsigned
int emb, unsigned int del)
This routine is supposed to help with multivariate series. Given a
series with comps components which are
additionally embedded in emb dimensions using
delay del, this routine returns a 2d array
with the following property: Given a number between 0 and
comps*emb-1, the first dimension of the returned array contains the
component of the multivariate series, while the second dimension
contains the time shift due to the embedding.
void
check_alloc(void *array)
Just checks whether the pointer array is
NULL. If so, the routines exits with an error code. The routine is
supposed to be used in combination with malloc from glibc.
void
myfgets(char *str,int *size,FILE *fin, unsigned
int verbosity)
This
routine wraps the fgets routine of C to handle looong input
lines. The parameters have the same meaning as in fgets. The only
differences are: size can be changed inside
and verbosity handles the verbosity level for
the output of warnings.
void what_i_do(char *text,char *name): Just writes a message to stderr saying what the program name does (text).
double
*rand_arb_dist(double *x,unsigned long nx,
unsigned long nc, unsigned int nb, unsigned long iseed)
This routine generates random numbers, which have the same
distribution as the data set x. The length of
x is nx. The number of
random numbers created is nc. nb is the number of boxes with which the
original data is binned to define the histogram to be
reproduced. iseed gives the seed for the
random number generator. The returned array finally contains the
random numbers.
void
eigen(double **mat,unsigned long n, double
*eig)
This routine calculates the eigenvectors and eigenvalues of a
symmetric matrix mat having dimension n. On return mat contains
the eigenvectors of mat as columns and eig its eigenvalues. It uses the routines tred2 and tql2 of the
EISPACK package which were translated to C using the f2c program. The
routine requires mat to be allocated in a
special way.