Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
nf_utilities.cc File Reference
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include "nf_utilities.h"

Go to the source code of this file.

Macros

#define is_nan(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)
 
void * nfu_malloc (size_t size)
 
void * nfu_calloc (size_t size, size_t n)
 
void * nfu_realloc (size_t size, void *old)
 
void * nfu_free (void *p)
 
void nfu_printMsg (char *fmt,...)
 
void nfu_printErrorMsg (char *fmt,...)
 

Macro Definition Documentation

◆ is_nan

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

Definition at line 18 of file nf_utilities.cc.

Referenced by nfu_isNAN().

Function Documentation

◆ nfu_calloc()

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}

Referenced by ptwX_new(), ptwXY_new(), and ptwXY_thin().

◆ nfu_free()

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}

Referenced by nf_Legendre_free(), nf_Legendre_new(), nf_Legendre_release(), ptwX_free(), ptwX_fromString(), ptwX_new(), ptwX_release(), ptwXY_cloneToInterpolation(), ptwXY_copy(), ptwXY_free(), ptwXY_fromString(), ptwXY_mergeFromXYs(), ptwXY_new(), ptwXY_release(), and ptwXY_thin().

◆ nfu_getInfinity()

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}

◆ nfu_getNAN()

double nfu_getNAN ( void )

Definition at line 54 of file nf_utilities.cc.

54 {
55
56 return( NAN );
57}

Referenced by ptwXY_div_ptwXY(), ptwXY_getXMaxAndFrom(), and ptwXY_getXMinAndFrom().

◆ nfu_isNAN()

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)

Referenced by ptwXY_div_ptwXY().

◆ nfu_malloc()

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}

Referenced by nf_Legendre_new(), and ptwXY_mergeFromXYs().

◆ nfu_printErrorMsg()

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}

◆ nfu_printMsg()

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}

◆ nfu_realloc()

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", p, (long long unsigned) size );
138 return( p );
139}

Referenced by nf_Legendre_reallocateCls(), ptwX_reallocatePoints(), ptwXY_reallocateOverflowPoints(), and ptwXY_reallocatePoints().

◆ nfu_setMemoryDebugMode()

void nfu_setMemoryDebugMode ( int mode)

Definition at line 106 of file nf_utilities.cc.

106 {
107
108 nfu_debugging = mode;
109}

◆ nfu_statusMessage()

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 );
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 );
100 }
101 return( unknownStatus_message );
102}
@ nfu_unsupportedInterpolation
@ nfu_domainsNotMutual
@ nfu_XNotAscending
@ nfu_invalidInterpolation
@ nfu_Okay
@ nfu_badSelf
@ nfu_oddNumberOfValues
@ nfu_mallocError
@ nfu_insufficientMemory
@ nfu_badNorm
@ nfu_badIntegrationInput
@ nfu_XOutsideDomain
@ nfu_badIndex
@ nfu_failedToConverge
@ nfu_tooFewPoints
@ nfu_unsupportedInterpolationConversion
@ nfu_badInput
@ nfu_badIndexForX
@ nfu_empty
@ nfu_divByZero
@ nfu_otherInterpolation

Referenced by MCGIDI_angular_parseFromTOM(), MCGIDI_fromTOM_pdfOfX(), MCGIDI_product_parseFromTOM(), MCGIDI_target_heated_read(), and MCGIDI_target_heated_recast().