BitPunch McEliece  v0.0.4
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gf2types.h
Go to the documentation of this file.
1 /*
2 This file is part of BitPunch
3 Copyright (C) 2014-2015 Frantisek Uhrecky <frantisek.uhrecky[what here]gmail.com>
4 
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef BPUT_GF2TYPES_H
19 #define BPUT_GF2TYPES_H
20 
21 #include <stdint.h>
22 
26 typedef uint32_t BPU_T_GF2;
27 
32 typedef struct _BPU_T_GF2_Vector {
34  uint8_t element_bit_size;
35  uint16_t elements_in_row;
36  uint32_t len;
38 
43 typedef struct _BPU_T_GF2_Matrix {
45  uint8_t element_bit_size;
46  uint16_t elements_in_row;
47  uint32_t k;
48  uint32_t n;
50 
56 
62 typedef struct _BPU_T_GF2_Sparse_Poly {
63  uint32_t *index;
64  uint32_t weight;
66 
74 typedef struct _BPU_T_GF2_QC_Matrix {
76  uint16_t element_count;
77  uint32_t element_size;
78  uint8_t isVertical;
79  uint32_t n;
80  uint32_t k;
81  uint8_t is_I_appended;
83 
92  uint16_t element_count;
93  uint32_t element_size;
94  uint8_t isVertical;
95  uint32_t n;
96  uint32_t k;
98 
104 #define BPU_gf2MatNullRow(m_pointer, row) memset((void *) ((m_pointer)->elements[row]), 0, (m_pointer)->element_bit_size / 8 * (m_pointer)->elements_in_row)
106 
111 #define BPU_gf2VecNull(v_pointer) memset((void *) ((v_pointer)->elements), 0, (v_pointer)->element_bit_size / 8 * (v_pointer)->elements_in_row)
113 
120 
127 
134 int BPU_gf2MatMalloc(BPU_T_GF2_Matrix **m, int rows, int cols);
135 
141 int BPU_gf2VecMalloc(BPU_T_GF2_Vector **v, int len);
142 
149 int BPU_gf2VecResize(BPU_T_GF2_Vector *v, int len);
150 
158 
159 
160 /**********************************************************
161 gf2 POLY
162 **********************************************************/
163 
170 int BPU_gf2PolyMalloc(BPU_T_GF2_Poly *p, int len);
171 
177 void BPU_gf2PolyFree(BPU_T_GF2_Poly *p, int is_dyn);
178 
179 
180 /**********************************************************
181 gf2 SPARSE POLY
182 **********************************************************/
183 
190 
196 void BPU_gf2SparsePolyFree(BPU_T_GF2_Sparse_Poly *p, int is_dyn);
197 
198 
199 /**********************************************************
200 gf2 QUASI-CYCLIC MATRIX
201 **********************************************************/
202 
212 int BPU_gf2QcMatrixMalloc(BPU_T_GF2_QC_Matrix *v, int element_count, int element_size, int isVertical, int is_I_appended);
213 
219 void BPU_gf2QcMatrixFree(BPU_T_GF2_QC_Matrix *v, int is_dyn);
220 
221 
222 /**********************************************************
223 gf2 SPARSE QUASI-CYCLIC MATRIX
224 **********************************************************/
225 
233 void BPU_gf2SparseQcMatrixMalloc(BPU_T_GF2_Sparse_Qc_Matrix *v, int element_count, int element_size, int isVertical);
234 
235 
242 
243 #endif // BPUT_GF2TYPES_H
void BPU_gf2VecFree(BPU_T_GF2_Vector **v)
Free dynamically or statically allocated vector.
Definition: gf2types.c:45
uint32_t weight
weight of polynomial
Definition: gf2types.h:64
BPU_T_GF2_Sparse_Poly * matrices
all cyclic matrices of matrix
Definition: gf2types.h:91
uint8_t isVertical
if 1, elements are in vertical orientation, if 0 horizontal orientation
Definition: gf2types.h:94
uint32_t k
rows of whole matrix
Definition: gf2types.h:80
uint16_t element_count
number of cyclic matrices
Definition: gf2types.h:92
uint16_t elements_in_row
number of elements in one row
Definition: gf2types.h:46
struct _BPU_T_GF2_Sparse_Qc_Matrix BPU_T_GF2_Sparse_Qc_Matrix
uint32_t element_size
size of cyclic matrix
Definition: gf2types.h:77
uint8_t is_I_appended
if matrix has identity matrix on left
Definition: gf2types.h:81
uint32_t * index
indexes of set coefficients. 0 is coefficient for x^0
Definition: gf2types.h:63
uint32_t k
rows
Definition: gf2types.h:47
void BPU_gf2MatFree(BPU_T_GF2_Matrix **m)
Free dynamically or statically allocated matrix.
Definition: gf2types.c:29
BPU_T_GF2_Vector BPU_T_GF2_Poly
Definition: gf2types.h:55
uint32_t k
rows of whole matrix
Definition: gf2types.h:96
int BPU_gf2VecMallocElements(BPU_T_GF2_Vector *v, int len)
BPU_gf2VecMallocElements Malloc vector elements and set to zero.
Definition: gf2types.c:114
uint32_t BPU_T_GF2
Definition: gf2types.h:26
uint32_t n
cols of whole matrix
Definition: gf2types.h:79
uint8_t element_bit_size
element size, is sizeof(BPU_T_GF2) i.e. 64 bits
Definition: gf2types.h:45
uint32_t element_size
size of cyclic matrix
Definition: gf2types.h:93
BPU_T_GF2 * elements
all element of matrix
Definition: gf2types.h:33
void BPU_gf2PolyFree(BPU_T_GF2_Poly *p, int is_dyn)
Definition: gf2types.c:187
void BPU_gf2QcMatrixFree(BPU_T_GF2_QC_Matrix *v, int is_dyn)
Definition: gf2types.c:251
struct _BPU_T_GF2_QC_Matrix BPU_T_GF2_QC_Matrix
uint16_t element_count
number of cyclic matrices
Definition: gf2types.h:76
struct _BPU_T_GF2_Sparse_Poly BPU_T_GF2_Sparse_Poly
uint16_t elements_in_row
number of elements in one row
Definition: gf2types.h:35
void BPU_gf2SparseQcMatrixFree(BPU_T_GF2_Sparse_Qc_Matrix *v, int is_dyn)
Definition: gf2types.c:174
struct _BPU_T_GF2_Vector BPU_T_GF2_Vector
uint32_t n
cols
Definition: gf2types.h:48
int BPU_gf2PolyMalloc(BPU_T_GF2_Poly *p, int len)
Definition: gf2types.c:195
void BPU_gf2SparsePolyFree(BPU_T_GF2_Sparse_Poly *p, int is_dyn)
Definition: gf2types.c:147
int BPU_gf2MatMalloc(BPU_T_GF2_Matrix **m, int rows, int cols)
Definition: gf2types.c:54
uint32_t len
cols
Definition: gf2types.h:36
struct _BPU_T_GF2_Matrix BPU_T_GF2_Matrix
BPU_T_GF2_Poly * matrices
all cyclic matrices of matrix
Definition: gf2types.h:75
void BPU_gf2SparseQcMatrixMalloc(BPU_T_GF2_Sparse_Qc_Matrix *v, int element_count, int element_size, int isVertical)
Definition: gf2types.c:154
int BPU_gf2VecResize(BPU_T_GF2_Vector *v, int len)
BPU_gf2VecResize Resize vecor.
Definition: gf2types.c:107
uint8_t element_bit_size
element size, is sizeof(BPU_T_GF2) i.e. 64 bits
Definition: gf2types.h:34
uint8_t isVertical
if 1, elements are in vertical orientation, if 0 horizontal orientation
Definition: gf2types.h:78
int BPU_gf2QcMatrixMalloc(BPU_T_GF2_QC_Matrix *v, int element_count, int element_size, int isVertical, int is_I_appended)
Definition: gf2types.c:220
void BPU_gf2SparsePolyMalloc(BPU_T_GF2_Sparse_Poly *p, int weight)
Definition: gf2types.c:140
uint32_t n
cols of whole matrix
Definition: gf2types.h:95
BPU_T_GF2 ** elements
all element of matrix
Definition: gf2types.h:44
int BPU_gf2VecMalloc(BPU_T_GF2_Vector **v, int len)
Definition: gf2types.c:97