Ejemplo n.º 1
0
void StructuredDataset::Randomize() {
  int *perm = RandPerm(num_examples);
  StructuredExample **examples_new = (StructuredExample**)malloc(sizeof(StructuredExample*)*(num_examples));
  for(int i = 0; i < num_examples; i++) 
    examples_new[i] = examples[perm[i]];
  free(examples);
  examples = examples_new;
  free(perm);
}
Ejemplo n.º 2
0
/*---------------------------------------------------------------
  RandPermList() - randomly permutes members of the given list.
  ------------------------------------------------------------*/
int RandPermList(int N, int *v)
{
  int *p, *vp, n;

  if (v==NULL)
  {
    printf("ERROR: RandPermVect: vector is null\n");
    return(1);
  }

  p = RandPerm(N,NULL);
  vp = (int *) calloc(sizeof(int),N);
  for (n=0;n<N;n++) vp[n] = v[n];
  for (n=0;n<N;n++) v[n]  = vp[p[n]];

  free(p);
  free(vp);

  return(0);
}