Skip to main content

QraCode

Struct QraCode 

Source
pub struct QraCode {
Show 24 fields pub K: usize, pub N: usize, pub m: u32, pub M: usize, pub a: usize, pub NC: usize, pub V: usize, pub C: usize, pub NMSG: usize, pub MAXVDEG: usize, pub MAXCDEG: usize, pub code_type: QraCodeType, pub R: f32, pub name: &'static str, pub acc_input_idx: &'static [i32], pub acc_input_wlog: &'static [i32], pub gflog: &'static [i32], pub gfexp: &'static [i32], pub msgw: &'static [i32], pub vdeg: &'static [i32], pub cdeg: &'static [i32], pub v2cmidx: &'static [i32], pub c2vmidx: &'static [i32], pub gfpmat: &'static [i32],
}
Expand description

Static description of a single QRA code: parameters + the precomputed tables consumed by the encoder and BP decoder.

Fields§

§K: usize

Number of information symbols.

§N: usize

Codeword length in symbols.

§m: u32

Bits per symbol (M = 2^m).

§M: usize

Symbol alphabet cardinality.

§a: usize

Code grouping factor (1 for Q65).

§NC: usize

Number of check symbols (N − K).

§V: usize

Number of variables in the code graph (= N).

§C: usize

Number of factor nodes (= N + NC + 1).

§NMSG: usize

Number of edges / messages in the bipartite graph.

§MAXVDEG: usize

Maximum variable-node degree in the graph.

§MAXCDEG: usize

Maximum factor-node (check) degree in the graph.

§code_type: QraCodeType

Code type (Normal / CRC / CRC-punctured).

§R: f32

Code rate K / N.

§name: &'static str

Human-readable code name (e.g. "qra15_65_64_irr_e23").

§acc_input_idx: &'static [i32]

acc_input_idx[k] — index into x[] of the systematic input symbol entering the accumulator at check k. Length NC * a + 1 (the +1 entry is the terminator check used in debug builds; it is harmless to have it present).

§acc_input_wlog: &'static [i32]

acc_input_wlog[k] — log-α weight (in GF(M)*) applied to that input before XOR-accumulation.

§gflog: &'static [i32]

GF(M) discrete log: gflog[x] = log_α(x) for x != 0.

§gfexp: &'static [i32]

GF(M) discrete exp: gfexp[i] = α^i for 0 ≤ i < M − 1.

§msgw: &'static [i32]

msgw[i] — log-α weight attached to message edge i.

§vdeg: &'static [i32]

vdeg[v] — degree of variable node v.

§cdeg: &'static [i32]

cdeg[c] — degree of factor node c.

§v2cmidx: &'static [i32]

v2cmidx[v * MAXVDEG + k] — message index for the k-th edge leaving variable v. Length V * MAXVDEG.

§c2vmidx: &'static [i32]

c2vmidx[c * MAXCDEG + k] — message index for the k-th edge leaving check c. Length C * MAXCDEG.

§gfpmat: &'static [i32]

gfpmat[w * M + k] — multiplication-by-α^w permutation table over GF(M). Length (M − 1) * M.

Implementations§

Source§

impl QraCode

Source

pub fn encode(&self, x: &[i32], y: &mut [i32])

Systematic encode: copy x (K info symbols over GF(M)) into the first K positions of y, then compute NC parity symbols by running the QRA accumulator chain across acc_input_idx / acc_input_wlog.

x.len() must equal self.K; y.len() must equal self.N. All symbol values must be in 0 .. self.M.

Source

pub fn mfsk_bessel_metric( &self, pix: &mut [f32], rsq: &[f32], n_symbols: usize, es_no_metric: f32, ) -> f32

Convert per-tone squared amplitudes into per-symbol intrinsic probability distributions, assuming non-coherent M-FSK reception in AWGN.

n_symbols is the number of observed channel symbols — this matches the C reference’s qra_mfskbesselmetric(..., N, ...) call shape, where N is passed in rather than read off the code, because Q65 punctures 2 symbols off the codeword and so observes N - 2 = 63 symbols, not the underlying code’s N = 65. Both pix and rsq must have length M * n_symbols, laid out row-major: symbol-k data sits in [M * k .. M * (k+1)].

Returns the estimated noise standard deviation σ̂.

The metric is calibrated for Es/No = es_no_metric (linear, not dB). Q65 uses ~2.8 dB linearised, scaled by m * R.

Source

pub fn extrinsic( &self, pex: &mut [f32], pix: &[f32], maxiter: u32, scratch: &mut DecoderScratch, ) -> ExtrinsicResult

Iterative non-binary BP: given per-symbol intrinsic probability distributions pix (length M·V), iterate until each variable’s outgoing extrinsic distribution is concentrated on one value or maxiter is exhausted.

On return, pex (length M·V) holds the extrinsic distributions — pass them together with pix to Self::map_decode for the final hard decision.

scratch must come from DecoderScratch::for_code applied to the same code instance.

Source

pub fn map_decode(&self, pex: &mut [f32], pix: &[f32], xdec: &mut [i32])

MAP hard decision on the K information symbols.

Multiplies extrinsic × intrinsic for each variable, then argmax. Destroys pex in place. xdec.len() must equal self.K.

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.