Miscellaneous
[Utilities.]

() More...

Functions

void Lorene::arrete (int a=0)
 Setting a stop point in a code.
bool Lorene::zero_premier (double(*f)(double, const Param &), const Param &par, double a, double b, int n, double &a0, double &b0)
 Locates the sub-interval containing the first zero of a function in a given interval.
double Lorene::zerosec (double(*f)(double, const Param &), const Param &par, double a, double b, double precis, int nitermax, int &niter, bool abort=true)
 Finding the zero a function.
double Lorene::zerosec_b (double(*f)(double, const Param &), const Param &par, double a, double b, double precis, int nitermax, int &niter)
 Finding the zero a function on a bounded domain.
void Lorene::zero_list (double(*f)(double, const Param &), const Param &par, double xmin, double xmax, int nsub, Tbl *&az, Tbl *&bz)
 Locates approximatively all the zeros of a function in a given interval.
Tbl Lorene::integ1D (const Tbl &xx, const Tbl &ff)
 Integrates a function defined on an unequally-spaced grid, approximating it by piece parabolae.
int Lorene::fwrite_be (const int *aa, int size, int nb, FILE *fich)
 Writes integer(s) into a binary file according to the big endian convention.
int Lorene::fwrite_be (const double *aa, int size, int nb, FILE *fich)
 Writes double precision number(s) into a binary file according to the big endian convention.
int Lorene::fread_be (int *aa, int size, int nb, FILE *fich)
 Reads integer(s) from a binary file according to the big endian convention.
int Lorene::fread_be (double *aa, int size, int nb, FILE *fich)
 Reads double precision number(s) from a binary file according to the big endian convention.
char * Lorene::load_file (char *fname)
 Read file into memory and returns pointer to data.
char * Lorene::load_file_buffered (char *fname)
 Returns pointer to data from a file using a buffer.
int Lorene::read_variable (const char *fname, const char *var_name, char *fmt, void *varp)
 Reads a variable from file.
int Lorene::read_variable (const char *fname, const char *var_name, int &var)
 Read an integer-variable from file (cf read_variable(char *, char *, char *, void *) ).
int Lorene::read_variable (const char *fname, const char *var_name, bool &var)
 Read a bool variable from file (cf read_variable(char *, char *, char *, void *) ).
int Lorene::read_variable (const char *fname, const char *var_name, double &var)
 Read a double variable from file (cf read_variable(char *, char *, char *, void *) ).
int Lorene::read_variable (const char *fname, const char *var_name, char **str)
 Read a (ANSI C) string variable from file.
void * Lorene::MyMalloc (long bytes)
 'Improved' malloc that sets memory to 0 and also auto-terminates on error.
int Lorene::FS_filelength (FILE *f)
 A portable routine to determine the length of a file.
void Lorene::c_est_pas_fait (const char *)
 Helpful function to say something is not implemented yet.
bool Lorene::search_file (ifstream &infile, const string &pattern)
 A function that searches for a pattern in a file and places the file stream after the found pattern.

Detailed Description

()


Function Documentation

void Lorene::arrete ( int  a = 0  ) 

Setting a stop point in a code.

Stops the execution of a code, until the 'Enter' case is hit.

Parameters:
a [input] stops the run if, and only if, a=0. Default value : 0.

Definition at line 64 of file arrete.C.

void Lorene::c_est_pas_fait ( const char *  fichier  ) 

Helpful function to say something is not implemented yet.

Definition at line 76 of file c_est_pas_fait.C.

int Lorene::fread_be ( double *  aa,
int  size,
int  nb,
FILE *  fich 
)

Reads double precision number(s) from a binary file according to the big endian convention.

This function has the same prototype and return value than the fread function of the stdio C library. The difference is that it assumes that the binary file is written in the big endian format, whatever the system is using little endian or big endian.

Parameters:
aa [output] array of double to be read (in case of one element, address of this double )
size [input] number of bytes of one double (must be 8)
nb [input] number of elements in the array aa
fich [input] binary file (must have been open by fopen )
Returns:
number of double effectively read in the file

Definition at line 120 of file fread_be.C.

int Lorene::fread_be ( int *  aa,
int  size,
int  nb,
FILE *  fich 
)

Reads integer(s) from a binary file according to the big endian convention.

This function has the same prototype and return value than the fread function of the stdio C library. The difference is that it assumes that the binary file is written in the big endian format, whatever the system is using little endian or big endian.

Parameters:
aa [output] integer array to be read (in case of one element, address of this integer)
size [input] number of bytes of one int (must be 4)
nb [input] number of elements in the array aa
fich [input] binary file (must have been open by fopen )
Returns:
number of integers effectively read in the file

Definition at line 72 of file fread_be.C.

int Lorene::FS_filelength ( FILE *  f  ) 

A portable routine to determine the length of a file.

Definition at line 272 of file read_variable.C.

int Lorene::fwrite_be ( const double *  aa,
int  size,
int  nb,
FILE *  fich 
)

Writes double precision number(s) into a binary file according to the big endian convention.

This function has the same prototype and return value than the fwrite function of the stdio C library. The difference is that it ensures that the binary file is written in the big endian format, whatever the system is using little endian or big endian.

Parameters:
aa [input] array of double to be written (in case of one element, address of this double )
size [input] number of bytes of one double (must be 8)
nb [input] number of elements in the array aa
fich [input] binary file (must have been open by fopen )
Returns:
number of double effectively written in the file

Definition at line 123 of file fwrite_be.C.

int Lorene::fwrite_be ( const int *  aa,
int  size,
int  nb,
FILE *  fich 
)

Writes integer(s) into a binary file according to the big endian convention.

This function has the same prototype and return value than the fwrite function of the stdio C library. The difference is that it ensures that the binary file is written in the big endian format, whatever the system is using little endian or big endian.

Parameters:
aa [input] integer array to be written (in case of one element, address of this integer)
size [input] number of bytes of one int (must be 4)
nb [input] number of elements in the array aa
fich [input] binary file (must have been open by fopen )
Returns:
number of integers effectively written in the file

Definition at line 73 of file fwrite_be.C.

Tbl Lorene::integ1D ( const Tbl &  xx,
const Tbl &  ff 
)

Integrates a function defined on an unequally-spaced grid, approximating it by piece parabolae.

This function performs the numerical integration of a function given by its values on a unequally-spaced grid, by means of local parabolic approximation. The resulting primitive is set to 0 on the lower end of the integration interval.

Parameters:
xx [input] Tbl containing the grid abscissas
ff [input] Tbl containing the values of the function to be integrated, on the grid points
Returns:
a Tbl with the values of the primitive of ff at the grid points, such that it is zero at the first grid point.

Definition at line 50 of file integrate_1D.C.

References Lorene::Tbl::get_etat(), Lorene::Tbl::get_taille(), and Lorene::Tbl::set().

char* Lorene::load_file ( char *  fname  ) 

Read file into memory and returns pointer to data.

Returns:
: pointer to allocated memory or NULL on error.\

NOTE: don't forget to free the memory after use !

char* Lorene::load_file_buffered ( char *  fname  ) 

Returns pointer to data from a file using a buffer.

This function only reads from disk if the file has not been buffered yet. If a new file is read, the buffer is free'ed and the new data allocated.

Parameters:
fname [input] name of file to read in. You can use NULL for previous file.
Returns:
: pointer to buffered data or NULL on error.\

NOTE: do _NEVER_ free the (buffer-)data pointer, or the next call will crash!!

void * Lorene::MyMalloc ( long  bytes  ) 

'Improved' malloc that sets memory to 0 and also auto-terminates on error.

Definition at line 293 of file read_variable.C.

int Lorene::read_variable ( const char *  fname,
const char *  var_name,
char **  str 
)

Read a (ANSI C) string variable from file.

Definition at line 244 of file read_variable.C.

References Lorene::read_variable().

int Lorene::read_variable ( const char *  fname,
const char *  var_name,
double &  var 
)

Read a double variable from file (cf read_variable(char *, char *, char *, void *) ).

Definition at line 234 of file read_variable.C.

References Lorene::read_variable().

int Lorene::read_variable ( const char *  fname,
const char *  var_name,
bool &  var 
)

Read a bool variable from file (cf read_variable(char *, char *, char *, void *) ).

Definition at line 221 of file read_variable.C.

References Lorene::read_variable().

int Lorene::read_variable ( const char *  fname,
const char *  var_name,
int &  var 
)

Read an integer-variable from file (cf read_variable(char *, char *, char *, void *) ).

Definition at line 211 of file read_variable.C.

References Lorene::read_variable().

int Lorene::read_variable ( const char *  fname,
const char *  var_name,
char *  fmt,
void *  varp 
)

Reads a variable from file.

Variable definitions can be of the type "variable = value", all other lines are ignored as comments. (alternatively, you can use ":" or whitespace instead of "=")

NOTE: the variable-definition has to be at the beginning of a line (modulo whitespace), or it will be considered a comment!

Parameters:
fname [input] Name of config-file to read from. Use NULL to use buffered file.
var_name [input] Variable-name to read from config-file
fmt [input] C-style format string for reading (see sscanf ).
varp [output] Pointer to C-variable to read value into (has to be big enough!!)
Returns:
0 on success, -1 on error. \

NOTE: rather use one of the type-specific overloaded functions below whenever possible (safer due to type-checking)

Definition at line 110 of file read_variable.C.

References Lorene::load_file_buffered(), and Lorene::MyMalloc().

bool Lorene::search_file ( ifstream &  infile,
const string &  pattern 
)

A function that searches for a pattern in a file and places the file stream after the found pattern.

It returns 'false' if the pattern is not found.

Definition at line 53 of file misc.C.

void Lorene::zero_list ( double(*)(double, const Param &)  f,
const Param &  par,
double  xmin,
double  xmax,
int  nsub,
Tbl *&  az,
Tbl *&  bz 
)

Locates approximatively all the zeros of a function in a given interval.

The N zeros are located in N intervals [az(i), bz(i)] with $0\leq i \leq N-1$.

Parameters:
(*f)(double,const Param&) [input] Function the zeros of which are to be located: a zero x0 is defined by f(x0, par) = 0 , where par are the parameters of the function f, stored in an object of the Lorene class Param .
par [input] Parameters of the function f.
xmin [input] Lower bound of the search interval
xmax [input] Higher bound of the search interval
nsub [input] Number of subdivision of the interval [xmin, xmax] to locate the zeros
az [output] 1-D array (Lorene Tbl ) contain the lower bounds of the intervals containing a zero. This Tbl \ is allocated by the routine via a new Tbl \ command (hence the pointer type).
bz [output] 1-D array (Lorene Tbl ) contain the higher bounds of the intervals containing a zero. This Tbl \ is allocated by the routine via a new Tbl \ command (hence the pointer type).

Definition at line 60 of file zero_list.C.

References Lorene::Tbl::set(), and Lorene::Tbl::set_etat_qcq().

bool Lorene::zero_premier ( double(*)(double, const Param &)  f,
const Param &  par,
double  a,
double  b,
int  n,
double &  a0,
double &  b0 
)

Locates the sub-interval containing the first zero of a function in a given interval.

Parameters:
(*f)(double,const Param&) [input] Function the zero of which is to be searched: f(x0, par) = 0 , where par are the parameters of the function f, stored in an object of the Lorene class Param .
a [input] Lower bound of the search interval [a, b]
b [input] Higher bound of the search interval [a, b]
n [input] Number of subdivisions of the interval [a, b]
a0 [output] Lower bound of the first (i.e. closest to a) interval [a0, b0] which contains a zero of f
b0 [output] Higher bound of the first (i.e. closest to a) interval [a0, b0] which contains a zero of f
Returns:
true if the interval [a0, b0] containing a zero of f has been found, false otherwise

Definition at line 64 of file zero_premier.C.

double Lorene::zerosec ( double(*)(double, const Param &)  f,
const Param &  par,
double  a,
double  b,
double  precis,
int  nitermax,
int &  niter,
bool  abort = true 
)

Finding the zero a function.

This routine locates a zero by means of the secant method.

Parameters:
(*f)(double,const Param&) [input] Function the zero of which is to be searched: the routine computes x0 in a given interval [a, b] such that f(x0, par) = 0 , where par are the parameters of the function f, stored in an object of the Lorene class Param .
par [input] Parameters of the function f.
a [input] Lower bound of the search interval [a, b]
b [input] Higher bound of the search interval [a, b]
precis [input] Required precision in the determination of x0 : the returned solution will be x0 +/- precis
nitermax [input] Maximum number of iterations in the secant method to compute x0.
niter [output] Number of iterations effectively used in computing x0
abort [input] Should the function abort if the maximal number of iterations has been reached?
Returns:
x0 (zero of function f)

Definition at line 92 of file zerosec.C.

double Lorene::zerosec_b ( double(*)(double, const Param &)  f,
const Param &  par,
double  a,
double  b,
double  precis,
int  nitermax,
int &  niter 
)

Finding the zero a function on a bounded domain.

Same as zerosec but insures that all calls to the function f are within [x1,x2]. Namely, it requires that f(x1)*f(x2)<0.

Parameters:
(*f)(double,const Param&) [input] Function the zero of which is to be searched: the routine computes x0 in a given interval [a, b] such that f(x0, par) = 0 , where par are the parameters of the function f, stored in an object of the Lorene class Param .
par [input] Parameters of the function f.
a [input] Lower bound of the search interval [a, b]
b [input] Higher bound of the search interval [a, b]
precis [input] Required precision in the determination of x0 : the returned solution will be x0 +/- precis
nitermax [input] Maximum number of iterations in the secant method to compute x0.
niter [output] Number of iterations effectively used in computing x0
Returns:
x0 (zero of function f)

Definition at line 71 of file zerosec_borne.C.


Generated on 7 Dec 2019 for LORENE by  doxygen 1.6.1