pub const MAX_INACTIVE_NUM: usize = 100;
pub const GF2_FIELD_POLY: u16 = 0x001;
pub type DegreeSetFn = Box<dyn FnMut(usize) -> Vec<usize>>;
#[derive(Clone, Debug)]
pub struct DecodingConfig {
pub max_inactive_num: usize,
pub inac_strategy: InactivationStrategy,
pub subs_method: SubstitutionMethod,
}
impl Default for DecodingConfig {
fn default() -> Self {
Self {
max_inactive_num: 0,
inac_strategy: InactivationStrategy::ByIndex,
subs_method: SubstitutionMethod::Direct,
}
}
}
impl DecodingConfig {
pub fn with_max_inact_num(mut self, max_inactive_num: usize) -> Self {
self.max_inactive_num = max_inactive_num;
self
}
}
#[derive(Clone, Debug)]
pub struct CodeParams {
pub k: usize,
pub a: usize,
pub b: usize,
pub l: usize,
pub h: usize,
pub i: usize,
}
impl CodeParams {
pub fn new(k: usize, a: usize, l: usize, h: usize) -> Self {
let b = k - a;
let i = b + h;
Self { k, a, b, l, h, i }
}
pub fn new_without_pre_inact(k: usize, l: usize, h: usize) -> Self {
Self {
k,
a: k,
b: 0,
l,
h,
i: 0,
}
}
pub fn num_active(&self) -> usize {
self.a + self.l
}
pub fn num_pre_inactive(&self) -> usize {
self.i
}
pub fn num_inactive(&self) -> usize {
self.b + self.h
}
pub fn num_message_ldpc(&self) -> usize {
self.k + self.l
}
pub fn num_total(&self) -> usize {
self.k + self.l + self.h
}
pub fn has_precode(&self) -> bool {
self.l > 0 || self.h > 0
}
pub fn num_message(&self) -> usize {
self.k
}
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum CodeType {
Ordinary,
Systematic,
}
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum SolverType {
OrdEnc,
OrdDec,
SysEnc,
SysDec,
}
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum InactivationStrategy {
ByIndex,
FirstActive,
LastActive,
MinDegree,
TrailRun,
}
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum SubstitutionMethod {
Direct,
Original,
}
#[derive(Debug, PartialEq, Clone, Copy)]
pub enum DecodeStatus {
Decoded,
NotDecoded,
}
#[derive(Debug, Clone)]
pub enum Operation {
EnsureZero {
list_id: Vec<usize>,
},
EnsureZeroOne {
id: usize,
},
MultiplyAlpha {
id: usize,
},
MultiplyScalar {
scalar: u8,
id: usize,
},
AddOneToVector {
src_id: usize,
target_id: usize,
},
AddTwoToVector {
s0: usize,
s1: usize,
target_id: usize,
},
AddThreeToVector {
s0: usize,
s1: usize,
s2: usize,
target_id: usize,
},
AddToVector {
list_id: Vec<usize>,
target_id: usize,
},
BroadcastAdd {
src_id: usize,
target_ids: Vec<usize>,
},
MulAdd {
src_id: usize,
scalar: u8,
target_id: usize,
},
MoveTo {
src_id: usize,
target_id: usize,
},
CopyTo {
src_id: usize,
target_id: usize,
},
Remove {
id: usize,
},
InfoCodedVector {
coded_id: usize,
data_id: usize,
},
}