-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
39 lines (30 loc) · 1.29 KB
/
main.cpp
File metadata and controls
39 lines (30 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "header.h"
#define DEBUG false
int main()
{
const std::vector<double> snt_db_list{0, 1, 5, 10, 15, 20};
const int NUM_BITS = 30000;
const int NUM_LOOPS = 10;
for (auto snr_db : snt_db_list)
{
double ber = 0;
std::cout << "SNR_DB: " << snr_db << std::endl;
for (int i = 0; i < NUM_LOOPS; i++)
{
std::vector<int> original_bits = generate_bits(2 * NUM_BITS);
if (DEBUG) print_vector("Original bits", original_bits);
std::vector<std::complex<double>> symbols = bpsk_modulate(original_bits);
auto h_mimo = generate_channel_matrix();
std::vector<std::complex<double>> Y = mimo_channel(symbols, h_mimo, snr_db);
if (DEBUG) print_vector("MIMO channel", Y);
auto X_restored = zf_demodulate(Y, h_mimo);
if (DEBUG) print_vector("X_restored", X_restored);
std::vector<int> received_bits = bpsk_demodulate(X_restored);
if (DEBUG) print_vector("Received bits", received_bits);
ber += calculate_ber(original_bits, received_bits);
}
std::cout << "BER: " << ber / NUM_LOOPS << std::endl;
std::cout << "theoreticalBER_SISO: " << theoreticalBER_SISO(snr_db) << std::endl;
std::cout << std::endl;
}
}