/* * Copyright 1997, Regents of the University of Minnesota * * util.c * * This file contains utility functions * * $Id: util.c 1421 2007-04-06 14:37:41Z karypis $ * */ #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) { gk_idx_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<