libtpccurveio
 All Data Structures Files Functions Variables Enumerations Enumerator Defines
Functions
mathfunc.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <ctype.h>
#include "decpoint.h"
#include "petunits.h"
#include "datetime.h"
#include "backup.h"
#include "include/mathfunc.h"
Include dependency graph for mathfunc.c:

Go to the source code of this file.

Functions

void fitEmpty (FIT *fit)
void fitInit (FIT *fit)
int fitWrite (FIT *fit, char *filename)
int fitSetmem (FIT *fit, int voiNr)
void fitPrint (FIT *fit)
int fitRead (char *filename, FIT *fit)
int fitFunctionformat (int type, char *str)
int fitFunctionname (int type, char *str)
int fitEval (FitVOI *r, double x, double *y)
int fitEvaltac (FitVOI *r, double *x, double *y, int dataNr)
int fitIntegralEval (FitVOI *r, double x, double *yi)
int fitIntegralEvaltac (FitVOI *r, double *x, double *yi, int dataNr)
int fitDerivEval (FitVOI *r, double x, double *yd)
int fitDerivEvaltac (FitVOI *r, double *x, double *yd, int dataNr)

Function Documentation

int fitDerivEval ( FitVOI r,
double  x,
double *  yd 
)

Evaluates yd=Df(x).

Returns:
Returns 0, if ok.
Parameters:
rFit parameters of a single region
xTime where to evaluate the derivative of the function
ydThe derivative of the function is returned here

Definition at line 1319 of file mathfunc.c.

References FitVOI::p, and FitVOI::type.

Referenced by fitDerivEvaltac().

int fitDerivEvaltac ( FitVOI r,
double *  x,
double *  yd,
int  dataNr 
)

Evaluates an array yd[i]=Df(x[i]).

Returns:
Returns 0, if ok.
Parameters:
rFit parameters of a single region
xTimes where to evaluate the function derivatives
ydArray for the function derivatives
dataNrNr of (x,yd) data

Definition at line 1425 of file mathfunc.c.

References fitDerivEval().

Here is the call graph for this function:

void fitEmpty ( FIT fit)

Free memory allocated for FIT. All contents are cleared.

Definition at line 194 of file mathfunc.c.

References FIT::_voidataNr, FIT::datafile, FIT::program, FIT::time, FIT::timeunit, FIT::unit, FIT::voi, and FIT::voiNr.

Referenced by fitRead(), and fitSetmem().

int fitEval ( FitVOI r,
double  x,
double *  y 
)

Evaluate y=f(x).

Returns:
Returns 0, if ok.
Parameters:
rFit parameters of a single region
xTime where to evaluate the function
yThe value of the function is returned here

Definition at line 675 of file mathfunc.c.

References MATHFUNC_TEST, FitVOI::p, FitVOI::parNr, and FitVOI::type.

Referenced by fitEvaltac().

int fitEvaltac ( FitVOI r,
double *  x,
double *  y,
int  dataNr 
)

Evaluates an array y[i]=f(x[i]).

Returns:
Returns 0, if ok.
Parameters:
rFit parameters of a single region
xTimes where to evaluate the function
yArray for the function values
dataNrNr of (x,y) data

Definition at line 1116 of file mathfunc.c.

References fitEval().

Here is the call graph for this function:

int fitFunctionformat ( int  type,
char *  str 
)

Copies the description of a function type to the specified string which must have space for >=128 characters.

Parameters:
typeThe number of function
strRepresentation of the format of the function

Definition at line 464 of file mathfunc.c.

int fitFunctionname ( int  type,
char *  str 
)

Copies the name of the function to the specified string which must have space for >=128 characters.

Parameters:
typeThe number of function
strName of the function

Definition at line 588 of file mathfunc.c.

void fitInit ( FIT fit)

Initiate FIT structure. Call this once before first use.

Definition at line 209 of file mathfunc.c.

References FIT::_voidataNr, and FIT::voiNr.

int fitIntegralEval ( FitVOI r,
double  x,
double *  yi 
)

Evaluates yi=Integral of f(x) between 0 and x.

Returns:
Returns 0, if ok.
Parameters:
rFit parameters of a single region
xTime where to evaluate integral of the function
yiThe integral value of the function is returned here

Definition at line 1138 of file mathfunc.c.

References FitVOI::p, and FitVOI::type.

Referenced by fitIntegralEvaltac().

int fitIntegralEvaltac ( FitVOI r,
double *  x,
double *  yi,
int  dataNr 
)

Evaluate an array yi[i]=Integral of f(x[i]) between 0 and x.

Returns:
Returns 0, if ok.
Parameters:
rFit parameters of a single region
xTimes where to evaluate the function integrals
yiArray for the function integral values
dataNrNr of (x,yi) data

Definition at line 1297 of file mathfunc.c.

References fitIntegralEval().

Here is the call graph for this function:

void fitPrint ( FIT fit)

Print to stdout the contents of FIT data structure. Mainly for testing purposes.

Definition at line 332 of file mathfunc.c.

References FIT::_voidataNr, fitWrite(), MATHFUNC_TEST, and FIT::voiNr.

Here is the call graph for this function:

int fitRead ( char *  filename,
FIT fit 
)

Read FIT file contents to the specified data structure, emptying its old contents.

Returns:
In case of an error, >0 is returned, and a description is written in fiterrmsg.
Parameters:
filenamePointer to filename
fitPointer to initiated FIT struct

Definition at line 346 of file mathfunc.c.

References FIT::datafile, FitVOI::dataNr, FitVOI::end, FIT_VER, fitEmpty(), fiterrmsg, fitSetmem(), FitVOI::hemisphere, MATHFUNC_TEST, FitVOI::name, FitVOI::p, FitVOI::parNr, FitVOI::place, FIT::program, FitVOI::start, FIT::time, FIT::timeunit, FitVOI::type, FIT::unit, FIT::voi, FitVOI::voiname, FIT::voiNr, and FitVOI::wss.

Here is the call graph for this function:

int fitSetmem ( FIT fit,
int  voiNr 
)

Allocate memory for FIT data. Any previous contents are destroyed.

Definition at line 311 of file mathfunc.c.

References FIT::_voidataNr, fitEmpty(), FIT::voi, and FIT::voiNr.

Referenced by fit_allocate_with_dft(), and fitRead().

Here is the call graph for this function:

int fitWrite ( FIT fit,
char *  filename 
)

Write function parameters in FIT into specified file. If necessary, a backup file (+BACKUP_EXTENSION) is created. In case of an error, >0 is returned, and a description is written in fiterrmsg.

Definition at line 222 of file mathfunc.c.

References FIT::datafile, FitVOI::dataNr, FitVOI::end, FIT_VER, fiterrmsg, FitVOI::hemisphere, MATHFUNC_TEST, FitVOI::p, FitVOI::parNr, FitVOI::place, FIT::program, FitVOI::start, FIT::time, FIT::timeunit, FitVOI::type, FIT::unit, FIT::voi, FitVOI::voiname, FIT::voiNr, and FitVOI::wss.

Referenced by fitPrint().