00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _MISC_H_
00024 #define _MISC_H_
00025
00026 #include <stdio.h>
00027 #include <stdlib.h>
00028
00035
00036 extern const void * aspi_null;
00037
00038
00039 void aspi_init_rand (int seed);
00040
00041 double aspi_misc_random_number (void);
00042
00043 double aspi_misc_random_gaussian (double mean, double sigma);
00044
00045 double aspi_misc_gaussian (double mu, double sigma, double x);
00046
00047 int aspi_misc_random_binomial (int runs, double proba);
00048
00049 int aspi_misc_random_poisson (double lambda);
00050
00051
00052 void aspi_misc_poisson_set_runs (int runs);
00053
00054 #define ASPI_PI 3.14159265358979323846
00055
00056
00057
00058
00063 #ifndef DEBUG
00064 #ifdef NDEBUG
00065 #define DEBUG 0
00066 #else
00067 #define DEBUG 1
00068 #endif
00069 #endif
00070
00071 #ifndef aspi_return_if_fail
00072 #define aspi_return_if_fail(expr) \
00073 if (!(expr)) \
00074 { \
00075 fprintf(stderr, \
00076 "** CRITICAL ** file %s: line %d (%s): assertion `%s' failed.\n", \
00077 __FILE__, \
00078 __LINE__, \
00079 __PRETTY_FUNCTION__, \
00080 #expr); \
00081 if (DEBUG) \
00082 abort (); \
00083 return; \
00084 };
00085 #endif
00086
00087 #ifndef aspi_return_value_if_fail
00088 #define aspi_return_value_if_fail(expr, value) \
00089 if (!(expr)) \
00090 { \
00091 fprintf(stderr, \
00092 "** CRITICAL ** file %s: line %d (%s): assertion `%s' failed.\n", \
00093 __FILE__, \
00094 __LINE__, \
00095 __PRETTY_FUNCTION__, \
00096 #expr); \
00097 if (DEBUG) \
00098 abort (); \
00099 return (value); \
00100 };
00101 #endif
00102
00103
00104 #endif