M4RI 1.0.1
Data Structures | Defines | Functions | Variables
grayflex.h File Reference

Gray code implementation. More...

Go to the source code of this file.

Data Structures

struct  code
 Gray codes. More...

Defines

#define __M4RI_MAXKAY   16

Functions

int m4ri_gray_code (int i, int l)
void m4ri_build_code (int *ord, int *inc, int l)
void m4ri_build_all_codes (void)
 Generates global code book.
void m4ri_destroy_all_codes (void)
int m4ri_opt_k (int a, int b, int c)
 Return the optimal var k for the given parameters.

Variables

code ** m4ri_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@fordham.edu>
Martin Albrecht <M.R.Albrecht@rhul.ac.uk>

Define Documentation

#define __M4RI_MAXKAY   16

Maximum allowed value for k.


Function Documentation

void m4ri_build_all_codes ( void  )

Generates global code book.

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

Warning:
Not thread safe!
void m4ri_build_code ( int *  ord,
int *  inc,
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 m4ri_destroy_all_codes ( void  )

Frees memory from the global code book.

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

Warning:
Not thread safe!
int m4ri_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.
int m4ri_opt_k ( int  a,
int  b,
int  c 
)

Return the optimal var k for the given parameters.

If var c != 0 then var k for multiplication is returned, else var k for inversion. The optimal var k here means $0.75 log_2(n)$ where $n$ is $min(a,b)$ for inversion and $b$ for multiplication.

Parameters:
aNumber of rows of (first) matrix
bNumber of columns of (first) matrix
cNumber of columns of second matrix (may be 0)
Returns:
k

Variable Documentation

Global m4ri_codebook.

Warning:
Not thread safe!