mirror of
https://github.com/cberner/raptorq.git
synced 2024-06-29 18:21:43 +00:00
Fix compiler warnings and add a test
This commit is contained in:
parent
cec0f2bdd1
commit
f8d8d53c52
19
src/base.rs
19
src/base.rs
@ -268,7 +268,7 @@ impl IntermediateSymbolDecoder {
|
||||
}
|
||||
let r = r.unwrap() as usize;
|
||||
|
||||
let mut chosen_row;
|
||||
let chosen_row;
|
||||
if r == 2 {
|
||||
// See paragraph starting "If r = 2 and there is a row with exactly 2 ones in V..."
|
||||
if rows_with_two_ones.len() > 0 {
|
||||
@ -593,10 +593,12 @@ impl IntermediateSymbolDecoder {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn get_symbol_mul_ops(&self) -> u32 {
|
||||
self.debug_symbol_mul_ops
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn get_symbol_add_ops(&self) -> u32 {
|
||||
self.debug_symbol_add_ops
|
||||
}
|
||||
@ -681,6 +683,7 @@ mod tests {
|
||||
use constraint_matrix::generate_constraint_matrix;
|
||||
use base::fused_inverse_mul_symbols;
|
||||
use octet::Octet;
|
||||
use base::IntermediateSymbolDecoder;
|
||||
|
||||
fn identity(size: usize) -> OctetMatrix {
|
||||
let mut result = OctetMatrix::new(size, size);
|
||||
@ -715,4 +718,18 @@ mod tests {
|
||||
assert_eq!(a.clone().inverse().unwrap().mul_symbols(&rand_symbols), fused_inverse_mul_symbols(&a, &rand_symbols, source_symbols).unwrap());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn operations_per_symbol() {
|
||||
Octet::static_init();
|
||||
for elements in [10, 100].iter() {
|
||||
let num_symbols = extended_source_block_symbols(*elements);
|
||||
let a = generate_constraint_matrix(num_symbols, 0..num_symbols);
|
||||
let symbols = vec![Symbol::zero(1); a.width()];
|
||||
let mut decoder = IntermediateSymbolDecoder::new(&a, &symbols, num_symbols);
|
||||
decoder.execute();
|
||||
assert!((decoder.get_symbol_mul_ops() as f64 / num_symbols as f64) < 30.0);
|
||||
assert!((decoder.get_symbol_add_ops() as f64 / num_symbols as f64) < 50.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ use constraint_matrix::enc_indices;
|
||||
pub struct SourceBlockDecoder {
|
||||
source_block_id: u8,
|
||||
symbol_size: u16,
|
||||
block_length: u64,
|
||||
source_block_symbols: u32,
|
||||
source_symbols: Vec<Option<Symbol>>,
|
||||
repair_packets: Vec<EncodingPacket>,
|
||||
@ -30,7 +29,6 @@ impl SourceBlockDecoder {
|
||||
SourceBlockDecoder {
|
||||
source_block_id,
|
||||
symbol_size,
|
||||
block_length,
|
||||
source_block_symbols: source_symbols,
|
||||
source_symbols: vec![None; source_symbols as usize],
|
||||
repair_packets: vec![],
|
||||
|
@ -14,7 +14,6 @@ use base::fused_inverse_mul_symbols;
|
||||
|
||||
pub struct SourceBlockEncoder {
|
||||
source_block_id: u8,
|
||||
symbol_size: u16,
|
||||
source_symbols: Vec<Symbol>,
|
||||
intermediate_symbols: Vec<Symbol>
|
||||
}
|
||||
@ -28,7 +27,6 @@ impl SourceBlockEncoder {
|
||||
let intermediate_symbols = gen_intermediate_symbols(extend_source_block(source_symbols.clone(), symbol_size as usize), symbol_size as usize);
|
||||
SourceBlockEncoder {
|
||||
source_block_id,
|
||||
symbol_size,
|
||||
source_symbols,
|
||||
intermediate_symbols
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user