Skip to main content

Carrier

Struct Carrier 

Source
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: Numerology

The numerology.

§n_subcarriers: usize

Subcarriers $K$ of the grid (even, at most $N_{\mathrm{FFT}}$).

§n_fft: usize

FFT size $N_{\mathrm{FFT}}$ (a multiple of 128).

§first_symbol: usize

The position in the subframe of the first OFDM symbol of the grid.

Implementations§

Source§

impl Carrier

Source

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.

Source

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.

Source

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.

Source

pub fn sample_rate(&self) -> f64

The sampling rate $N_{\mathrm{FFT}}\Delta f$ of the carrier (Hz).

Trait Implementations§

Source§

impl Clone for Carrier

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Carrier

Source§

impl Debug for Carrier

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Carrier

Source§

impl PartialEq for Carrier

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Carrier

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.