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.
plugins
channelrx
demoddatv
leansdr
math.cpp
Go to the documentation of this file.
1
#include "
math.h
"
2
3
namespace
leansdr
4
{
5
6
int
hamming_weight
(
uint8_t
x)
7
{
8
static
const
int
lut[16] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4};
9
return
lut[x & 15] + lut[x >> 4];
10
}
11
12
int
hamming_weight
(
uint16_t
x)
13
{
14
return
hamming_weight
((
uint8_t
)x) +
hamming_weight
((
uint8_t
)(x >> 8));
15
}
16
17
int
hamming_weight
(
uint32_t
x)
18
{
19
return
hamming_weight
((
uint16_t
)x) +
hamming_weight
((
uint16_t
)(x >> 16));
20
}
21
22
int
hamming_weight
(
uint64_t
x)
23
{
24
return
hamming_weight
((
uint32_t
)x) +
hamming_weight
((
uint32_t
)(x >> 32));
25
}
26
27
unsigned
char
parity
(
uint8_t
x)
28
{
29
x ^= x >> 4;
30
return
(0x6996 >> (x & 15)) & 1;
// 16-entry look-up table
31
}
32
33
unsigned
char
parity
(
uint16_t
x)
34
{
35
return
parity
((
uint8_t
)(x ^ (x >> 8)));
36
}
37
38
unsigned
char
parity
(
uint32_t
x)
39
{
40
return
parity
((
uint16_t
)(x ^ (x >> 16)));
41
}
42
43
unsigned
char
parity
(
uint64_t
x)
44
{
45
return
parity
((
uint32_t
)(x ^ (x >> 32)));
46
}
47
48
int
log2i
(
uint64_t
x)
49
{
50
int
n = -1;
51
for
(; x; ++n, x >>= 1)
52
;
53
return
n;
54
}
55
56
}
// leansdr
math.h
leansdr::log2i
int log2i(uint64_t x)
Definition:
math.cpp:48
leansdr::hamming_weight
int hamming_weight(uint8_t x)
Definition:
math.cpp:6
uint32_t
unsigned int uint32_t
Definition:
rtptypes_win.h:46
uint8_t
unsigned char uint8_t
Definition:
rtptypes_win.h:42
uint16_t
unsigned short uint16_t
Definition:
rtptypes_win.h:44
leansdr
Definition:
datvconstellation.h:28
leansdr::parity
unsigned char parity(uint8_t x)
Definition:
math.cpp:27
uint64_t
unsigned __int64 uint64_t
Definition:
rtptypes_win.h:48
Generated on Fri Aug 2 2019 17:56:30 for SDRAngel by
1.8.13