nk 1.0.0
C++ Numerical Computing Runtime
Loading...
Searching...
No Matches
channel.hpp
Go to the documentation of this file.
1
3// toolboxes/comm/include/nk/comm/channel/channel.hpp
4//
5// AWGN / WGN / BSC channel models, Q-functions, analytical BER, and
6// SNR conversions.
7
8#pragma once
9
10#include <memory_resource>
11#include <nk/value/value.hpp>
12
13#include <string>
14#include <tuple>
15
16namespace nk {
17
20 namespace ops { class RngContext; } }
21
22namespace nk::comm {
23
37Value awgn(::nk::ops::RngContext &rng, const Value &x, double snr_db, double sigpower_db,
38 std::pmr::memory_resource *mr = nullptr);
39
51Value wgn(::nk::ops::RngContext &rng, int m, int n, double p, const std::string &type,
52 bool complex_out,
53 std::pmr::memory_resource *mr = nullptr);
54
63Value bsc(::nk::ops::RngContext &rng, const Value &x, double p,
64 std::pmr::memory_resource *mr = nullptr);
65
72Value qfunc(const Value &x, std::pmr::memory_resource *mr = nullptr);
73
81 std::pmr::memory_resource *mr = nullptr);
82
94Value marcumq(const Value &a, const Value &b, int m,
95 std::pmr::memory_resource *mr = nullptr);
96
106Value berawgn(const Value &EbNo_dB, const std::string &mod, int M,
107 std::pmr::memory_resource *mr = nullptr);
108
118Value noisebw(const Value &num, const Value &den, int Nsamp,
119 double fs,
120 std::pmr::memory_resource *mr = nullptr);
121
131std::tuple<Value, Value>
132berconfint(double numErrs, double numBits, double level,
133 std::pmr::memory_resource *mr = nullptr);
134
149Value convertSNR(const Value &snr_in,
150 const std::string &in_type,
151 const std::string &out_type,
152 int bits_per_symbol,
153 std::pmr::memory_resource *mr = nullptr);
154
155
157} // namespace nk::comm
Core MATLAB-compatible multidimensional array and scalar value type.
Definition value.hpp:61
Value convertSNR(const Value &snr_in, const std::string &in_type, const std::string &out_type, int bits_per_symbol, std::pmr::memory_resource *mr=nullptr)
Convert between Eb/No, Es/No, and SNR (snr_out = convertSNR(snr_in, in_type, out_type,...
Value bsc(::nk::ops::RngContext &rng, const Value &x, double p, std::pmr::memory_resource *mr=nullptr)
Binary symmetric channel — flip each bit with probability p (y = bsc(x, p)).
Value noisebw(const Value &num, const Value &den, int Nsamp, double fs, std::pmr::memory_resource *mr=nullptr)
Equivalent noise bandwidth of an LTI filter (bw = noisebw(num, den, Nsamp, fs)).
Value qfuncinv(const Value &p, std::pmr::memory_resource *mr=nullptr)
Inverse Q-function: Q⁻¹(p) = √2·erfc⁻¹(2p).
Value wgn(::nk::ops::RngContext &rng, int m, int n, double p, const std::string &type, bool complex_out, std::pmr::memory_resource *mr=nullptr)
Generate an m×n matrix of white Gaussian noise samples (y = wgn(m, n, p, type, complex)).
Value qfunc(const Value &x, std::pmr::memory_resource *mr=nullptr)
Gaussian Q-function: Q(x) = 0.5·erfc(x/√2).
Value berawgn(const Value &EbNo_dB, const std::string &mod, int M, std::pmr::memory_resource *mr=nullptr)
Analytical bit-error rate over AWGN (ber = berawgn(EbNo_dB, mod, M)).
Value awgn(::nk::ops::RngContext &rng, const Value &x, double snr_db, double sigpower_db, std::pmr::memory_resource *mr=nullptr)
Add white Gaussian noise so the resulting SNR is snr_db dB (y = awgn(x, snr_db, sigpower_db)).
std::tuple< Value, Value > berconfint(double numErrs, double numBits, double level, std::pmr::memory_resource *mr=nullptr)
Clopper–Pearson exact binomial confidence interval for a measured BER ([ber, ci] = berconfint(numErrs...
Value marcumq(const Value &a, const Value &b, int m, std::pmr::memory_resource *mr=nullptr)
Generalised Marcum Q-function (q = marcumq(a, b, m)).