10 #include "nf_utilities.h"
14 #define is_nan(a) _isnan(a)
18 #define is_nan(a) std::isnan(a)
21 #if defined __cplusplus
70 if( sign < 0 )
return( -INFINITY );
79 case nfu_Okay :
return( Okay_message );
80 case nfu_mallocError :
return( mallocError_message );
81 case nfu_insufficientMemory :
return( insufficientMemory_message );
82 case nfu_badIndex :
return( badIndex_message );
83 case nfu_XNotAscending :
return( XNotAscending_message );
84 case nfu_badIndexForX :
return( badIndexForX_message );
85 case nfu_XOutsideDomain :
return( XOutsideDomain_message );
86 case nfu_invalidInterpolation :
return( invalidInterpolation_message );
87 case nfu_badSelf :
return( badSelf_message );
88 case nfu_divByZero :
return( divByZero_message );
89 case nfu_unsupportedInterpolation :
return( unsupportedInterpolation_message );
90 case nfu_unsupportedInterpolationConversion :
return( unsupportedInterpolationConversion_message );
91 case nfu_empty :
return( empty_message );
92 case nfu_tooFewPoints :
return( tooFewPoints_message );
93 case nfu_domainsNotMutual :
return( notMutualDomian_message );
94 case nfu_badInput :
return( badInput_message );
95 case nfu_badNorm :
return( badNorm_message );
96 case nfu_badIntegrationInput :
return( badIntegrationInput_message );
97 case nfu_otherInterpolation :
return( otherInterpolation_message );
98 case nfu_failedToConverge :
return( failedToConverge_message );
99 case nfu_oddNumberOfValues :
return( oddNumberOfValues_message );
101 return( unknownStatus_message );
108 nfu_debugging = mode;
115 void *p = malloc( size );
117 if( nfu_debugging ) printf(
"nfu_malloc %12p size = %8llu\n", p, (
long long unsigned) size );
125 void *p = calloc( size, n );
127 if( nfu_debugging ) printf(
"nfu_calloc %12p size = %8llu, n = %8llu\n", p, (
long long unsigned) size, (
long long unsigned) n );
135 void *p = realloc( old, size );
137 if( nfu_debugging ) printf(
"nfu_realloc %12p size = %8llu, old = %12p\n", p, (
long long unsigned) size, old );
146 if( nfu_debugging ) printf(
"nfu_free %12p\n", p );
158 va_start( args, fmt );
159 vfprintf( stderr, fmt, args );
160 fprintf( stderr,
"\n" );
170 va_start( args, fmt );
171 vfprintf( stderr, fmt, args );
172 fprintf( stderr,
"\n" );
175 exit( EXIT_FAILURE );
178 #if defined __cplusplus
static const char empty_message[]
void * nfu_realloc(size_t size, void *old)
static const char mallocError_message[]
static const char unsupportedInterpolation_message[]
static const char XNotAscending_message[]
static const char insufficientMemory_message[]
static const char badIndex_message[]
static const char unsupportedInterpolationConversion_message[]
void nfu_setMemoryDebugMode(int mode)
static const char tooFewPoints_message[]
static const char badSelf_message[]
static const char unknownStatus_message[]
static const char otherInterpolation_message[]
static const char XOutsideDomain_message[]
static const char Okay_message[]
static const char notMutualDomian_message[]
static const char divByZero_message[]
static const char badIntegrationInput_message[]
static const char failedToConverge_message[]
double nfu_getInfinity(double sign)
const char * nfu_statusMessage(nfu_status status)
static const char invalidInterpolation_message[]
static const char badIndexForX_message[]
static const char badInput_message[]
static const char badNorm_message[]
void nfu_printMsg(char *fmt,...)
void nfu_printErrorMsg(char *fmt,...)
G4int sign(const T t)
A simple sign function that allows us to port fortran code to c++ more easily.
void * nfu_calloc(size_t size, size_t n)
static const char oddNumberOfValues_message[]
void * nfu_malloc(size_t size)