51 lines
1.5 KiB
Plaintext
51 lines
1.5 KiB
Plaintext
#ifndef GF2_HEADER_CUH
|
|
#define GF2_HEADER_CUH
|
|
|
|
#include "../header.cuh"
|
|
|
|
namespace gf2
|
|
{
|
|
static const size_t gf2_num = base_len;
|
|
static const size_t gf2_len = 1;
|
|
|
|
static const size_t gf2_table_num = 8;
|
|
static const size_t gf2_table_len = 8;
|
|
static const size_t gf2_table_mask = 0xFF;
|
|
|
|
__host__ inline void del(base_t &dst, size_t idx)
|
|
{
|
|
dst &= ~(base_one << idx);
|
|
}
|
|
__host__ inline void set(base_t &dst, size_t idx)
|
|
{
|
|
dst |= base_one << idx;
|
|
}
|
|
__host__ inline base_t concat(base_t dst_l, size_t idx_l, base_t dst_r)
|
|
{
|
|
if (idx_l == 0)
|
|
{
|
|
return dst_r;
|
|
}
|
|
if (idx_l == gf2_num)
|
|
{
|
|
return dst_l;
|
|
}
|
|
return (dst_l & (base_fullmask >> (base_len - idx_l))) | (dst_r & (base_fullmask << idx_l));
|
|
}
|
|
__host__ __device__ inline base_t get(base_t src, size_t idx)
|
|
{
|
|
return (src >> idx) & base_one;
|
|
}
|
|
|
|
__host__ inline base_t rev(base_t n)
|
|
{
|
|
n = (n & (base_t)0xAA'AA'AA'AA'AA'AA'AA'AA) >> 1 | (n & (base_t)0x55'55'55'55'55'55'55'55) << 1;
|
|
n = (n & (base_t)0xCC'CC'CC'CC'CC'CC'CC'CC) >> 2 | (n & (base_t)0x33'33'33'33'33'33'33'33) << 2;
|
|
n = (n & (base_t)0xF0'F0'F0'F0'F0'F0'F0'F0) >> 4 | (n & (base_t)0x0F'0F'0F'0F'0F'0F'0F'0F) << 4;
|
|
n = (n & (base_t)0xFF'00'FF'00'FF'00'FF'00) >> 8 | (n & (base_t)0x00'FF'00'FF'00'FF'00'FF) << 8;
|
|
n = (n & (base_t)0xFF'FF'00'00'FF'FF'00'00) >> 16 | (n & (base_t)0x00'00'FF'FF'00'00'FF'FF) << 16;
|
|
return n >> 32 | n << 32;
|
|
}
|
|
|
|
}
|
|
#endif |