/******************************************************************************
 *
 * aiiutils.h -- Useful inline functions 
 *
 * (c) Leonid (Lodrion) Taycher 2000
 *
 ******************************************************************************/


#ifndef __AIIUTILS_H__
#define __AIIUTILS_H__

#include <math.h>
#include <stdlib.h>

template <class T>
inline T Sqr(T x) { return x * x; };

// Rounder -- rounds the double value to the NEAREST integer.
inline int round(double v) { return int(floor(v + 0.5)); };

inline double realRnd() {return double(random()) / (double(RAND_MAX) + 1);};

inline int intRnd(int topval) { return (random() % topval); };

template <class T>
inline T aicMin(T lhs, T rhs) { return ((lhs < rhs) ? lhs : rhs); };

template <class T>
inline T aicMax(T lhs, T rhs) { return ((lhs > rhs) ? lhs : rhs); };
#endif
