M4RI
1.0.1
Main Page
Related Pages
Data Structures
Files
Examples
File List
Globals
graycode.h
1
12
#ifndef M4RI_GRAYFLEX_H
13
#define M4RI_GRAYFLEX_H
14
15
/******************************************************************************
16
*
17
* M4RI: Linear Algebra over GF(2)
18
*
19
* Copyright (C) 2007 Gregory Bard <gregory.bard@ieee.org>
20
* Copyright (C) 2007 Martin Albrecht <malb@informatik.uni-bremen.de>
21
*
22
* Distributed under the terms of the GNU General Public License (GPL)
23
* version 2 or higher.
24
*
25
* This code is distributed in the hope that it will be useful,
26
* but WITHOUT ANY WARRANTY; without even the implied warranty of
27
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28
* General Public License for more details.
29
*
30
* The full text of the GPL is available at:
31
*
32
* http://www.gnu.org/licenses/
33
******************************************************************************/
34
39
#define __M4RI_MAXKAY 16
40
65
typedef
struct
{
69
int
*
ord
;
73
int
*
inc
;
74
}
code
;
75
82
extern
code
**m4ri_codebook;
83
93
int
m4ri_gray_code(
int
i,
int
l);
94
107
void
m4ri_build_code(
int
*ord,
int
*inc,
int
l);
108
118
void
m4ri_build_all_codes(
void
);
119
129
void
m4ri_destroy_all_codes(
void
);
130
135
static
inline
int
log2_floor(
int
v) {
136
static
unsigned
const
int
b[] = { 0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000 };
137
static
unsigned
const
int
S[] = { 1, 2, 4, 8, 16 };
138
unsigned
int
r = 0;
139
for
(
int
i = 4; i >= 0; --i)
140
{
141
if
((v & b[i]))
142
{
143
v >>= S[i];
144
r |= S[i];
145
}
146
}
147
return
r;
148
}
149
150
166
int
m4ri_opt_k(
int
a,
int
b,
int
c);
167
168
#endif // M4RI_GRAYFLEX_H
Generated on Sat Aug 3 2013 09:38:14 for M4RI by
1.8.4