165 #endif // BPU_CONF_PRINT
172 #define BPU_getBit(w, n) ((int)((((uint32_t)w) >> (n)) & 1u))
182 #define BPU_gf2MatGetBit(m_pointer, s, t) (BPU_getBit((m_pointer)->elements[s][(t) / (m_pointer)->element_bit_size], (t) % (m_pointer)->element_bit_size))
191 #define BPU_gf2VecGetBit(v_pointer, i) (BPU_getBit((v_pointer)->elements[(i) / (v_pointer)->element_bit_size], (i) % (v_pointer)->element_bit_size))
201 #define BPU_gf2MatSetBit(m_pointer, s, t, bit) if (bit) { \
202 (m_pointer)->elements[s][t / (m_pointer)->element_bit_size] |= ((BPU_T_GF2) 1) << ((t) % (m_pointer)->element_bit_size);\
206 (m_pointer)->elements[s][(t) / (m_pointer)->element_bit_size] &= ((BPU_T_GF2) (0xFFFFFFFFu)) ^ (((BPU_T_GF2) 1) << ((t) % (m_pointer)->element_bit_size));\
215 #define BPU_gf2VecSetBit(v_pointer, i, bit) if (bit) { \
216 (v_pointer)->elements[(i) / (v_pointer)->element_bit_size] |= ((BPU_T_GF2) 1) << ((i) % (v_pointer)->element_bit_size);\
220 (v_pointer)->elements[(i) / (v_pointer)->element_bit_size] &= ((BPU_T_GF2) (0xFFFFFFFFu)) ^ (((BPU_T_GF2) 1) << ((i) % (v_pointer)->element_bit_size));\
229 #define BPU_gf2MatCopyRowToVec(v_pointer, m_pointer, row) memcpy((void *) ((v_pointer)->elements), (void *) ((m_pointer)->elements[row]), (v_pointer)->element_bit_size / 8 * (v_pointer)->elements_in_row)
238 #define BPU_gf2PolyGetBit(poly, bit) ((poly->elements[bit/poly->element_bit_size] >> (bit%poly->element_bit_size)) & 1ul)
void BPU_printBinaryMsb32Ln(uint32_t in)
Print number as binary string in big endian so msb is first printed.
void BPU_gf2SparsePolyCopy(BPU_T_GF2_Sparse_Poly *out, const BPU_T_GF2_Sparse_Poly *in)
void BPU_gf2PolyAdd(BPU_T_GF2_Poly *out, const BPU_T_GF2_Poly *in, int crop)
int BPU_gf2VecCmp(const BPU_T_GF2_Vector *v1, const BPU_T_GF2_Vector *v2)
BPU_gf2VecCmp Compare two vectors.
int BPU_gf2PolyGetHighestBitPos(BPU_T_GF2_Poly *a)
int BPU_gf2MatCopy(BPU_T_GF2_Matrix *out, const BPU_T_GF2_Matrix *in)
BPU_gf2MatCopyCreate copy of input matrix.
void BPU_gf2Swap(BPU_T_GF2 *a, BPU_T_GF2 *b)
void BPU_gf2PolyShiftRightOne(BPU_T_GF2_Poly *a)
void BPU_gf2PolyTransp(BPU_T_GF2_Poly *out, const BPU_T_GF2_Poly *in)
int BPU_gf2VecCrop(BPU_T_GF2_Vector *out, const BPU_T_GF2_Vector *in, const int start, const int length)
void BPU_printBinaryLsb(uint32_t in, int len)
Print number as binary string in little endian so lsb is first printed.
void BPU_printGf2Vec(const BPU_T_GF2_Vector *v)
void BPU_gf2VecCopy(BPU_T_GF2_Vector *dest, const BPU_T_GF2_Vector *src)
Copy VectorGF2.
int BPU_gf2MatCrop(BPU_T_GF2_Matrix *m, uint16_t width)
Crop matrix GF2 from left.
void BPU_printBinaryMsb(uint32_t in, int len)
Print number as binary string in big endian so msb is first printed.
int BPU_gf2PolyInv(BPU_T_GF2_Poly *out, const BPU_T_GF2_Poly *a, const BPU_T_GF2_Poly *mod)
int BPU_gf2MatFindRow(const BPU_T_GF2_Matrix *mat, int i, int start_index)
int BPU_gf2MatTransp(BPU_T_GF2_Matrix *out, const BPU_T_GF2_Matrix *in)
void BPU_printBinaryMsb32(uint32_t in)
Print number as binary string in big endian so msb is first printed.
void BPU_gf2PolyCopy(BPU_T_GF2_Poly *out, const BPU_T_GF2_Poly *in)
void BPU_gf2SparsePolyAdd(BPU_T_GF2_Poly *out, const BPU_T_GF2_Sparse_Poly *in)
void BPU_gf2QcMatrixTransp(BPU_T_GF2_QC_Matrix *out, const BPU_T_GF2_QC_Matrix *in)
void BPU_printGf2Mat(const BPU_T_GF2_Matrix *m)
void BPU_printBinaryLsb32(uint32_t in)
Print number as binary string in little endian so lsb is first printed.
void BPU_gf2PolyExtEuclidA(BPU_T_GF2_Poly *d, BPU_T_GF2_Poly *s, BPU_T_GF2_Poly *t, const BPU_T_GF2_Poly *a, const BPU_T_GF2_Poly *b, const BPU_T_GF2_Poly *m)
int BPU_gf2VecRand(BPU_T_GF2_Vector *out, int w)
void BPU_gf2PolyMulMod(const BPU_T_GF2_Poly *a, const BPU_T_GF2_Poly *b, BPU_T_GF2_Poly *c, const BPU_T_GF2_Poly *m, int crop)
int BPU_gf2MatPermute(BPU_T_GF2_Matrix *m, BPU_T_Perm_Vector *permutation)
void BPU_printGf2SparsePoly(const BPU_T_GF2_Sparse_Poly *v)
void BPU_gf2MatXorRows(BPU_T_GF2_Matrix *mat, int i, int j)
void BPU_gf2PolyMulX(BPU_T_GF2_Poly *a)
void BPU_gf2SparseQcMatrixGetRow(BPU_T_GF2_Sparse_Poly *p, const BPU_T_GF2_Sparse_Qc_Matrix *m, int row_num)
void BPU_printBinaryMsbLn(uint32_t in, int len)
Print number as binary string in big endian so msb is first printed.
int BPU_gf2MatGetRowAsGf2Vec(BPU_T_GF2_Vector *out, const BPU_T_GF2_Matrix *in, int row)
void BPU_gf2PolySetDeg(BPU_T_GF2_Poly *a, int deg)
int BPU_gf2MatFindCol(const BPU_T_GF2_Matrix *mat, int i, int start_index)
void BPU_printGf2QcMatrix(const BPU_T_GF2_QC_Matrix *v)
int BPU_gf2PolyInitRand(BPU_T_GF2_Poly *out, int l, int w, int set_deg)
void BPU_printGf2PolyForMatrix(const BPU_T_GF2_Poly *v)
int BPU_gf2VecMulMat(BPU_T_GF2_Vector *x, const BPU_T_GF2_Vector *v, const BPU_T_GF2_Matrix *b)
uint8_t BPU_getParity(BPU_T_GF2 dword)
BPU_getParity Get parity of word.
void BPU_gf2SparseQcMatrixTransp(BPU_T_GF2_Sparse_Qc_Matrix *out, const BPU_T_GF2_Sparse_Qc_Matrix *in)
int BPU_gf2SparsePolyAndHW(const BPU_T_GF2_Poly *a, const BPU_T_GF2_Sparse_Poly *b)
int BPU_gf2VecConcat(BPU_T_GF2_Vector *out, const BPU_T_GF2_Vector *vec1, const BPU_T_GF2_Vector *vec2)
Concats two vectors without allocation ouput.
void BPU_gf2PolyShiftLeft(BPU_T_GF2_Poly *a, int shift_count)
BPU_T_GF2 BPU_gf2VecGetMaskedBit(const BPU_T_GF2_Vector *vec, uint32_t bit)
int BPU_gf2MatMakeSystematic(BPU_T_GF2_Matrix *inout)
It brings Matrix GF2 into the systematic form -> with I on the left side.
void BPU_printGf2SparseQcMatrix(const BPU_T_GF2_Sparse_Qc_Matrix *v)
int BPU_gf2PolyIsZero(const BPU_T_GF2_Poly *a)
void BPU_gf2MatSwapRows(BPU_T_GF2_Matrix *mat, int i, int j)
BPU_T_GF2 BPU_gf2MatGetMaskedBit(const BPU_T_GF2_Matrix *m, uint32_t row, uint32_t bit)
int BPU_gf2VecXor(BPU_T_GF2_Vector *out, const BPU_T_GF2_Vector *in)
Xor two Vectors GF2 and store result in first vector.
int BPU_gf2VecPermute(BPU_T_GF2_Vector *vec, const BPU_T_Perm_Vector *permutation)
void BPU_printGf2Poly(const BPU_T_GF2_Poly *v)
void BPU_printBinaryLsbLn(uint32_t in, int len)
Print number as binary string in little endian so lsb is first printed.
void BPU_gf2PolyDiv(BPU_T_GF2_Poly *q, BPU_T_GF2_Poly *r, const BPU_T_GF2_Poly *a, const BPU_T_GF2_Poly *b)
void BPU_printBinary32LsbLn(uint32_t in)
Print number as binary string in little endian so lsb is first printed.
int BPU_gf2QcMatrixToSparse(BPU_T_GF2_Sparse_Qc_Matrix *out, const BPU_T_GF2_QC_Matrix *in, const int wi[])
void BPU_printGf2VecMsb(const BPU_T_GF2_Vector *v)
BPU_printGf2VecMsb Most significant bit is printed first.
void BPU_printGf2VecOnes(const BPU_T_GF2_Vector *vec)
BPU_printGf2VecOnes Print only ones.