Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
nf_utilities.cc File Reference
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include "nf_utilities.h"
Include dependency graph for nf_utilities.cc:

Go to the source code of this file.

Macros

#define is_nan(a)   std::isnan(a)
 

Functions

double nfu_getNAN (void)
 
int nfu_isNAN (double d)
 
double nfu_getInfinity (double sign)
 
const char * nfu_statusMessage (nfu_status status)
 
void nfu_setMemoryDebugMode (int mode)
 
voidnfu_malloc (size_t size)
 
voidnfu_calloc (size_t size, size_t n)
 
voidnfu_realloc (size_t size, void *old)
 
voidnfu_free (void *p)
 
void nfu_printMsg (char *fmt,...)
 
void nfu_printErrorMsg (char *fmt,...)
 

Variables

static const char Okay_message [] = "all is okay"
 
static const char mallocError_message [] = "could not allocate memory"
 
static const char insufficientMemory_message [] = "user's memory is too small to hanlde data"
 
static const char badIndex_message [] = "bad index"
 
static const char XNotAscending_message [] = "x values are not ascending"
 
static const char badIndexForX_message [] = "index not correct for x value"
 
static const char XOutsideDomain_message [] = "x value not in domain"
 
static const char invalidInterpolation_message [] = "bad x,y values for interpolation"
 
static const char badSelf_message [] = "source object has bad status value"
 
static const char divByZero_message [] = "division by zero"
 
static const char unsupportedInterpolation_message [] = "unsupported interpolation"
 
static const char unsupportedInterpolationConversion_message [] = "unsupported interpolation conversion"
 
static const char empty_message [] = "empty instance"
 
static const char tooFewPoints_message [] = "too few points in instance"
 
static const char notMutualDomian_message [] = "domains are not mutual"
 
static const char unknownStatus_message [] = "unknown (i.e., invalid) status value"
 
static const char badInput_message [] = "bad input to function"
 
static const char badNorm_message [] = "bad norm"
 
static const char badIntegrationInput_message [] = "bad integration input"
 
static const char otherInterpolation_message [] = "other integration not supported"
 
static const char failedToConverge_message [] = "failed to converge"
 
static const char oddNumberOfValues_message [] = "odd number of inputted values"
 
static int nfu_debugging = 0
 

Macro Definition Documentation

#define is_nan (   a)    std::isnan(a)

Definition at line 18 of file nf_utilities.cc.

Function Documentation

void* nfu_calloc ( size_t  size,
size_t  n 
)

Definition at line 123 of file nf_utilities.cc.

123  {
124 
125  void *p = calloc( size, n );
126 
127  if( nfu_debugging ) printf( "nfu_calloc %12p size = %8llu, n = %8llu\n", p, (long long unsigned) size, (long long unsigned) n );
128  return( p );
129 }
const char * p
Definition: xmltok.h:285
static int nfu_debugging
Definition: nf_utilities.cc:49

Here is the caller graph for this function:

void* nfu_free ( void p)

Definition at line 143 of file nf_utilities.cc.

143  {
144 
145  if( p != NULL ) {
146  if( nfu_debugging ) printf( "nfu_free %12p\n", p );
147  free( p );
148  }
149  return( NULL );
150 }
const char * p
Definition: xmltok.h:285
static int nfu_debugging
Definition: nf_utilities.cc:49

Here is the caller graph for this function:

double nfu_getInfinity ( double  sign)

Definition at line 68 of file nf_utilities.cc.

68  {
69 
70  if( sign < 0 ) return( -INFINITY );
71  return( INFINITY );
72 }
G4int sign(const T t)
double nfu_getNAN ( void  )

Definition at line 54 of file nf_utilities.cc.

54  {
55 
56  return( NAN );
57 }

Here is the caller graph for this function:

int nfu_isNAN ( double  d)

Definition at line 61 of file nf_utilities.cc.

61  {
62 
63  return( is_nan( d ) );
64 }
#define is_nan(a)
Definition: nf_utilities.cc:18

Here is the caller graph for this function:

void* nfu_malloc ( size_t  size)

Definition at line 113 of file nf_utilities.cc.

113  {
114 
115  void *p = malloc( size );
116 
117  if( nfu_debugging ) printf( "nfu_malloc %12p size = %8llu\n", p, (long long unsigned) size );
118  return( p );
119 }
const char * p
Definition: xmltok.h:285
static int nfu_debugging
Definition: nf_utilities.cc:49

Here is the caller graph for this function:

void nfu_printErrorMsg ( char *  fmt,
  ... 
)

Definition at line 166 of file nf_utilities.cc.

166  {
167 
168  va_list args;
169 
170  va_start( args, fmt );
171  vfprintf( stderr, fmt, args );
172  fprintf( stderr, "\n" );
173  va_end( args );
174 
175  exit( EXIT_FAILURE );
176 }
void nfu_printMsg ( char *  fmt,
  ... 
)

Definition at line 154 of file nf_utilities.cc.

154  {
155 
156  va_list args;
157 
158  va_start( args, fmt );
159  vfprintf( stderr, fmt, args );
160  fprintf( stderr, "\n" );
161  va_end( args );
162 }
void* nfu_realloc ( size_t  size,
void old 
)

Definition at line 133 of file nf_utilities.cc.

133  {
134 
135  void *p = realloc( old, size );
136 
137  if( nfu_debugging ) printf( "nfu_realloc %12p size = %8llu, old = %12p\n", p, (long long unsigned) size, old );
138  return( p );
139 }
const char * p
Definition: xmltok.h:285
static int nfu_debugging
Definition: nf_utilities.cc:49

Here is the caller graph for this function:

void nfu_setMemoryDebugMode ( int  mode)

Definition at line 106 of file nf_utilities.cc.

106  {
107 
108  nfu_debugging = mode;
109 }
static int nfu_debugging
Definition: nf_utilities.cc:49
const char* nfu_statusMessage ( nfu_status  status)

Definition at line 76 of file nf_utilities.cc.

76  {
77 
78  switch( status ) {
79  case nfu_Okay : return( Okay_message );
80  case nfu_mallocError : return( mallocError_message );
82  case nfu_badIndex : return( badIndex_message );
84  case nfu_badIndexForX : return( badIndexForX_message );
87  case nfu_badSelf : return( badSelf_message );
88  case nfu_divByZero : return( divByZero_message );
91  case nfu_empty : return( empty_message );
92  case nfu_tooFewPoints : return( tooFewPoints_message );
94  case nfu_badInput : return( badInput_message );
95  case nfu_badNorm : return( badNorm_message );
100  }
101  return( unknownStatus_message );
102 }
static const char empty_message[]
Definition: nf_utilities.cc:38
static const char mallocError_message[]
Definition: nf_utilities.cc:27
static const char unsupportedInterpolation_message[]
Definition: nf_utilities.cc:36
static const char XNotAscending_message[]
Definition: nf_utilities.cc:30
static const char insufficientMemory_message[]
Definition: nf_utilities.cc:28
static const char badIndex_message[]
Definition: nf_utilities.cc:29
static const char unsupportedInterpolationConversion_message[]
Definition: nf_utilities.cc:37
static const char tooFewPoints_message[]
Definition: nf_utilities.cc:39
static const char badSelf_message[]
Definition: nf_utilities.cc:34
static const char unknownStatus_message[]
Definition: nf_utilities.cc:41
static const char otherInterpolation_message[]
Definition: nf_utilities.cc:45
static const char XOutsideDomain_message[]
Definition: nf_utilities.cc:32
static const char Okay_message[]
Definition: nf_utilities.cc:26
static const char notMutualDomian_message[]
Definition: nf_utilities.cc:40
static const char divByZero_message[]
Definition: nf_utilities.cc:35
static const char badIntegrationInput_message[]
Definition: nf_utilities.cc:44
static const char failedToConverge_message[]
Definition: nf_utilities.cc:46
static const char invalidInterpolation_message[]
Definition: nf_utilities.cc:33
static const char badIndexForX_message[]
Definition: nf_utilities.cc:31
static const char badInput_message[]
Definition: nf_utilities.cc:42
static const char badNorm_message[]
Definition: nf_utilities.cc:43
static const char oddNumberOfValues_message[]
Definition: nf_utilities.cc:47

Here is the caller graph for this function:

Variable Documentation

const char badIndex_message[] = "bad index"
static

Definition at line 29 of file nf_utilities.cc.

const char badIndexForX_message[] = "index not correct for x value"
static

Definition at line 31 of file nf_utilities.cc.

const char badInput_message[] = "bad input to function"
static

Definition at line 42 of file nf_utilities.cc.

const char badIntegrationInput_message[] = "bad integration input"
static

Definition at line 44 of file nf_utilities.cc.

const char badNorm_message[] = "bad norm"
static

Definition at line 43 of file nf_utilities.cc.

const char badSelf_message[] = "source object has bad status value"
static

Definition at line 34 of file nf_utilities.cc.

const char divByZero_message[] = "division by zero"
static

Definition at line 35 of file nf_utilities.cc.

const char empty_message[] = "empty instance"
static

Definition at line 38 of file nf_utilities.cc.

const char failedToConverge_message[] = "failed to converge"
static

Definition at line 46 of file nf_utilities.cc.

const char insufficientMemory_message[] = "user's memory is too small to hanlde data"
static

Definition at line 28 of file nf_utilities.cc.

const char invalidInterpolation_message[] = "bad x,y values for interpolation"
static

Definition at line 33 of file nf_utilities.cc.

const char mallocError_message[] = "could not allocate memory"
static

Definition at line 27 of file nf_utilities.cc.

int nfu_debugging = 0
static

Definition at line 49 of file nf_utilities.cc.

const char notMutualDomian_message[] = "domains are not mutual"
static

Definition at line 40 of file nf_utilities.cc.

const char oddNumberOfValues_message[] = "odd number of inputted values"
static

Definition at line 47 of file nf_utilities.cc.

const char Okay_message[] = "all is okay"
static

Definition at line 26 of file nf_utilities.cc.

const char otherInterpolation_message[] = "other integration not supported"
static

Definition at line 45 of file nf_utilities.cc.

const char tooFewPoints_message[] = "too few points in instance"
static

Definition at line 39 of file nf_utilities.cc.

const char unknownStatus_message[] = "unknown (i.e., invalid) status value"
static

Definition at line 41 of file nf_utilities.cc.

const char unsupportedInterpolation_message[] = "unsupported interpolation"
static

Definition at line 36 of file nf_utilities.cc.

const char unsupportedInterpolationConversion_message[] = "unsupported interpolation conversion"
static

Definition at line 37 of file nf_utilities.cc.

const char XNotAscending_message[] = "x values are not ascending"
static

Definition at line 30 of file nf_utilities.cc.

const char XOutsideDomain_message[] = "x value not in domain"
static

Definition at line 32 of file nf_utilities.cc.