mirror of
https://github.com/pjreddie/darknet.git
synced 2023-08-10 21:13:14 +03:00
lots of stuff
This commit is contained in:
23
src/utils.c
23
src/utils.c
@ -8,6 +8,29 @@
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
void sorta_shuffle(void *arr, size_t n, size_t size, size_t sections)
|
||||
{
|
||||
size_t i;
|
||||
for(i = 0; i < sections; ++i){
|
||||
size_t start = n*i/sections;
|
||||
size_t end = n*(i+1)/sections;
|
||||
size_t num = end-start;
|
||||
shuffle(arr+(start*size), num, size);
|
||||
}
|
||||
}
|
||||
|
||||
void shuffle(void *arr, size_t n, size_t size)
|
||||
{
|
||||
size_t i;
|
||||
void *swp = calloc(1, size);
|
||||
for(i = 0; i < n-1; ++i){
|
||||
size_t j = i + rand()/(RAND_MAX / (n-i)+1);
|
||||
memcpy(swp, arr+(j*size), size);
|
||||
memcpy(arr+(j*size), arr+(i*size), size);
|
||||
memcpy(arr+(i*size), swp, size);
|
||||
}
|
||||
}
|
||||
|
||||
void del_arg(int argc, char **argv, int index)
|
||||
{
|
||||
int i;
|
||||
|
Reference in New Issue
Block a user