Documentation>C API
random.c File Reference

Random number generator - Definition. More...

#include "random.h"
#include <stdio.h>
#include <string.h>

Functions

void vl_rand_init (VlRand *self)
 Initialise random number generator. More...
 
void vl_rand_seed (VlRand *self, vl_uint32 s)
 Seed the state of the random number generator. More...
 
void vl_rand_seed_by_array (VlRand *self, vl_uint32 const key [], vl_size keySize)
 Seed the state of the random number generator by an array. More...
 
void vl_rand_permute_indexes (VlRand *self, vl_index *array, vl_size size)
 Randomly permute and array of indexes. More...
 
vl_uint32 vl_rand_uint32 (VlRand *self)
 Generate a random UINT32. More...
 

Detailed Description

Author
Andrea Vedaldi

Function Documentation

◆ vl_rand_init()

void vl_rand_init ( VlRand self)
Parameters
selfnumber generator.

◆ vl_rand_permute_indexes()

void vl_rand_permute_indexes ( VlRand self,
vl_index array,
vl_size  size 
)
Parameters
selfrandom number generator.
arrayarray of indexes.
sizenumber of element in the array.

The function uses Algorithm P, also known as Knuth shuffle.

◆ vl_rand_seed()

void vl_rand_seed ( VlRand self,
vl_uint32  s 
)
Parameters
selfrandom number generator.
sseed.

◆ vl_rand_seed_by_array()

void vl_rand_seed_by_array ( VlRand self,
vl_uint32 const  key[],
vl_size  keySize 
)
Parameters
selfrandom number generator.
keyarray of numbers.
keySizelength of the array.

◆ vl_rand_uint32()

vl_uint32 vl_rand_uint32 ( VlRand self)
Parameters
selfrandom number generator.
Returns
a random number in [0, 0xffffffff].