1 /*
2  * minimum-weight-gf3.h
3  *
4  * Minimum Hamming weight computation for codes over GF(3)
5  *
6  * Version Log:
7  *   0.1  18 March 2008 (first released to public -- GUAVA 3.3)
8  *
9  * CJ, Tjhai
10  * email: ctjhai@plymouth.ac.uk
11  * Homepage: www.plymouth.ac.uk/staff/ctjhai
12  *
13  */
14 
15 #ifndef _MINIMUM_WEIGHT_GF3_H
16 #define _MINIMUM_WEIGHT_GF3_H
17 
18 #include "types.h"
19 
20 #define subtract_gf3(gf,a,b)	gf->sub[a][b]
21 #define divide_gf3(gf,a,b)		gf->div[a][b]
22 /*
23  * c = a + b
24  * add_gf3_vec requires a declaration of "packed_t t1, t2"
25  *
26  */
27 #define add_gf3_vec(a, b, c)	{   t1   = (a.v1 | b.v2)^(a.v2 | b.v1);\
28 									t2   = (a.v2 | b.v2) ^ t1;\
29 									c.v2 = (a.v1 | b.v1) ^ t1;\
30 									c.v1 = t2;\
31 								}
32 /*
33  * c = a - b
34  *   = a + -b
35  *   = a + 2b
36  * sub_gf3_vec requires a declaration of "packed_t t1, t2"
37  *
38  */
39 #define sub_gf3_vec(a, b, c)	{   t1   = (a.v1 | b.v1)^(a.v2 | b.v2);\
40 									t2   = (a.v2 | b.v1) ^ t1;\
41 									c.v2 = (a.v1 | b.v2) ^ t1;\
42 									c.v1 = t2;\
43 								}
44 
45 
46 /*------------- Data structure specified for GF(3) --------------*/
47 typedef struct {
48 	short **sub, **div;
49 } GF3;
50 
51 typedef struct {
52 	packed_t v1, v2;
53 } GF3_VEC;
54 
55 typedef struct {
56 	unsigned short dimension, block_length;
57 	unsigned short nBlocks;
58 	unsigned short nMatrices, nFullRankMatrices;
59 	unsigned short *rank;
60 	GF3_VEC  ***mat;
61 } PACKED_MATRIX_GF3;
62 
63 /*-------------------- Function prototypes ----------------------*/
64 int  mindist_gf3(MATRIX G, mod_t m_mod, int lower_bound);
65 int  cyclic_mindist_gf3(MATRIX G, mod_t m_mod, int lower_bound);
66 
67 #endif
68