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

Go to the source code of this file.

Functions

int nfu_setup (void)
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 const *fmt,...)
void nfu_printErrorMsg (char const *fmt,...)

Variables

int nfu_SMR_libraryID = smr_unknownID

Function Documentation

◆ nfu_calloc()

void * nfu_calloc ( size_t size,
size_t n )

Definition at line 133 of file nf_utilities.c.

133 {
134
135 void *p = calloc( size, n );
136
137 if( nfu_debugging ) printf( "nfu_calloc %12p size = %8llu, n = %8llu\n", p, (long long unsigned) size, (long long unsigned) n );
138 return( p );
139}
voidp calloc(uInt items, uInt size)

◆ nfu_free()

void * nfu_free ( void * p)

Definition at line 153 of file nf_utilities.c.

153 {
154
155 if( p != NULL ) {
156 if( nfu_debugging ) printf( "nfu_free %12p\n", p );
157 free( p );
158 }
159 return( NULL );
160}
void free(voidpf ptr)

Referenced by nf_Legendre_free(), nf_Legendre_new(), and nf_Legendre_release().

◆ nfu_getInfinity()

double nfu_getInfinity ( double sign)

Definition at line 74 of file nf_utilities.c.

74 {
75
76 if( sign < 0 ) return( -INFINITY );
77 return( INFINITY );
78}

◆ nfu_getNAN()

double nfu_getNAN ( void )

Definition at line 60 of file nf_utilities.c.

60 {
61
62 return( NAN );
63}

Referenced by ptwXY_div_ptwXY().

◆ nfu_isNAN()

int nfu_isNAN ( double d)

Definition at line 67 of file nf_utilities.c.

67 {
68
69 return( isnan( d ) );
70}

Referenced by ptwXY_div_ptwXY().

◆ nfu_malloc()

void * nfu_malloc ( size_t size)

Definition at line 123 of file nf_utilities.c.

123 {
124
125 void *p = malloc( size );
126
127 if( nfu_debugging ) printf( "nfu_malloc %12p size = %8llu\n", p, (long long unsigned) size );
128 return( p );
129}
voidp malloc(uInt size)

◆ nfu_printErrorMsg()

void nfu_printErrorMsg ( char const * fmt,
... )

Definition at line 176 of file nf_utilities.c.

176 {
177
178 va_list args;
179
180 va_start( args, fmt );
181 vfprintf( stderr, fmt, args );
182 fprintf( stderr, "\n" );
183 va_end( args );
184
185 exit( EXIT_FAILURE );
186}

◆ nfu_printMsg()

void nfu_printMsg ( char const * fmt,
... )

Definition at line 164 of file nf_utilities.c.

164 {
165
166 va_list args;
167
168 va_start( args, fmt );
169 vfprintf( stderr, fmt, args );
170 fprintf( stderr, "\n" );
171 va_end( args );
172}

◆ nfu_realloc()

void * nfu_realloc ( size_t size,
void * old )

Definition at line 143 of file nf_utilities.c.

143 {
144
145 void *p = realloc( old, size );
146
147 if( nfu_debugging ) printf( "nfu_realloc %12p size = %8llu, old = %12p\n", p, (long long unsigned) size, old );
148 return( p );
149}

Referenced by nf_Legendre_reallocateCls().

◆ nfu_setMemoryDebugMode()

void nfu_setMemoryDebugMode ( int mode)

Definition at line 116 of file nf_utilities.c.

116 {
117
118 nfu_debugging = mode;
119}

◆ nfu_setup()

int nfu_setup ( void )

Definition at line 51 of file nf_utilities.c.

51 {
52
53 nfu_SMR_libraryID = smr_registerLibrary( "numericalFunctions" );
54
55 return( 0 );
56}
int nfu_SMR_libraryID
int smr_registerLibrary(char const *libraryName)

◆ nfu_statusMessage()

const char * nfu_statusMessage ( nfu_status status)

Definition at line 82 of file nf_utilities.c.

82 {
83
84printf( "status = %d\n", status );
85 switch( status ) {
86 case nfu_Okay : return( Okay_message );
87 case nfu_Error : return( Error_message );
88 case nfu_mallocError : return( mallocError_message );
89 case nfu_insufficientMemory : return( insufficientMemory_message );
90 case nfu_badIndex : return( badIndex_message );
91 case nfu_XNotAscending : return( XNotAscending_message );
92 case nfu_badIndexForX : return( badIndexForX_message );
93 case nfu_XOutsideDomain : return( XOutsideDomain_message );
94 case nfu_invalidInterpolation : return( invalidInterpolation_message );
95 case nfu_badSelf : return( badSelf_message );
96 case nfu_divByZero : return( divByZero_message );
97 case nfu_unsupportedInterpolation : return( unsupportedInterpolation_message );
98 case nfu_unsupportedInterpolationConversion : return( unsupportedInterpolationConversion_message );
99 case nfu_empty : return( empty_message );
100 case nfu_tooFewPoints : return( tooFewPoints_message );
101 case nfu_domainsNotMutual : return( notMutualDomian_message );
102 case nfu_badInput : return( badInput_message );
103 case nfu_badNorm : return( badNorm_message );
104 case nfu_badIntegrationInput : return( badIntegrationInput_message );
105 case nfu_otherInterpolation : return( otherInterpolation_message );
106 case nfu_flatInterpolation : return( flatInterpolation_message );
107 case nfu_failedToConverge : return( failedToConverge_message );
108 case nfu_oddNumberOfValues : return( oddNumberOfValues_message );
109 case nfu_badLogValue : return( badLogValue_message );
110 }
111 return( unknownStatus_message );
112}
@ nfu_unsupportedInterpolation
@ nfu_domainsNotMutual
@ nfu_XNotAscending
@ nfu_invalidInterpolation
@ nfu_Okay
@ nfu_badSelf
@ nfu_badLogValue
@ nfu_oddNumberOfValues
@ nfu_mallocError
@ nfu_insufficientMemory
@ nfu_flatInterpolation
@ nfu_badNorm
@ nfu_badIntegrationInput
@ nfu_XOutsideDomain
@ nfu_badIndex
@ nfu_failedToConverge
@ nfu_tooFewPoints
@ nfu_unsupportedInterpolationConversion
@ nfu_badInput
@ nfu_badIndexForX
@ nfu_Error
@ nfu_empty
@ nfu_divByZero
@ nfu_otherInterpolation

Variable Documentation

◆ nfu_SMR_libraryID

int nfu_SMR_libraryID = smr_unknownID

Definition at line 46 of file nf_utilities.c.

Referenced by nf_Legendre_allocated(), nf_Legendre_clone(), nf_Legendre_evauluateAtMu(), nf_Legendre_from_ptwXY(), nf_Legendre_getCl(), nf_Legendre_initialize(), nf_Legendre_maxOrder(), nf_Legendre_normalize(), nf_Legendre_reallocateCls(), nf_Legendre_setCl(), nf_Legendre_to_ptwXY(), nfu_setup(), nfu_stringToInt32(), nfu_stringToListOfDoubles(), nfu_stringToListOfInt32s(), ptwX_abs(), ptwX_add_double(), ptwX_add_ptwX(), ptwX_ascendingOrder(), ptwX_clone(), ptwX_close(), ptwX_closesDifferenceInRange(), ptwX_compare(), ptwX_copy(), ptwX_countOccurrences(), ptwX_create(), ptwX_createLine(), ptwX_deletePoints(), ptwX_fromString(), ptwX_getPointAtIndex(), ptwX_initialize(), ptwX_insertPointsAtIndex(), ptwX_length(), ptwX_mul_double(), ptwX_neg(), ptwX_new(), ptwX_range(), ptwX_reallocatePoints(), ptwX_reverse(), ptwX_setData(), ptwX_setPointAtIndex(), ptwX_slice(), ptwX_slopeOffset(), ptwX_sort(), ptwX_sub_ptwX(), ptwX_unique(), ptwXY_abs(), ptwXY_add_double(), ptwXY_add_ptwXY(), ptwXY_appendXY(), ptwXY_applyFunction(), ptwXY_areDomainsMutual(), ptwXY_binary_ptwXY(), ptwXY_clear(), ptwXY_clip(), ptwXY_clone(), ptwXY_clone2(), ptwXY_cloneToInterpolation(), ptwXY_coalescePoints(), ptwXY_convolution(), ptwXY_copy(), ptwXY_copyPointsOnly(), ptwXY_copyToC_XY(), ptwXY_create(), ptwXY_createFrom_Xs_Ys(), ptwXY_createFromFunction(), ptwXY_createFromFunction2(), ptwXY_createGaussian(), ptwXY_createGaussianCenteredSigma1(), ptwXY_deletePoints(), ptwXY_div_doubleFrom(), ptwXY_div_fromDouble(), ptwXY_div_ptwXY(), ptwXY_domainMax(), ptwXY_domainMaxAndFrom(), ptwXY_domainMaxSlice(), ptwXY_domainMin(), ptwXY_domainMinAndFrom(), ptwXY_domainMinSlice(), ptwXY_domainSlice(), ptwXY_dullEdges(), ptwXY_equalProbableBins(), ptwXY_exp(), ptwXY_f_integrate(), ptwXY_flatInterpolationToLinear(), ptwXY_fromString(), ptwXY_fromUnitbase(), ptwXY_getLowerIndexBoundingX(), ptwXY_getNonOverflowLength(), ptwXY_getPointAtIndex(), ptwXY_getPointsAroundX(), ptwXY_getPointsAroundX_closeIsEqual(), ptwXY_getSlopeAtX(), ptwXY_getValueAtX(), ptwXY_getXArray(), ptwXY_getXYPairAtIndex(), ptwXY_groupOneFunction(), ptwXY_groupThreeFunctions(), ptwXY_groupTwoFunctions(), ptwXY_initialize(), ptwXY_integrate(), ptwXY_integrateDomain(), ptwXY_integrateDomainWithWeight_sqrt_x(), ptwXY_integrateDomainWithWeight_x(), ptwXY_integrateWithFunction(), ptwXY_integrateWithWeight_sqrt_x(), ptwXY_integrateWithWeight_x(), ptwXY_interpolatePoint(), ptwXY_intersectionWith_ptwX(), ptwXY_inverse(), ptwXY_length(), ptwXY_mapToXsAndAdd(), ptwXY_mergeClosePoints(), ptwXY_mergeFromXsAndYs(), ptwXY_mergeFromXYs(), ptwXY_mod(), ptwXY_mul2_ptwXY(), ptwXY_mul_double(), ptwXY_mul_ptwXY(), ptwXY_mutualifyDomains(), ptwXY_neg(), ptwXY_new(), ptwXY_normalize(), ptwXY_pow(), ptwXY_range(), ptwXY_rangeMax(), ptwXY_rangeMin(), ptwXY_reallocateOverflowPoints(), ptwXY_reallocatePoints(), ptwXY_runningIntegral(), ptwXY_scaleAndOffsetDomainWith_ptwXYs(), ptwXY_scaleOffsetXAndY(), ptwXY_setValueAtX(), ptwXY_setValueAtX_overrideIfClose(), ptwXY_setXYData(), ptwXY_setXYDataFromXsAndYs(), ptwXY_setXYPairAtIndex(), ptwXY_simpleCoalescePoints(), ptwXY_slice(), ptwXY_slopeOffset(), ptwXY_startIndex(), ptwXY_sub_doubleFrom(), ptwXY_sub_fromDouble(), ptwXY_sub_ptwXY(), ptwXY_thicken(), ptwXY_thin(), ptwXY_thinDomain(), ptwXY_toOtherInterpolation(), ptwXY_toUnitbase(), ptwXY_trim(), ptwXY_tweakDomainsToMutualify(), ptwXY_union(), ptwXY_unitbaseInterpolate(), ptwXY_valuesToC_XsAndYs(), ptwXY_valueTo_ptwXY(), and ptwXY_ysMappedToXs().