|
M4RI 1.0.1
|
Gray code implementation. More...
#include "misc.h"Go to the source code of this file.
Data Structures | |
| struct | code |
| Gray codes. More... | |
Defines | |
| #define | MAXKAY 16 |
Functions | |
| int | m4ri_swap_bits (int v, int l) |
| 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 ** | codebook |
Gray code implementation.
The Gray code is a binary numeral system where two successive values differ in only one digit.
| #define MAXKAY 16 |
Maximum allowed value for k.
| void m4ri_build_all_codes | ( | void | ) |
Generates global code book.
This function is called automatically when the shared library is loaded.
| 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
.
| ord | Will hold gray code data, must be preallocated with correct size |
| inc | Will hold some increment data, must be preallocated with correct size |
| l | Logarithm of length of Gray code. |
| void m4ri_destroy_all_codes | ( | void | ) |
Frees memory from the global code book.
This function is called automatically when the shared library is unloaded.
| int m4ri_gray_code | ( | int | i, |
| int | l | ||
| ) |
Returns the i-th gray code entry for a gray code of length
.
| i | The ndex in the Gray code table. |
| l | Length of the Gray code. |
| 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
where
is
for inversion and
for multiplication.
| a | Number of rows of (first) matrix |
| b | Number of columns of (first) matrix |
| c | Number of columns of second matrix (may be 0) |
| int m4ri_swap_bits | ( | int | v, |
| int | l | ||
| ) |
Swaps l bits in v.
1.7.4