Patterns in static

Apophenia

internal.h

00001 /* These are functions used here and there to write Apophenia. They're
00002  not incredibly useful, or even very good form, so they're not public. Cut
00003  & paste `em into your own code if you'd like.
00004  */
00005 
00006 
00007 /* Many Apop functions try to treat the vector and matrix equally, which
00008  requires knowing which exists and what the sizes are. */
00009 #define Get_vmsizes(d) \
00010     size_t vsize = (d)->vector ? (d)->vector->size : 0; \
00011     size_t wsize = (d)->weights ? (d)->weights->size : 0; \
00012     size_t msize1 = (d)->matrix ? (d)->matrix->size1 : 0; \
00013     size_t msize2 = (d)->matrix ? (d)->matrix->size2 : 0; \
00014     double tsize = vsize + msize1*msize2; \
00015     if (tsize||wsize) /*prevent unused variable complaints */;
00016 
00017 // Define a static varaible, and initialize on first use.
00018 #define Staticdef(type, name, def) static type (name) = NULL; if (!(name)) (name) = (def);
00019 
00020 // Check for NULL and complain if so.
00021 #define Nullcheck(in) Apop_assert(in, 0, 0, 's', "%s is NULL.", #in)
00022 #define Nullcheck_m(in) Apop_assert(in, 0, 0, 's', "%s is a NULL model.", #in)
00023 #define Nullcheck_p(in) Apop_assert((in)->parameters, 0, 0, 's', "%s is a model with NULL parameters. Please set the parameters and try again.", #in)
00024 #define Nullcheck_d(in) Apop_assert(in, 0, 0, 's', "%s is a NULL data set.", #in)
00025 
00026 #define Nullcheck_v(in) Apop_assert_void(in, 0, 's', "%s is NULL.", #in)
00027 #define Nullcheck_mv(in) Apop_assert_void(in, 0, 's', "%s is a NULL model.", #in)
00028 #define Nullcheck_pv(in) Apop_assert_void((in)->parameters, 0, 's', "%s is a model with NULL parameters. Please set the parameters and try again.", #in)
00029 #define Nullcheck_dv(in) Apop_assert_void(in, 0, 's', "%s is a NULL data set.", #in)

SourceForge.net Logo

Autogenerated by doxygen on 28 Sep 2009.