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 Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | List of all members
leansdr::bitvect< T, N > Struct Template Reference

#include <discrmath.h>

Public Member Functions

 bitvect ()
 
 bitvect (T val)
 
template<int M>
bitvect< T, N > & copy (const bitvect< T, M > &a)
 
bool operator[] (unsigned int i) const
 
template<int M>
bitvect< T, N > & operator+= (const bitvect< T, M > &a)
 
bitvect< T, N > & operator<<= (unsigned int n)
 

Public Attributes

v [NW]
 

Static Public Attributes

static const size_t WSIZE = sizeof(T) * 8
 
static const size_t NW = (N + WSIZE - 1) / WSIZE
 

Private Member Functions

void truncate_to_N ()
 

Detailed Description

template<typename T, int N>
struct leansdr::bitvect< T, N >

Definition at line 33 of file discrmath.h.

Constructor & Destructor Documentation

◆ bitvect() [1/2]

template<typename T, int N>
leansdr::bitvect< T, N >::bitvect ( )
inline

Definition at line 39 of file discrmath.h.

39 {}

◆ bitvect() [2/2]

template<typename T, int N>
leansdr::bitvect< T, N >::bitvect ( val)
inline

Definition at line 40 of file discrmath.h.

41  {
42  v[0] = val;
43  for (int i = 1; i < NW; ++i)
44  v[i] = 0;
45  }
static const size_t NW
Definition: discrmath.h:36
int32_t i
Definition: decimators.h:244

Member Function Documentation

◆ copy()

template<typename T, int N>
template<int M>
bitvect<T, N>& leansdr::bitvect< T, N >::copy ( const bitvect< T, M > &  a)
inline

Definition at line 49 of file discrmath.h.

50  {
51  int nw = (a.NW < NW) ? a.NW : NW;
52  for (int i = 0; i < nw; ++i)
53  v[i] = a.v[i];
54  if (M < N)
55  for (int i = a.NW; i < NW; ++i)
56  v[i] = 0;
57  if (M > N)
58  truncate_to_N();
59  return *this;
60  }
void truncate_to_N()
Definition: discrmath.h:97
static const size_t NW
Definition: discrmath.h:36
int32_t i
Definition: decimators.h:244

◆ operator+=()

template<typename T, int N>
template<int M>
bitvect<T, N>& leansdr::bitvect< T, N >::operator+= ( const bitvect< T, M > &  a)
inline

Definition at line 70 of file discrmath.h.

71  {
72  int nw = (a.NW < NW) ? a.NW : NW;
73  for (int i = 0; i < nw; ++i)
74  v[i] ^= a.v[i];
75  if (M > N)
76  truncate_to_N();
77  return *this;
78  }
void truncate_to_N()
Definition: discrmath.h:97
static const size_t NW
Definition: discrmath.h:36
int32_t i
Definition: decimators.h:244

◆ operator<<=()

template<typename T, int N>
bitvect<T, N>& leansdr::bitvect< T, N >::operator<<= ( unsigned int  n)
inline

Definition at line 82 of file discrmath.h.

83  {
84  if (n >= WSIZE)
85  fail("shift exceeds word width");
86  T mask = ~(((T)-1) << n);
87  for (int i = NW - 1; i > 0; --i)
88  v[i] = (v[i] << n) | ((v[i - 1] >> (WSIZE - n)) & mask);
89  v[0] <<= n;
90  if (N != NW * WSIZE)
91  truncate_to_N();
92  return *this;
93  }
void truncate_to_N()
Definition: discrmath.h:97
static const size_t WSIZE
Definition: discrmath.h:35
void fail(const char *s)
Definition: framework.cpp:11
static const size_t NW
Definition: discrmath.h:36
int32_t i
Definition: decimators.h:244

◆ operator[]()

template<typename T, int N>
bool leansdr::bitvect< T, N >::operator[] ( unsigned int  i) const
inline

Definition at line 62 of file discrmath.h.

63  {
64  return v[i / WSIZE] & ((T)1 << (i & (WSIZE - 1)));
65  }
static const size_t WSIZE
Definition: discrmath.h:35
int32_t i
Definition: decimators.h:244

◆ truncate_to_N()

template<typename T, int N>
void leansdr::bitvect< T, N >::truncate_to_N ( )
inlineprivate

Definition at line 97 of file discrmath.h.

Referenced by leansdr::bitvect< T, DP >::copy(), leansdr::bitvect< T, DP >::operator+=(), and leansdr::bitvect< T, DP >::operator<<=().

98  {
99  v[NW - 1] &= ((T)-1) >> (NW * WSIZE - N);
100  }
static const size_t WSIZE
Definition: discrmath.h:35
static const size_t NW
Definition: discrmath.h:36
+ Here is the caller graph for this function:

Member Data Documentation

◆ NW

template<typename T, int N>
const size_t leansdr::bitvect< T, N >::NW = (N + WSIZE - 1) / WSIZE
static

◆ v

template<typename T, int N>
T leansdr::bitvect< T, N >::v[NW]

◆ WSIZE

template<typename T, int N>
const size_t leansdr::bitvect< T, N >::WSIZE = sizeof(T) * 8
static

Definition at line 35 of file discrmath.h.

Referenced by leansdr::bitvect< T, DP >::operator[]().


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