SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Public Types | Public Member Functions | Static Public Attributes | Private Attributes | List of all members
leansdr::gf2n< Te, N, ALPHA, TRUNCP > Struct Template Reference

#include <discrmath.h>

Public Types

typedef Te element
 

Public Member Functions

 gf2n ()
 
Te add (Te x, Te y)
 
Te sub (Te x, Te y)
 
Te mul (Te x, Te y)
 
Te div (Te x, Te y)
 
Te inv (Te x)
 
Te exp (Te x)
 
Te log (Te x)
 

Static Public Attributes

static const Te alpha = ALPHA
 

Private Attributes

Te lut_exp [(1<< N) *2]
 
Te lut_log [1<< N]
 

Detailed Description

template<typename Te, int N, Te ALPHA, Te TRUNCP>
struct leansdr::gf2n< Te, N, ALPHA, TRUNCP >

Definition at line 218 of file discrmath.h.

Member Typedef Documentation

◆ element

template<typename Te, int N, Te ALPHA, Te TRUNCP>
typedef Te leansdr::gf2n< Te, N, ALPHA, TRUNCP >::element

Definition at line 220 of file discrmath.h.

Constructor & Destructor Documentation

◆ gf2n()

template<typename Te, int N, Te ALPHA, Te TRUNCP>
leansdr::gf2n< Te, N, ALPHA, TRUNCP >::gf2n ( )
inline

Definition at line 222 of file discrmath.h.

223  {
224  if (ALPHA != 2)
225  fail("alpha!=2 not implemented");
226  // Precompute log and exp tables.
227  Te alpha_i = 1; // ALPHA^0
228  for (int i = 0; i < (1 << N); ++i)
229  {
230  lut_exp[i] = alpha_i; // ALPHA^i
231  lut_exp[((1 << N) - 1) + i] = alpha_i; // Wrap to avoid modulo 2^N-1
232  lut_log[alpha_i] = i;
233  bool overflow = alpha_i & (1 << (N - 1));
234  alpha_i <<= 1; // Multiply by alpha=[X] i.e. increase degrees
235  alpha_i &= ~((~(Te)0) << N); // In case Te is wider than N bits
236  if (overflow)
237  alpha_i ^= TRUNCP; // Modulo P iteratively
238  }
239  }
Te lut_exp[(1<< N) *2]
Definition: discrmath.h:262
void fail(const char *s)
Definition: framework.cpp:11
int32_t i
Definition: decimators.h:244
Te lut_log[1<< N]
Definition: discrmath.h:263

Member Function Documentation

◆ add()

template<typename Te, int N, Te ALPHA, Te TRUNCP>
Te leansdr::gf2n< Te, N, ALPHA, TRUNCP >::add ( Te  x,
Te  y 
)
inline

Definition at line 240 of file discrmath.h.

240 { return x ^ y; } // Addition modulo 2

◆ div()

template<typename Te, int N, Te ALPHA, Te TRUNCP>
Te leansdr::gf2n< Te, N, ALPHA, TRUNCP >::div ( Te  x,
Te  y 
)
inline

Definition at line 248 of file discrmath.h.

249  {
250  if (!x)
251  return 0;
252  return lut_exp[lut_log[x] + ((1 << N) - 1) - lut_log[y]];
253  }
Te lut_exp[(1<< N) *2]
Definition: discrmath.h:262
Te lut_log[1<< N]
Definition: discrmath.h:263

◆ exp()

template<typename Te, int N, Te ALPHA, Te TRUNCP>
Te leansdr::gf2n< Te, N, ALPHA, TRUNCP >::exp ( Te  x)
inline

Definition at line 258 of file discrmath.h.

258 { return lut_exp[x]; }
Te lut_exp[(1<< N) *2]
Definition: discrmath.h:262

◆ inv()

template<typename Te, int N, Te ALPHA, Te TRUNCP>
Te leansdr::gf2n< Te, N, ALPHA, TRUNCP >::inv ( Te  x)
inline

Definition at line 254 of file discrmath.h.

255  {
256  return lut_exp[((1 << N) - 1) - lut_log[x]];
257  }
Te lut_exp[(1<< N) *2]
Definition: discrmath.h:262
Te lut_log[1<< N]
Definition: discrmath.h:263

◆ log()

template<typename Te, int N, Te ALPHA, Te TRUNCP>
Te leansdr::gf2n< Te, N, ALPHA, TRUNCP >::log ( Te  x)
inline

Definition at line 259 of file discrmath.h.

259 { return lut_log[x]; }
Te lut_log[1<< N]
Definition: discrmath.h:263

◆ mul()

template<typename Te, int N, Te ALPHA, Te TRUNCP>
Te leansdr::gf2n< Te, N, ALPHA, TRUNCP >::mul ( Te  x,
Te  y 
)
inline

Definition at line 242 of file discrmath.h.

243  {
244  if (!x || !y)
245  return 0;
246  return lut_exp[lut_log[x] + lut_log[y]];
247  }
Te lut_exp[(1<< N) *2]
Definition: discrmath.h:262
Te lut_log[1<< N]
Definition: discrmath.h:263

◆ sub()

template<typename Te, int N, Te ALPHA, Te TRUNCP>
Te leansdr::gf2n< Te, N, ALPHA, TRUNCP >::sub ( Te  x,
Te  y 
)
inline

Definition at line 241 of file discrmath.h.

241 { return x ^ y; } // Subtraction modulo 2

Member Data Documentation

◆ alpha

template<typename Te, int N, Te ALPHA, Te TRUNCP>
const Te leansdr::gf2n< Te, N, ALPHA, TRUNCP >::alpha = ALPHA
static

Definition at line 221 of file discrmath.h.

◆ lut_exp

template<typename Te, int N, Te ALPHA, Te TRUNCP>
Te leansdr::gf2n< Te, N, ALPHA, TRUNCP >::lut_exp[(1<< N) *2]
private

Definition at line 262 of file discrmath.h.

◆ lut_log

template<typename Te, int N, Te ALPHA, Te TRUNCP>
Te leansdr::gf2n< Te, N, ALPHA, TRUNCP >::lut_log[1<< N]
private

Definition at line 263 of file discrmath.h.


The documentation for this struct was generated from the following file: