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.
void vl_rand_seed (VlRand *self, vl_uint32 s)
 Seed the state of the random number generator.
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.
void vl_rand_permute_indexes (VlRand *self, vl_index *array, vl_size size)
 Randomly permute and array of indexes.
vl_uint32 vl_rand_uint32 (VlRand *self)
 Generate a random UINT32.

Detailed Description

Author:
Andrea Vedaldi

Function Documentation

void vl_rand_init ( VlRand self)
Parameters:
selfnumber generator.
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.

void vl_rand_seed ( VlRand self,
vl_uint32  s 
)
Parameters:
selfrandom number generator.
sseed.
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_uint32 vl_rand_uint32 ( VlRand self)
Parameters:
selfrandom number generator.
Returns:
a random number in [0, 0xffffffff].