PFUNC  1.0
Functions | Variables
pfunc/utility.h File Reference
#include <pfunc/config.h>
#include <pfunc/environ.hpp>
#include <stdlib.h>

Go to the source code of this file.

Functions

static double get_next_rand ()
static int get_closest_power_of_2 (const int n)
static PFUNC_INLINE double micro_time ()

Variables

static const double NORMALIZER = static_cast<double>(RAND_MAX)

Function Documentation

static int get_closest_power_of_2 ( const int  n) [inline, static]

Returns the next highest power of two for the given number.

Parameters:
[in]nThe number for which we want to find the next closest power.
Returns:
The power of 2 closest to 'n'. E.g., for 3, 4 is returned.
static double get_next_rand ( ) [inline, static]
static PFUNC_INLINE double micro_time ( ) [static]

Returns the time in seconds (as a double) to micro-second accuracy. This function can be used to measure the time elapsed. Eg., start = micro_time (); do_stuff (); end = micro_time () - start;


Variable Documentation

const double NORMALIZER = static_cast<double>(RAND_MAX) [static]

All the utility functions are in the C domain on purpose. Its a lot simpler to use this way and we do not need a wrapper from C++. Returns a random double in the range (0.0,1.0]. Notice that the random number generator is never initialized --- we don't really care about :).

Returns:
random double in the range (0.0,1.0].