Documentation>C API
Functions
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

  self | number generator.

## ◆ vl_rand_permute_indexes()

void vl_rand_permute_indexes | ( | VlRand * | self,
|  | vl_index * | array,
|  | vl_size | size
| ) |  |

Parameters

  self | random number generator.
  array | array of indexes.
  size | number 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

  self | random number generator.
  s | seed.

## ◆ vl_rand_seed_by_array()

void vl_rand_seed_by_array | ( | VlRand * | self,
|  | vl_uint32 const | key[],
|  | vl_size | keySize
| ) |  |

Parameters

  self | random number generator.
  key | array of numbers.
  keySize | length of the array.

## ◆ vl_rand_uint32()

vl_uint32 vl_rand_uint32 | ( | VlRand * | self | ) |

Parameters

  self | random number generator.

Returns
  a random number in [0, 0xffffffff].