Skip to content

Instantly share code, notes, and snippets.

@isag
Created March 31, 2012 16:17
Show Gist options
  • Save isag/2266492 to your computer and use it in GitHub Desktop.
Save isag/2266492 to your computer and use it in GitHub Desktop.
double **select_subpool(Params *p, double **pool,int nrows,int nrows_sub)
{
int positions[nrows];
for(int i = 0 ; i < nrows ; ++i) positions[i] = i;
// shuffle the vector
//-------------------
knuth_shuffle((void*)positions, nrows, p->rng, sizeof(int*));
for (int i = 0 ; i < nrows ; ++i) printf("%d\t",positions[i]);
printf("\n");
}
@PhDP
Copy link

PhDP commented Mar 31, 2012

It's sizeof(int).

BTW if you name the file with a .c extension gist will add syntax highlighting.

@PhDP
Copy link

PhDP commented Mar 31, 2012

The code from facilication.c (line 64) is also broken. It works simply because, in many cases, sizeof(double*) returns 8, just like sizeof(double), but it might not be true for all computers (the size of pointers vary).

@isag
Copy link
Author

isag commented Mar 31, 2012

Ok, I applied the method for a matrix shuffle (that's why I put the *).
I will removed the star in facilitation too.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment