TPCCLIB
Loading...
Searching...
No Matches
shuffle.c
Go to the documentation of this file.
1
5/******************************************************************************/
6#include "libtpcmodel.h"
7/******************************************************************************/
8
9/******************************************************************************/
13void random_shuffle(int *array, int n)
14{
15 if(n<=1 || array==NULL) return;
16 int i, j, tmp;
17 for(i=0; i<n-1; i++) {
18 j=i+rand()/(RAND_MAX/(n-i)+1);
19 tmp=array[j]; array[j]=array[i]; array[i]=tmp;
20 }
21}
22/******************************************************************************/
23
24/******************************************************************************/
29void randperm(int *array, int n, int a)
30{
31 if(n<1 || array==NULL) return;
32 int i;
33 for(i=0; i<n; i++) array[i]=i+a;
34 random_shuffle(array, n);
35}
36/******************************************************************************/
37
38/******************************************************************************/
#define RAND_MAX
Definition gaussdev.c:13
Header file for libtpcmodel.
void randperm(int *array, int n, int a)
Definition shuffle.c:29
void random_shuffle(int *array, int n)
Definition shuffle.c:13