/[pspp]/pspp/src/algorithm.c
ViewVC logotype

Diff of /pspp/src/algorithm.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.16 by blp, Sun Jul 31 05:35:05 2005 UTC revision 1.17 by jmd, Mon Oct 24 05:41:45 2005 UTC
# Line 307  is_partitioned (const void *array, size_ Line 307  is_partitioned (const void *array, size_
307    return 1;    return 1;
308  }  }
309    
 /* A algo_random_func that uses random.h. */  
 unsigned  
 algo_default_random (unsigned max, void *aux UNUSED)  
 {  
   unsigned long r_min = gsl_rng_min (get_rng ());  
   return (gsl_rng_get (get_rng ()) - r_min) % max;  
 }  
   
 /* Randomly reorders ARRAY, which contains COUNT elements of SIZE  
    bytes each.  Uses RANDOM as a source of random data, passing  
    AUX as the auxiliary data.  RANDOM may be null to use a  
    default random source. */  
 void  
 random_shuffle (void *array_, size_t count, size_t size,  
                 algo_random_func *random, void *aux)  
 {  
   unsigned char *array = array_;  
   int i;  
   
   if (random == NULL)  
     random = algo_default_random;  
   
   for (i = 1; i < count; i++)  
     SWAP (array + i * size, array + random (i + 1, aux) * size, size);  
 }  
   
310  /* Copies the COUNT elements of SIZE bytes each from ARRAY to  /* Copies the COUNT elements of SIZE bytes each from ARRAY to
311     RESULT, except that elements for which PREDICATE is false are     RESULT, except that elements for which PREDICATE is false are
312     not copied.  Returns the number of elements copied.  AUX is     not copied.  Returns the number of elements copied.  AUX is

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26