pub struct Carrier {
pub numerology: Numerology,
pub n_subcarriers: usize,
pub n_fft: usize,
pub first_symbol: usize,
}Expand description
An NR carrier: a grid of n_subcarriers $K$ subcarriers of the numerology
numerology, at the FFT size n_fft, whose first OFDM symbol is the symbol
first_symbol of a subframe (see the module).
Every symbol is the block of Ofdm::to_time of $K$ subcarriers out of
$N_{\mathrm{FFT}}$ without oversampling, scaled by $1/\sqrt{K}$ (a grid of unit-energy
symbols gives a unit mean power), and takes the prefix of its position in the
subframe.
§Examples
use comnum_waveform::ofdm::nr::{Carrier, Numerology};
use comnum_math::C64;
let carrier = Carrier { numerology: Numerology::new(1, false)?, n_subcarriers: 48, n_fft: 128, first_symbol: 0 };
let grid: Vec<C64> = (0..3 * 48).map(|i| C64::new((i % 3) as f64 - 1.0, 1.0)).collect();
let x = carrier.modulate(&grid)?;
assert_eq!(x.len(), 3 * 128 + 11 + 9 + 9); // (144 + 32)/16, then 144/16
assert!(carrier.demodulate(&x)?.iter().zip(&grid).all(|(a, b)| (a - b).norm() < 1e-12));Fields§
§numerology: NumerologyThe numerology.
n_subcarriers: usizeSubcarriers $K$ of the grid (even, at most $N_{\mathrm{FFT}}$).
n_fft: usizeFFT size $N_{\mathrm{FFT}}$ (a multiple of 128).
first_symbol: usizeThe position in the subframe of the first OFDM symbol of the grid.
Implementations§
Source§impl Carrier
impl Carrier
Sourcepub fn check(&self) -> Result<()>
pub fn check(&self) -> Result<()>
Validate the carrier.
§Errors
comnum_core::Error::Config for an odd or too large $K$, or an FFT size that
Numerology::cp_lengths refuses.
Sourcepub fn modulate(&self, grid: &[C64]) -> Result<Vec<C64>>
pub fn modulate(&self, grid: &[C64]) -> Result<Vec<C64>>
OFDM-modulate the symbols of a grid (grid[l * K + i] for subcarrier i of symbol
l), every one with the prefix of its position in the subframe.
§Errors
The errors of Carrier::check; comnum_core::Error::Shape for a grid that is
not a whole number of symbols.
Sourcepub fn demodulate(&self, samples: &[C64]) -> Result<Vec<C64>>
pub fn demodulate(&self, samples: &[C64]) -> Result<Vec<C64>>
The grid of the samples of whole OFDM symbols, every prefix of its position in the
subframe removed: the inverse of Carrier::modulate.
§Errors
The errors of Carrier::check; comnum_core::Error::Shape if the samples do not
end with a whole symbol.
Sourcepub fn sample_rate(&self) -> f64
pub fn sample_rate(&self) -> f64
The sampling rate $N_{\mathrm{FFT}}\Delta f$ of the carrier (Hz).