pub struct ResourceGrid {
pub n_subcarriers: usize,
pub n_symbols: usize,
pub pattern: PilotPattern,
pub seed: u64,
}Expand description
A grid of n_subcarriers × n_symbols resource elements with pilots.
Fields§
§n_subcarriers: usizeSubcarriers $K$ (the active subcarriers of the OFDM modulator).
n_symbols: usizeOFDM symbols $L$ per grid.
pattern: PilotPatternThe pilot pattern.
seed: u64Seed of the pilot symbols.
Implementations§
Source§impl ResourceGrid
impl ResourceGrid
Sourcepub fn check(&self) -> Result<()>
pub fn check(&self) -> Result<()>
Validate the grid.
§Errors
Error::Config for an empty grid, a pilot period or spacing of zero, or a pilot
table of another size than the grid.
§Examples
use comnum_waveform::ofdm::grid::{PilotPattern, ResourceGrid};
let g = ResourceGrid { n_subcarriers: 12, n_symbols: 7, pattern: PilotPattern::Comb { spacing: 0 }, seed: 1 };
assert!(g.check().is_err() && g.map(&[]).is_err());Sourcepub fn from_table(table: PilotTable) -> ResourceGrid
pub fn from_table(table: PilotTable) -> ResourceGrid
The grid of a pilot table, of its size.
Sourcepub fn is_pilot(&self, k: usize, l: usize) -> bool
pub fn is_pilot(&self, k: usize, l: usize) -> bool
Whether RE $(k, l)$ carries a pilot (a spacing of zero, which
ResourceGrid::check refuses, is read as one).
Sourcepub fn port_pilots(&self, l: usize, port: usize, n_ports: usize) -> Vec<usize>
pub fn port_pilots(&self, l: usize, port: usize, n_ports: usize) -> Vec<usize>
The pilot subcarriers of symbol l that belong to port port out of n_ports:
the pilots of a symbol are dealt to the ports in turn (frequency-division
orthogonal pilots; the other ports are silent there).
Sourcepub fn map_port(
&self,
data: &[C64],
port: usize,
n_ports: usize,
) -> Result<Vec<C64>>
pub fn map_port( &self, data: &[C64], port: usize, n_ports: usize, ) -> Result<Vec<C64>>
The grid of port port out of n_ports: ResourceGrid::map with the pilots
of the other ports set to zero.
§Errors
Sourcepub fn pilot(&self, k: usize, l: usize) -> C64
pub fn pilot(&self, k: usize, l: usize) -> C64
The pilot symbol of RE $(k, l)$: the value of the table of an explicit pattern, unit-energy QPSK drawn from the seed otherwise.
Sourcepub fn pilot_positions(&self) -> Vec<(usize, usize)>
pub fn pilot_positions(&self) -> Vec<(usize, usize)>
The pilot REs $(k, l)$, symbol after symbol.
Sourcepub fn data_indices(&self) -> Vec<usize>
pub fn data_indices(&self) -> Vec<usize>
The indices $l K + k$ of the data REs, symbol after symbol: the order in which
ResourceGrid::map places the data and ResourceGrid::extract takes them.
§Examples
use comnum_waveform::ofdm::grid::{PilotPattern, ResourceGrid};
let g = ResourceGrid { n_subcarriers: 4, n_symbols: 2, pattern: PilotPattern::Comb { spacing: 2 }, seed: 0 };
assert_eq!(g.data_indices(), vec![1, 3, 5, 7]);Sourcepub fn pilot_symbols(&self) -> Vec<usize>
pub fn pilot_symbols(&self) -> Vec<usize>
The symbols that carry at least one pilot.
Sourcepub fn map(&self, data: &[C64]) -> Result<Vec<C64>>
pub fn map(&self, data: &[C64]) -> Result<Vec<C64>>
Place data (exactly ResourceGrid::n_data symbols) and the pilots: the grid,
symbol after symbol.
§Errors
The errors of ResourceGrid::check; Error::Shape for another number of data
symbols.
Sourcepub fn extract<T: Copy>(&self, grid: &[T]) -> Result<Vec<T>>
pub fn extract<T: Copy>(&self, grid: &[T]) -> Result<Vec<T>>
The data REs of a grid, in the order of ResourceGrid::map.
§Errors
Error::Shape unless grid holds the $K L$ REs of the grid.