| [a0bcf1] | 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 | 
|---|
|  | 20 | enum 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() | 
|---|
|  | 25 | enum 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 */ | 
|---|
|  | 28 | void CreateMainname(struct Problem *const P, const char* const filename); | 
|---|
|  | 29 |  | 
|---|
|  | 30 | /* Einlesen der Parameterdatei */ | 
|---|
| [961b75] | 31 | int 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); | 
|---|
| [a0bcf1] | 32 | void ReadParameters(struct Problem *const  P, const char *const filename); | 
|---|
| [774ae8] | 33 | void WriteParameters(struct Problem *const  P, const char *const filename); | 
|---|
| [a0bcf1] | 34 |  | 
|---|
|  | 35 | void Init(struct Problem *const P); | 
|---|
|  | 36 | void InitPerturbation(struct Problem *P); | 
|---|
|  | 37 | void 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 | */ | 
|---|
|  | 44 | static 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 |  | 
|---|