/*! \file util.c \brief Various utility routines \date Started 4/12/2007 \author George \version\verbatim $Id: gk_util.c 16223 2014-02-15 21:34:09Z karypis $ \endverbatim */ #include /************************************************************************* * This file randomly permutes the contents of an array. * flag == 0, don't initialize perm * flag == 1, set p[i] = i **************************************************************************/ void gk_RandomPermute(size_t n, int *p, int flag) { size_t i, u, v; int tmp; if (flag == 1) { for (i=0; i 1; i++, a = a>>1); return i-1; } /************************************************************************* * This function checks if the argument is a power of 2 **************************************************************************/ int gk_ispow2(int a) { return (a == (1<