1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Copyright (c) 2025 Shenghao Yang. All rights reserved.
// Licensed under AGPL-3.0 or commercial license. See LICENSE for details.
use crateOperation;
/// Traits for data operations used by encoder and decoder.
/// They hide the implementation details of the vector operations,
/// including the data storage and caculations.
/// They also provide data security by hiding the data operations.
/// The encoder and decoder use indices to identify the vectors.
/// The message vectors are indexed from 0 to k-1, which are supposed consecutive.
/// The data vectors are indexed by a unique vector ID, which is used by both the encoder and decoder.
/// In our implementation using Rust, usize is naturally used as the type of vector IDs.
/* pub trait DataOperations {
/// Sets multiple packets to zero.
fn ensure_zero(&mut self, list_id: &[usize]);
/// Multiplies a vector by the alpha value.
fn multiply_alpha(&mut self, id: usize);
/// Multiplies a vector by a scalar value.
fn multiply_scalar(&mut self, scalar: u8, id: usize);
/// Divides a vector by a scalar value.
fn divide_scalar(&mut self, scalar: u8, id: usize);
/// Adds multiple vectors (from `list_id`) to a target vector (`target_id`).
/// Equivalent to `add_many_to_one(list_id, id)` in the spec.
fn add_to_vector(&mut self, list_id: &[usize], target_id: usize);
/// Adds a source vector (`source_id`) to multiple target vectors (`target_ids`).
/// Equivalent to `add_one_to_many(id, list_id)` in the spec.
fn broadcast_add(&mut self, source_id: usize, target_ids: &[usize]);
/// Adds a scalar multiple of a source vector (`source_id`) to multiple target vectors (`target_ids`).
fn mul_add(&mut self, source_id: usize, scalar: u8, target_id: usize);
/// Move a coded vector to a variable vector.
fn move_to(&mut self, cod_id: usize, var_id: usize);
/// Copy a vector to a target vector.
fn copy_to(&mut self, src_id: usize, target_id: usize);
/// Remove a vector.
fn remove(&mut self, id: usize);
}
*/
/// This trait defines the interface for data operators used to store and retrieve the vectors.
/// It is used by the data manager to store and retrieve the vectors for the purpose of testing with data operator only.
/// This interface is not used by the encoder and decoder and is not required by the data manager in the future.
/// The data operator should be implemented for specific applications. Vector data management, vector operation acceleration, multi-threading, etc. should be considered in the data operator implementation, but not in the coding library.