cmMath.h/c : Added cmModIncr().

This commit is contained in:
kevin 2015-07-16 19:01:54 -04:00
parent a59041336a
commit 01505d751a
2 changed files with 20 additions and 0 deletions

View File

@ -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 )

View File

@ -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