source: pcp/src/init.h@ 1d77026

Last change on this file since 1d77026 was 774ae8, checked in by Frederik Heber <heber@…>, 17 years ago

WriteParameters() added
OutputIonCoordinates() uses WriteParameters() and additional parameter whether its MD or StructOpt

  • Property mode set to 100644
File size: 2.1 KB
Line 
1#ifndef init_h
2#define init_h
3/** \file init.h
4 * Header file for \ref init.c
5 *
6 * Contains declarations of the functions implemented in \ref init.c,
7 * enumeration value_type which is needed for ParseForParameters() and
8 * one inline function tpow() realising a "x to the power of n" where n
9 * may be also arbitrary (also negative) integer.
10 *
11 Project: ParallelCarParrinello
12 \authors Jan Hamaekers, Frederik Heber
13 \date 2000, 2006
14
15 File: init.h
16 $Id: init.h,v 1.17 2007/02/09 09:13:48 foo Exp $
17*/
18
19// Specifting whether a value in the parameter file must be specified or is optional
20enum necessity { optional, //!< parameter is optional, if not given sensible value is chosen
21 critical //!< parameter must be given or programme won't initiate
22 };
23
24// Specifying the cast type to be read of a parameter, see ParseForParameter()
25enum value_type { string_type, double_type, int_type, row_int, row_double, grid, lower_trigrid, upper_trigrid};
26
27/* Bereite mainname vor: loescht von filename von rechts nach links bis zu erstem "/" oder ganz */
28void CreateMainname(struct Problem *const P, const char* const filename);
29
30/* Einlesen der Parameterdatei */
31int ParseForParameter(int verbose, FILE *file, const char *const name, int sequential, int const xth, int const yth, enum value_type type, void *value, int repetition, enum necessity critical);
32void ReadParameters(struct Problem *const P, const char *const filename);
33void WriteParameters(struct Problem *const P, const char *const filename);
34
35void Init(struct Problem *const P);
36void InitPerturbation(struct Problem *P);
37void InitPsisValue(struct Problem *const P, int start, int end);
38
39/** Calculate the value \a x to the power of \a n.
40 * \param x value
41 * \param n power
42 * \return \f$x^n\f$
43 */
44static inline double tpow(double x, int n)
45{
46 double y = 1;
47 int neg = (n < 0);
48
49 if (neg) n = -n;
50
51 while (n) { // go through every bit of the integer number n
52 if (n & 1) y *= x; // if bit set, multiply
53 x *= x; // go to next power of 2
54 n >>= 1; // and to the next bit
55 }
56 return neg ? 1.0/y : y; // if n was negative, return reciprocal value
57}
58#endif
59
Note: See TracBrowser for help on using the repository browser.