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
//! RECURSIA: recursive compression of TEC patterns.
use cratecosiatec_compress;
use crateTranslationalEquivalence;
/// RECURSIA (Recursive SIA) applied to the COSIATEC compression algorithm.
///
/// This function first obtains a standard COSIATEC cover of the dataset, then
/// recursively compresses the `pattern` of each resulting TEC if the pattern
/// contains at least `min_pattern_size` points. The recursive compression uses
/// the same algorithm (RECURSIA‑COSIATEC) and stores the result in the TEC’s
/// `sub_tecs` field. After recursion, the original `pattern` is cleared because
/// the compressed representation is now held in `sub_tecs`.
///
/// The recursion continues until patterns shrink below the size threshold.
/// This hierarchical encoding can reveal nested repetitions and improve
/// overall compression factor.
///
/// # Arguments
/// * `dataset` - A reference to the set of points `(tick, pitch)` to compress.
/// * `restrict_dpitch_zero` - If `true`, only purely temporal translations are allowed.
/// * `min_pattern_size` - Minimum number of points a pattern must contain to
/// be considered for recursion. Patterns smaller than this are left unchanged
/// (their `sub_tecs` remains empty).
/// * `sweepline_optimization` - Whether to use the sweepline optimized implementation.
///
/// # Returns
/// A vector of top‑level `TranslationalEquivalence` objects. Each TEC may have
/// a non‑empty `sub_tecs` field containing the recursively compressed version
/// of its pattern. The original pattern points are cleared in such cases.
///
/// # Examples
/// ```
/// use nbslim::recursive_cosiatec_compress;
///
/// let points = vec![(0, 0), (1, 1), (2, 0), (3, 1)];
/// let tecs = recursive_cosiatec_compress(&points, true, 2, true);
/// // Some TECs may have non‑empty sub_tecs.
/// ```