include/mxUtil.h
inline int randi(int imax) { 
 assert(imax>0);
 imax--;
 if (imax==0) return 0;
 int guard = (int) (randu()*imax)+1;
 return (guard > imax)? imax : guard;
}
// randi returns a random integer in 0..imax-1
randi returns a random integer in 0..imax-1
randi returns a random integer in 0 .. imax - 1
inline int randi(int imax) { 
 assert(imax>0);
 imax--;
 if (imax==0) return 0;
 int guard = (int) (randu()*imax)+1;
 return (guard > imax)? imax : guard;
}
inline int randi ( int imax ) { assert ( imax > 0 ) ; imax -- ; if ( imax == 0 ) return 0 ; int guard = ( int ) ( randu ( ) * imax ) + 1 ; return ( guard > imax ) ? imax : guard ; }
randi returns a random integer in 0..imax-1
randi returns a random integer in 0 .. imax - 1