ABY Framework  1.0
Arithmetic Bool Yao Framework
 All Classes Files Functions Variables Enumerations Enumerator Macros
Classes | Functions
graycode.h File Reference

Gray code implementation. More...

#include "typedefs.h"
Include dependency graph for graycode.h:

Go to the source code of this file.

Classes

struct  code
 Gray codes. More...
 

Functions

int gray_code (int i, int l)
 
codebuild_code (int l)
 
void destroy_code (code *codebook)
 

Detailed Description

Gray code implementation.

The Gray code is a binary numeral system where two successive values differ in only one digit.

Author
Gregory Bard bard@.nosp@m.ford.nosp@m.ham.e.nosp@m.du
Martin Albrecht M.R.A.nosp@m.lbre.nosp@m.cht@r.nosp@m.hul..nosp@m.ac.uk

Function Documentation

code* build_code ( int  l)

Fills var ord and var inc with Gray code data for a Gray code of length $2^l$.

Parameters
ordWill hold gray code data, must be preallocated with correct size
incWill hold some increment data, must be preallocated with correct size
lLogarithm of length of Gray code.
Note
Robert Miller had the idea for a non-recursive implementation.
void destroy_code ( code codebook)

Frees memory from the global code book.

This function is called automatically when the shared library is unloaded.

Warning
Not thread safe!
int gray_code ( int  i,
int  l 
)

Returns the i-th gray code entry for a gray code of length $2^l$.

Parameters
iThe index in the Gray code table.
lLength of the Gray code.
Returns
i-th Gray code entry.