cmMath.h/c : Added cmModIncr().
This commit is contained in:
parent
a59041336a
commit
01505d751a
14
cmMath.c
14
cmMath.c
@ -154,6 +154,20 @@ unsigned cmPrevOddU( unsigned v ) { return cmIsOddU(v) ? v : v-1; }
|
||||
unsigned cmNextEvenU( unsigned v ) { return cmIsEvenU(v) ? v : v+1; }
|
||||
unsigned cmPrevEvenU( unsigned v ) { return cmIsEvenU(v) ? v : v-1; }
|
||||
|
||||
unsigned cmModIncr(int idx, int delta, int maxN )
|
||||
{
|
||||
int sum = idx + delta;
|
||||
|
||||
if( sum >= maxN )
|
||||
return sum - maxN;
|
||||
|
||||
if( sum < 0 )
|
||||
return maxN + sum;
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
// modified bessel function of first kind, order 0
|
||||
// ref: orfandis appendix B io.m
|
||||
double cmBessel0( double x )
|
||||
|
6
cmMath.h
6
cmMath.h
@ -15,6 +15,12 @@ unsigned cmPrevOddU( unsigned v );
|
||||
unsigned cmNextEvenU( unsigned v );
|
||||
unsigned cmPrevEvenU( unsigned v );
|
||||
|
||||
/// Increment or decrement 'idx' by 'delta' always wrapping the result into the range
|
||||
/// 0 to (maxN-1).
|
||||
/// 'idx': initial value
|
||||
/// 'delta': incremental amount
|
||||
/// 'maxN' - 1 : maximum return value.
|
||||
unsigned cmModIncr(int idx, int delta, int maxN );
|
||||
|
||||
// modified bessel function of first kind, order 0
|
||||
// ref: orfandis appendix B io.m
|
||||
|
Loading…
Reference in New Issue
Block a user