ldpc_toolbox/codes/
nr5g.rs

1//! # 5G NR LDPC codes
2//!
3//! This module contains the LDPC codes used in 5G NR.
4//!
5//! The code definitions are handled as variants of the [`Code`] enum,
6//! which defines methods to work with the codes.
7//!
8//! ## References
9//! \[1\] [3GPP TS 38.212 V18.6.0 (2025-04)](https://www.etsi.org/deliver/etsi_ts/138200_138299/138212/18.06.00_60/ts_138212v180600p.pdf)
10
11use crate::sparse::SparseMatrix;
12use clap::ValueEnum;
13
14/// 5G NR LDPC base graph.
15#[derive(Copy, Clone, Debug, Eq, PartialEq, ValueEnum)]
16pub enum BaseGraph {
17    /// 5G NR LDPC base graph 1.
18    #[value(name = "1")]
19    BG1,
20    /// 5G NR LDPC base graph 2.
21    #[value(name = "2")]
22    BG2,
23}
24
25#[derive(Copy, Clone, Debug, Eq, PartialEq)]
26struct VijRow {
27    column_index: usize,
28    vij: [usize; 8],
29}
30
31impl VijRow {
32    fn vij(&self, set_index: SetIndex) -> usize {
33        self.vij[usize::from(set_index)]
34    }
35}
36
37impl BaseGraph {
38    /// Constructs the parity check matrix for this base graph with a given
39    /// lifting size.
40    pub fn h(&self, lifting_size: LiftingSize) -> SparseMatrix {
41        let zc = usize::from(lifting_size);
42        let mut h = SparseMatrix::new(self.num_rows() * zc, self.num_cols() * zc);
43        for (j, rows) in self.graph().iter().enumerate() {
44            for row in rows {
45                let k = row.column_index;
46                let vij = row.vij(lifting_size.set_index());
47                for r in 0..zc {
48                    h.insert(zc * j + r, zc * k + ((r + vij) % zc));
49                }
50            }
51        }
52        h
53    }
54
55    fn graph(&self) -> Box<[Vec<VijRow>]> {
56        match self {
57            BaseGraph::BG1 => base_graph_1().into(),
58            BaseGraph::BG2 => base_graph_2().into(),
59        }
60    }
61
62    fn num_rows(&self) -> usize {
63        self.graph().len()
64    }
65
66    fn num_cols(&self) -> usize {
67        match self {
68            BaseGraph::BG1 => 68,
69            BaseGraph::BG2 => 52,
70        }
71    }
72}
73
74/// 5G NR LDPC lifting size.
75///
76/// This enum lists the LDPC lifiting sizes defined in TS 38.212 Table 5.3.2-1.
77#[derive(Copy, Clone, Debug, Eq, PartialEq, ValueEnum)]
78pub enum LiftingSize {
79    /// 5G NR lifting size 2.
80    #[value(name = "2")]
81    Z2,
82    /// 5G NR lifting size 4.
83    #[value(name = "4")]
84    Z4,
85    /// 5G NR lifting size 8.
86    #[value(name = "8")]
87    Z8,
88    /// 5G NR lifting size 16.
89    #[value(name = "16")]
90    Z16,
91    /// 5G NR lifting size 32.
92    #[value(name = "32")]
93    Z32,
94    /// 5G NR lifting size 64.
95    #[value(name = "64")]
96    Z64,
97    /// 5G NR lifting size 128.
98    #[value(name = "128")]
99    Z128,
100    /// 5G NR lifting size 256.
101    #[value(name = "256")]
102    Z256,
103    /// 5G NR lifting size 3.
104    #[value(name = "3")]
105    Z3,
106    /// 5G NR lifting size 6.
107    #[value(name = "6")]
108    Z6,
109    /// 5G NR lifting size 12.
110    #[value(name = "12")]
111    Z12,
112    /// 5G NR lifting size 24.
113    #[value(name = "24")]
114    Z24,
115    /// 5G NR lifting size 48.
116    #[value(name = "48")]
117    Z48,
118    /// 5G NR lifting size 96.
119    #[value(name = "96")]
120    Z96,
121    /// 5G NR lifting size 192.
122    #[value(name = "192")]
123    Z192,
124    /// 5G NR lifting size 384.
125    #[value(name = "384")]
126    Z384,
127    /// 5G NR lifting size 5.
128    #[value(name = "5")]
129    Z5,
130    /// 5G NR lifting size 10.
131    #[value(name = "10")]
132    Z10,
133    /// 5G NR lifting size 20.
134    #[value(name = "20")]
135    Z20,
136    /// 5G NR lifting size 40.
137    #[value(name = "40")]
138    Z40,
139    /// 5G NR lifting size 80.
140    #[value(name = "80")]
141    Z80,
142    /// 5G NR lifting ize 160.
143    #[value(name = "160")]
144    Z160,
145    /// 5G NR lifting size 320.
146    #[value(name = "320")]
147    Z320,
148    /// 5G NR lifting size 7.
149    #[value(name = "7")]
150    Z7,
151    /// 5G NR lifting size 14.
152    #[value(name = "14")]
153    Z14,
154    /// 5G NR lifting size 28.
155    #[value(name = "28")]
156    Z28,
157    /// 5G NR lifting size 56.
158    #[value(name = "56")]
159    Z56,
160    /// 5G NR lifting size 112.
161    #[value(name = "112")]
162    Z112,
163    /// 5G NR lifting size 224.
164    #[value(name = "224")]
165    Z224,
166    /// 5G NR lifting size 9.
167    #[value(name = "9")]
168    Z9,
169    /// 5G NR lifting size 18.
170    #[value(name = "18")]
171    Z18,
172    /// 5G NR lifting size 36.
173    #[value(name = "36")]
174    Z36,
175    /// 5G NR lifting size 72.
176    #[value(name = "72")]
177    Z72,
178    /// 5G NR lifting size 144.
179    #[value(name = "144")]
180    Z144,
181    /// 5G NR lifting size 288.
182    #[value(name = "288")]
183    Z288,
184    /// 5G NR lifting size 11.
185    #[value(name = "11")]
186    Z11,
187    /// 5G NR lifting size 22.
188    #[value(name = "22")]
189    Z22,
190    /// 5G NR lifting size 44.
191    #[value(name = "44")]
192    Z44,
193    /// 5G NR lifting size 88.
194    #[value(name = "88")]
195    Z88,
196    /// 5G NR lifting size 176.
197    #[value(name = "176")]
198    Z176,
199    /// 5G NR lifting size 352.
200    #[value(name = "352")]
201    Z352,
202    /// 5G NR lifting size 13.
203    #[value(name = "13")]
204    Z13,
205    /// 5G NR lifting size 26.
206    #[value(name = "26")]
207    Z26,
208    /// 5G NR lifting size 52.
209    #[value(name = "52")]
210    Z52,
211    /// 5G NR lifting size 104.
212    #[value(name = "104")]
213    Z104,
214    /// 5G NR lifting size 204.
215    #[value(name = "204")]
216    Z208,
217    /// 5G NR lifting size 15.
218    #[value(name = "15")]
219    Z15,
220    /// 5G NR lifting size 30.
221    #[value(name = "30")]
222    Z30,
223    /// 5G NR lifting size 60.
224    #[value(name = "60")]
225    Z60,
226    /// 5G NR lifting size 120.
227    #[value(name = "120")]
228    Z120,
229    /// 5G NR lifting size 240.
230    #[value(name = "240")]
231    Z240,
232}
233
234#[derive(Copy, Clone, Debug, Eq, PartialEq)]
235enum SetIndex {
236    Ils0,
237    Ils1,
238    Ils2,
239    Ils3,
240    Ils4,
241    Ils5,
242    Ils6,
243    Ils7,
244}
245
246impl LiftingSize {
247    fn set_index(&self) -> SetIndex {
248        use LiftingSize::*;
249        use SetIndex::*;
250        match self {
251            Z2 | Z4 | Z8 | Z16 | Z32 | Z64 | Z128 | Z256 => Ils0,
252            Z3 | Z6 | Z12 | Z24 | Z48 | Z96 | Z192 | Z384 => Ils1,
253            Z5 | Z10 | Z20 | Z40 | Z80 | Z160 | Z320 => Ils2,
254            Z7 | Z14 | Z28 | Z56 | Z112 | Z224 => Ils3,
255            Z9 | Z18 | Z36 | Z72 | Z144 | Z288 => Ils4,
256            Z11 | Z22 | Z44 | Z88 | Z176 | Z352 => Ils5,
257            Z13 | Z26 | Z52 | Z104 | Z208 => Ils6,
258            Z15 | Z30 | Z60 | Z120 | Z240 => Ils7,
259        }
260    }
261}
262
263impl From<LiftingSize> for usize {
264    fn from(value: LiftingSize) -> usize {
265        use LiftingSize::*;
266        match value {
267            Z2 => 2,
268            Z4 => 4,
269            Z8 => 8,
270            Z16 => 16,
271            Z32 => 32,
272            Z64 => 64,
273            Z128 => 128,
274            Z256 => 256,
275            Z3 => 3,
276            Z6 => 6,
277            Z12 => 12,
278            Z24 => 24,
279            Z48 => 48,
280            Z96 => 96,
281            Z192 => 192,
282            Z384 => 384,
283            Z5 => 5,
284            Z10 => 10,
285            Z20 => 20,
286            Z40 => 40,
287            Z80 => 80,
288            Z160 => 160,
289            Z320 => 320,
290            Z7 => 7,
291            Z14 => 14,
292            Z28 => 28,
293            Z56 => 56,
294            Z112 => 112,
295            Z224 => 224,
296            Z9 => 9,
297            Z18 => 18,
298            Z36 => 36,
299            Z72 => 72,
300            Z144 => 144,
301            Z288 => 288,
302            Z11 => 11,
303            Z22 => 22,
304            Z44 => 44,
305            Z88 => 88,
306            Z176 => 176,
307            Z352 => 352,
308            Z13 => 13,
309            Z26 => 26,
310            Z52 => 52,
311            Z104 => 104,
312            Z208 => 208,
313            Z15 => 15,
314            Z30 => 30,
315            Z60 => 60,
316            Z120 => 120,
317            Z240 => 240,
318        }
319    }
320}
321
322impl From<SetIndex> for usize {
323    fn from(value: SetIndex) -> usize {
324        use SetIndex::*;
325        match value {
326            Ils0 => 0,
327            Ils1 => 1,
328            Ils2 => 2,
329            Ils3 => 3,
330            Ils4 => 4,
331            Ils5 => 5,
332            Ils6 => 6,
333            Ils7 => 7,
334        }
335    }
336}
337
338macro_rules! row {
339    ($col:literal $($row:literal)+) => {
340        VijRow {
341            column_index: $col,
342            vij: [$($row),+],
343        }
344    }
345}
346
347// TS 38.212 Table 5.3.2-2
348fn base_graph_1() -> [Vec<VijRow>; 46] {
349    [
350        // i = 0
351        vec![
352            row!(0 250 307 73 223 211 294 0 135),
353            row!(1 69 19 15 16 198 118 0 227),
354            row!(2 226 50 103 94 188 167 0 126),
355            row!(3 159 369 49 91 186 330 0 134),
356            row!(5 100 181 240 74 219 207 0 84),
357            row!(6 10 216 39 10 4 165 0 83),
358            row!(9 59 317 15 0 29 243 0 53),
359            row!(10 229 288 162 205 144 250 0 225),
360            row!(11 110 109 215 216 116 1 0 205),
361            row!(12 191 17 164 21 216 339 0 128),
362            row!(13 9 357 133 215 115 201 0 75),
363            row!(15 195 215 298 14 233 53 0 135),
364            row!(16 23 106 110 70 144 347 0 217),
365            row!(18 190 242 113 141 95 304 0 220),
366            row!(19 35 180 16 198 216 167 0 90),
367            row!(20 239 330 189 104 73 47 0 105),
368            row!(21 31 346 32 81 261 188 0 137),
369            row!(22 1 1 1 1 1 1 0 1),
370            row!(23 0 0 0 0 0 0 0 0),
371        ],
372        // i = 1
373        vec![
374            row!(0 2 76 303 141 179 77 22 96),
375            row!(2 239 76 294 45 162 225 11 236),
376            row!(3 117 73 27 151 223 96 124 136),
377            row!(4 124 288 261 46 256 338 0 221),
378            row!(5 71 144 161 119 160 268 10 128),
379            row!(7 222 331 133 157 76 112 0 92),
380            row!(8 104 331 4 133 202 302 0 172),
381            row!(9 173 178 80 87 117 50 2 56),
382            row!(11 220 295 129 206 109 167 16 11),
383            row!(12 102 342 300 93 15 253 60 189),
384            row!(14 109 217 76 79 72 334 0 95),
385            row!(15 132 99 266 9 152 242 6 85),
386            row!(16 142 354 72 118 158 257 30 153),
387            row!(17 155 114 83 194 147 133 0 87),
388            row!(19 255 331 260 31 156 9 168 163),
389            row!(21 28 112 301 187 119 302 31 216),
390            row!(22 0 0 0 0 0 0 105 0),
391            row!(23 0 0 0 0 0 0 0 0),
392            row!(24 0 0 0 0 0 0 0 0),
393        ],
394        // i = 2
395        vec![
396            row!(0 106 205 68 207 258 226 132 189),
397            row!(1 111 250 7 203 167 35 37 4),
398            row!(2 185 328 80 31 220 213 21 225),
399            row!(4 63 332 280 176 133 302 180 151),
400            row!(5 117 256 38 180 243 111 4 236),
401            row!(6 93 161 227 186 202 265 149 117),
402            row!(7 229 267 202 95 218 128 48 179),
403            row!(8 177 160 200 153 63 237 38 92),
404            row!(9 95 63 71 177 0 294 122 24),
405            row!(10 39 129 106 70 3 127 195 68),
406            row!(13 142 200 295 77 74 110 155 6),
407            row!(14 225 88 283 214 229 286 28 101),
408            row!(15 225 53 301 77 0 125 85 33),
409            row!(17 245 131 184 198 216 131 47 96),
410            row!(18 205 240 246 117 269 163 179 125),
411            row!(19 251 205 230 223 200 210 42 67),
412            row!(20 117 13 276 90 234 7 66 230),
413            row!(24 0 0 0 0 0 0 0 0),
414            row!(25 0 0 0 0 0 0 0 0),
415        ],
416        // i = 3
417        vec![
418            row!(0 121 276 220 201 187 97 4 128),
419            row!(1 89 87 208 18 145 94 6 23),
420            row!(3 84 0 30 165 166 49 33 162),
421            row!(4 20 275 197 5 108 279 113 220),
422            row!(6 150 199 61 45 82 139 49 43),
423            row!(7 131 153 175 142 132 166 21 186),
424            row!(8 243 56 79 16 197 91 6 96),
425            row!(10 136 132 281 34 41 106 151 1),
426            row!(11 86 305 303 155 162 246 83 216),
427            row!(12 246 231 253 213 57 345 154 22),
428            row!(13 219 341 164 147 36 269 87 24),
429            row!(14 211 212 53 69 115 185 5 167),
430            row!(16 240 304 44 96 242 249 92 200),
431            row!(17 76 300 28 74 165 215 173 32),
432            row!(18 244 271 77 99 0 143 120 235),
433            row!(20 144 39 319 30 113 121 2 172),
434            row!(21 12 357 68 158 108 121 142 219),
435            row!(22 1 1 1 1 1 1 0 1),
436            row!(25 0 0 0 0 0 0 0 0),
437        ],
438        // i = 4
439        vec![
440            row!(0 157 332 233 170 246 42 24 64),
441            row!(1 102 181 205 10 235 256 204 211),
442            row!(26 0 0 0 0 0 0 0 0),
443        ],
444        // i = 5
445        vec![
446            row!(0 205 195 83 164 261 219 185 2),
447            row!(1 236 14 292 59 181 130 100 171),
448            row!(3 194 115 50 86 72 251 24 47),
449            row!(12 231 166 318 80 283 322 65 143),
450            row!(16 28 241 201 182 254 295 207 210),
451            row!(21 123 51 267 130 79 258 161 180),
452            row!(22 115 157 279 153 144 283 72 180),
453            row!(27 0 0 0 0 0 0 0 0),
454        ],
455        // i = 6
456        vec![
457            row!(0 183 278 289 158 80 294 6 199),
458            row!(6 22 257 21 119 144 73 27 22),
459            row!(10 28 1 293 113 169 330 163 23),
460            row!(11 67 351 13 21 90 99 50 100),
461            row!(13 244 92 232 63 59 172 48 92),
462            row!(17 11 253 302 51 177 150 24 207),
463            row!(18 157 18 138 136 151 284 38 52),
464            row!(20 211 225 235 116 108 305 91 13),
465            row!(28 0 0 0 0 0 0 0 0),
466        ],
467        // i = 7
468        vec![
469            row!(0 220 9 12 17 169 3 145 77),
470            row!(1 44 62 88 76 189 103 88 146),
471            row!(4 159 316 207 104 154 224 112 209),
472            row!(7 31 333 50 100 184 297 153 32),
473            row!(8 167 290 25 150 104 215 159 166),
474            row!(14 104 114 76 158 164 39 76 18),
475            row!(29 0 0 0 0 0 0 0 0),
476        ],
477        // i = 8
478        vec![
479            row!(0 112 307 295 33 54 348 172 181),
480            row!(1 4 179 133 95 0 75 2 105),
481            row!(3 7 165 130 4 252 22 131 141),
482            row!(12 211 18 231 217 41 312 141 223),
483            row!(16 102 39 296 204 98 224 96 177),
484            row!(19 164 224 110 39 46 17 99 145),
485            row!(21 109 368 269 58 15 59 101 199),
486            row!(22 241 67 245 44 230 314 35 153),
487            row!(24 90 170 154 201 54 244 116 38),
488            row!(30 0 0 0 0 0 0 0 0),
489        ],
490        // i = 9
491        vec![
492            row!(0 103 366 189 9 162 156 6 169),
493            row!(1 182 232 244 37 159 88 10 12),
494            row!(10 109 321 36 213 93 293 145 206),
495            row!(11 21 133 286 105 134 111 53 221),
496            row!(13 142 57 151 89 45 92 201 17),
497            row!(17 14 303 267 185 132 152 4 212),
498            row!(18 61 63 135 109 76 23 164 92),
499            row!(20 216 82 209 218 209 337 173 205),
500            row!(31 0 0 0 0 0 0 0 0),
501        ],
502        // i = 10
503        vec![
504            row!(1 98 101 14 82 178 175 126 116),
505            row!(2 149 339 80 165 1 253 77 151),
506            row!(4 167 274 211 174 28 27 156 70),
507            row!(7 160 111 75 19 267 231 16 230),
508            row!(8 49 383 161 194 234 49 12 115),
509            row!(14 58 354 311 103 201 267 70 84),
510            row!(32 0 0 0 0 0 0 0 0),
511        ],
512        // i = 11
513        vec![
514            row!(0 77 48 16 52 55 25 184 45),
515            row!(1 41 102 147 11 23 322 194 115),
516            row!(12 83 8 290 2 274 200 123 134),
517            row!(16 182 47 289 35 181 351 16 1),
518            row!(21 78 188 177 32 273 166 104 152),
519            row!(22 252 334 43 84 39 338 109 165),
520            row!(23 22 115 280 201 26 192 124 107),
521            row!(33 0 0 0 0 0 0 0 0),
522        ],
523        // i = 12
524        vec![
525            row!(0 160 77 229 142 225 123 6 186),
526            row!(1 42 186 235 175 162 217 20 215),
527            row!(10 21 174 169 136 244 142 203 124),
528            row!(11 32 232 48 3 151 110 153 180),
529            row!(13 234 50 105 28 238 176 104 98),
530            row!(18 7 74 52 182 243 76 207 80),
531            row!(34 0 0 0 0 0 0 0 0),
532        ],
533        // i = 13
534        vec![
535            row!(0 177 313 39 81 231 311 52 220),
536            row!(3 248 177 302 56 0 251 147 185),
537            row!(7 151 266 303 72 216 265 1 154),
538            row!(20 185 115 160 217 47 94 16 178),
539            row!(23 62 370 37 78 36 81 46 150),
540            row!(35 0 0 0 0 0 0 0 0),
541        ],
542        // i = 14
543        vec![
544            row!(0 206 142 78 14 0 22 1 124),
545            row!(12 55 248 299 175 186 322 202 144),
546            row!(15 206 137 54 211 253 277 118 182),
547            row!(16 127 89 61 191 16 156 130 95),
548            row!(17 16 347 179 51 0 66 1 72),
549            row!(21 229 12 258 43 79 78 2 76),
550            row!(36 0 0 0 0 0 0 0 0),
551        ],
552        // i = 15
553        vec![
554            row!(0 40 241 229 90 170 176 173 39),
555            row!(1 96 2 290 120 0 348 6 138),
556            row!(10 65 210 60 131 183 15 81 220),
557            row!(13 63 318 130 209 108 81 182 173),
558            row!(18 75 55 184 209 68 176 53 142),
559            row!(25 179 269 51 81 64 113 46 49),
560            row!(37 0 0 0 0 0 0 0 0),
561        ],
562        // i = 16
563        vec![
564            row!(1 64 13 69 154 270 190 88 78),
565            row!(3 49 338 140 164 13 293 198 152),
566            row!(11 49 57 45 43 99 332 160 84),
567            row!(20 51 289 115 189 54 331 122 5),
568            row!(22 154 57 300 101 0 114 182 205),
569            row!(38 0 0 0 0 0 0 0 0),
570        ],
571        // i = 17
572        vec![
573            row!(0 7 260 257 56 153 110 91 183),
574            row!(14 164 303 147 110 137 228 184 112),
575            row!(16 59 81 128 200 0 247 30 106),
576            row!(17 1 358 51 63 0 116 3 219),
577            row!(21 144 375 228 4 162 190 155 129),
578            row!(39 0 0 0 0 0 0 0 0),
579        ],
580        // i = 18
581        vec![
582            row!(1 42 130 260 199 161 47 1 183),
583            row!(12 233 163 294 110 151 286 41 215),
584            row!(13 8 280 291 200 0 246 167 180),
585            row!(18 155 132 141 143 241 181 68 143),
586            row!(19 147 4 295 186 144 73 148 14),
587            row!(40 0 0 0 0 0 0 0 0),
588        ],
589        // i = 19
590        vec![
591            row!(0 60 145 64 8 0 87 12 179),
592            row!(1 73 213 181 6 0 110 6 108),
593            row!(7 72 344 101 103 118 147 166 159),
594            row!(8 127 242 270 198 144 258 184 138),
595            row!(10 224 197 41 8 0 204 191 196),
596            row!(41 0 0 0 0 0 0 0 0),
597        ],
598        // i = 20
599        vec![
600            row!(0 151 187 301 105 265 89 6 77),
601            row!(3 186 206 162 210 81 65 12 187),
602            row!(9 217 264 40 121 90 155 15 203),
603            row!(11 47 341 130 214 144 244 5 167),
604            row!(22 160 59 10 183 228 30 30 130),
605            row!(42 0 0 0 0 0 0 0 0),
606        ],
607        // i = 21
608        vec![
609            row!(1 249 205 79 192 64 162 6 197),
610            row!(5 121 102 175 131 46 264 86 122),
611            row!(16 109 328 132 220 266 346 96 215),
612            row!(20 131 213 283 50 9 143 42 65),
613            row!(21 171 97 103 106 18 109 199 216),
614            row!(43 0 0 0 0 0 0 0 0),
615        ],
616        // i = 22
617        vec![
618            row!(0 64 30 177 53 72 280 44 25),
619            row!(12 142 11 20 0 189 157 58 47),
620            row!(13 188 233 55 3 72 236 130 126),
621            row!(17 158 22 316 148 257 113 131 178),
622            row!(44 0 0 0 0 0 0 0 0),
623        ],
624        // i = 23
625        vec![
626            row!(1 156 24 249 88 180 18 45 185),
627            row!(2 147 89 50 203 0 6 18 127),
628            row!(10 170 61 133 168 0 181 132 117),
629            row!(18 152 27 105 122 165 304 100 199),
630            row!(45 0 0 0 0 0 0 0 0),
631        ],
632        // i = 24
633        vec![
634            row!(0 112 298 289 49 236 38 9 32),
635            row!(3 86 158 280 157 199 170 125 178),
636            row!(4 236 235 110 64 0 249 191 2),
637            row!(11 116 339 187 193 266 288 28 156),
638            row!(22 222 234 281 124 0 194 6 58),
639            row!(46 0 0 0 0 0 0 0 0),
640        ],
641        // i = 25
642        vec![
643            row!(1 23 72 172 1 205 279 4 27),
644            row!(6 136 17 295 166 0 255 74 141),
645            row!(7 116 383 96 65 0 111 16 11),
646            row!(14 182 312 46 81 183 54 28 181),
647            row!(47 0 0 0 0 0 0 0 0),
648        ],
649        // i = 26
650        vec![
651            row!(0 195 71 270 107 0 325 21 163),
652            row!(2 243 81 110 176 0 326 142 131),
653            row!(4 215 76 318 212 0 226 192 169),
654            row!(15 61 136 67 127 277 99 197 98),
655            row!(48 0 0 0 0 0 0 0 0),
656        ],
657        // i = 27
658        vec![
659            row!(1 25 194 210 208 45 91 98 165),
660            row!(6 104 194 29 141 36 326 140 232),
661            row!(8 194 101 304 174 72 268 22 9),
662            row!(49 0 0 0 0 0 0 0 0),
663        ],
664        // i = 28
665        vec![
666            row!(0 128 222 11 146 275 102 4 32),
667            row!(4 165 19 293 153 0 1 1 43),
668            row!(19 181 244 50 217 155 40 40 200),
669            row!(21 63 274 234 114 62 167 93 205),
670            row!(50 0 0 0 0 0 0 0 0),
671        ],
672        // i = 29
673        vec![
674            row!(1 86 252 27 150 0 273 92 232),
675            row!(14 236 5 308 11 180 104 136 32),
676            row!(18 84 147 117 53 0 243 106 118),
677            row!(25 6 78 29 68 42 107 6 103),
678            row!(51 0 0 0 0 0 0 0 0),
679        ],
680        // i = 30
681        vec![
682            row!(0 216 159 91 34 0 171 2 170),
683            row!(10 73 229 23 130 90 16 88 199),
684            row!(13 120 260 105 210 252 95 112 26),
685            row!(24 9 90 135 123 173 212 20 105),
686            row!(52 0 0 0 0 0 0 0 0),
687        ],
688        // i = 31
689        vec![
690            row!(1 95 100 222 175 144 101 4 73),
691            row!(7 177 215 308 49 144 297 49 149),
692            row!(22 172 258 66 177 166 279 125 175),
693            row!(25 61 256 162 128 19 222 194 108),
694            row!(53 0 0 0 0 0 0 0 0),
695        ],
696        // i = 32
697        vec![
698            row!(0 221 102 210 192 0 351 6 103),
699            row!(12 112 201 22 209 211 265 126 110),
700            row!(14 199 175 271 58 36 338 63 151),
701            row!(24 121 287 217 30 162 83 20 211),
702            row!(54 0 0 0 0 0 0 0 0),
703        ],
704        // i = 33
705        vec![
706            row!(1 2 323 170 114 0 56 10 199),
707            row!(2 187 8 20 49 0 304 30 132),
708            row!(11 41 361 140 161 76 141 6 172),
709            row!(21 211 105 33 137 18 101 92 65),
710            row!(55 0 0 0 0 0 0 0 0),
711        ],
712        // i = 34
713        vec![
714            row!(0 127 230 187 82 197 60 4 161),
715            row!(7 167 148 296 186 0 320 153 237),
716            row!(15 164 202 5 68 108 112 197 142),
717            row!(17 159 312 44 150 0 54 155 180),
718            row!(56 0 0 0 0 0 0 0 0),
719        ],
720        // i = 35
721        vec![
722            row!(1 161 320 207 192 199 100 4 231),
723            row!(6 197 335 158 173 278 210 45 174),
724            row!(12 207 2 55 26 0 195 168 145),
725            row!(22 103 266 285 187 205 268 185 100),
726            row!(57 0 0 0 0 0 0 0 0),
727        ],
728        // i = 36
729        vec![
730            row!(0 37 210 259 222 216 135 6 11),
731            row!(14 105 313 179 157 16 15 200 207),
732            row!(15 51 297 178 0 0 35 177 42),
733            row!(18 120 21 160 6 0 188 43 100),
734            row!(58 0 0 0 0 0 0 0 0),
735        ],
736        // i = 37
737        vec![
738            row!(1 198 269 298 81 72 319 82 59),
739            row!(13 220 82 15 195 144 236 2 204),
740            row!(23 122 115 115 138 0 85 135 161),
741            row!(59 0 0 0 0 0 0 0 0),
742        ],
743        // i = 38
744        vec![
745            row!(0 167 185 151 123 190 164 91 121),
746            row!(9 151 177 179 90 0 196 64 90),
747            row!(10 157 289 64 73 0 209 198 26),
748            row!(12 163 214 181 10 0 246 100 140),
749            row!(60 0 0 0 0 0 0 0 0),
750        ],
751        // i = 39
752        vec![
753            row!(1 173 258 102 12 153 236 4 115),
754            row!(3 139 93 77 77 0 264 28 188),
755            row!(7 149 346 192 49 165 37 109 168),
756            row!(19 0 297 208 114 117 272 188 52),
757            row!(61 0 0 0 0 0 0 0 0),
758        ],
759        // i = 40
760        vec![
761            row!(0 157 175 32 67 216 304 10 4),
762            row!(8 137 37 80 45 144 237 84 103),
763            row!(17 149 312 197 96 2 135 12 30),
764            row!(62 0 0 0 0 0 0 0 0),
765        ],
766        // i = 41
767        vec![
768            row!(1 167 52 154 23 0 123 2 53),
769            row!(3 173 314 47 215 0 77 75 189),
770            row!(9 139 139 124 60 0 25 142 215),
771            row!(18 151 288 207 167 183 272 128 24),
772            row!(63 0 0 0 0 0 0 0 0),
773        ],
774        // i = 42
775        vec![
776            row!(0 149 113 226 114 27 288 163 222),
777            row!(4 157 14 65 91 0 83 10 170),
778            row!(24 137 218 126 78 35 17 162 71),
779            row!(64 0 0 0 0 0 0 0 0),
780        ],
781        // i = 43
782        vec![
783            row!(1 151 113 228 206 52 210 1 22),
784            row!(16 163 132 69 22 243 3 163 127),
785            row!(18 173 114 176 134 0 53 99 49),
786            row!(25 139 168 102 161 270 167 98 125),
787            row!(65 0 0 0 0 0 0 0 0),
788        ],
789        // i = 44
790        vec![
791            row!(0 139 80 234 84 18 79 4 191),
792            row!(7 157 78 227 4 0 244 6 211),
793            row!(9 163 163 259 9 0 293 142 187),
794            row!(22 173 274 260 12 57 272 3 148),
795            row!(66 0 0 0 0 0 0 0 0),
796        ],
797        // i = 45
798        vec![
799            row!(1 149 135 101 184 168 82 181 177),
800            row!(6 151 149 228 121 0 67 45 114),
801            row!(10 167 15 126 29 144 235 153 93),
802            row!(67 0 0 0 0 0 0 0 0),
803        ],
804    ]
805}
806
807// TS 38.212 Table 5.3.2-3
808fn base_graph_2() -> [Vec<VijRow>; 42] {
809    [
810        // i = 0
811        vec![
812            row!(0 9 174 0 72 3 156 143 145),
813            row!(1 117 97 0 110 26 143 19 131),
814            row!(2 204 166 0 23 53 14 176 71),
815            row!(3 26 66 0 181 35 3 165 21),
816            row!(6 189 71 0 95 115 40 196 23),
817            row!(9 205 172 0 8 127 123 13 112),
818            row!(10 0 0 0 1 0 0 0 1),
819            row!(11 0 0 0 0 0 0 0 0),
820        ],
821        // i = 1
822        vec![
823            row!(0 167 27 137 53 19 17 18 142),
824            row!(3 166 36 124 156 94 65 27 174),
825            row!(4 253 48 0 115 104 63 3 183),
826            row!(5 125 92 0 156 66 1 102 27),
827            row!(6 226 31 88 115 84 55 185 96),
828            row!(7 156 187 0 200 98 37 17 23),
829            row!(8 224 185 0 29 69 171 14 9),
830            row!(9 252 3 55 31 50 133 180 167),
831            row!(11 0 0 0 0 0 0 0 0),
832            row!(12 0 0 0 0 0 0 0 0),
833        ],
834        // i = 2
835        vec![
836            row!(0 81 25 20 152 95 98 126 74),
837            row!(1 114 114 94 131 106 168 163 31),
838            row!(3 44 117 99 46 92 107 47 3),
839            row!(4 52 110 9 191 110 82 183 53),
840            row!(8 240 114 108 91 111 142 132 155),
841            row!(10 1 1 1 0 1 1 1 0),
842            row!(12 0 0 0 0 0 0 0 0),
843            row!(13 0 0 0 0 0 0 0 0),
844        ],
845        // i = 3
846        vec![
847            row!(1 8 136 38 185 120 53 36 239),
848            row!(2 58 175 15 6 121 174 48 171),
849            row!(4 158 113 102 36 22 174 18 95),
850            row!(5 104 72 146 124 4 127 111 110),
851            row!(6 209 123 12 124 73 17 203 159),
852            row!(7 54 118 57 110 49 89 3 199),
853            row!(8 18 28 53 156 128 17 191 43),
854            row!(9 128 186 46 133 79 105 160 75),
855            row!(10 0 0 0 1 0 0 0 1),
856            row!(13 0 0 0 0 0 0 0 0),
857        ],
858        // i = 4
859        vec![
860            row!(0 179 72 0 200 42 86 43 29),
861            row!(1 214 74 136 16 24 67 27 140),
862            row!(11 71 29 157 101 51 83 117 180),
863            row!(14 0 0 0 0 0 0 0 0),
864        ],
865        // i = 5
866        vec![
867            row!(0 231 10 0 185 40 79 136 121),
868            row!(1 41 44 131 138 140 84 49 41),
869            row!(5 194 121 142 170 84 35 36 169),
870            row!(7 159 80 141 219 137 103 132 88),
871            row!(11 103 48 64 193 71 60 62 207),
872            row!(15 0 0 0 0 0 0 0 0),
873        ],
874        // i = 6
875        vec![
876            row!(0 155 129 0 123 109 47 7 137),
877            row!(5 228 92 124 55 87 154 34 72),
878            row!(7 45 100 99 31 107 10 198 172),
879            row!(9 28 49 45 222 133 155 168 124),
880            row!(11 158 184 148 209 139 29 12 56),
881            row!(16 0 0 0 0 0 0 0 0),
882        ],
883        // i = 7
884        vec![
885            row!(1 129 80 0 103 97 48 163 86),
886            row!(5 147 186 45 13 135 125 78 186),
887            row!(7 140 16 148 105 35 24 143 87),
888            row!(11 3 102 96 150 108 47 107 172),
889            row!(13 116 143 78 181 65 55 58 154),
890            row!(17 0 0 0 0 0 0 0 0),
891        ],
892        // i = 8
893        vec![
894            row!(0 142 118 0 147 70 53 101 176),
895            row!(1 94 70 65 43 69 31 177 169),
896            row!(12 230 152 87 152 88 161 22 225),
897            row!(18 0 0 0 0 0 0 0 0),
898        ],
899        // i = 9
900        vec![
901            row!(1 203 28 0 2 97 104 186 167),
902            row!(8 205 132 97 30 40 142 27 238),
903            row!(10 61 185 51 184 24 99 205 48),
904            row!(11 247 178 85 83 49 64 81 68),
905            row!(19 0 0 0 0 0 0 0 0),
906        ],
907        // i = 10
908        vec![
909            row!(0 11 59 0 174 46 111 125 38),
910            row!(1 185 104 17 150 41 25 60 217),
911            row!(6 0 22 156 8 101 174 177 208),
912            row!(7 117 52 20 56 96 23 51 232),
913            row!(20 0 0 0 0 0 0 0 0),
914        ],
915        // i = 11
916        vec![
917            row!(0 11 32 0 99 28 91 39 178),
918            row!(7 236 92 7 138 30 175 29 214),
919            row!(9 210 174 4 110 116 24 35 168),
920            row!(13 56 154 2 99 64 141 8 51),
921            row!(21 0 0 0 0 0 0 0 0),
922        ],
923        // i = 12
924        vec![
925            row!(1 63 39 0 46 33 122 18 124),
926            row!(3 111 93 113 217 122 11 155 122),
927            row!(11 14 11 48 109 131 4 49 72),
928            row!(22 0 0 0 0 0 0 0 0),
929        ],
930        // i = 13
931        vec![
932            row!(0 83 49 0 37 76 29 32 48),
933            row!(1 2 125 112 113 37 91 53 57),
934            row!(8 38 35 102 143 62 27 95 167),
935            row!(13 222 166 26 140 47 127 186 219),
936            row!(23 0 0 0 0 0 0 0 0),
937        ],
938        // i = 14
939        vec![
940            row!(1 115 19 0 36 143 11 91 82),
941            row!(6 145 118 138 95 51 145 20 232),
942            row!(11 3 21 57 40 130 8 52 204),
943            row!(13 232 163 27 116 97 166 109 162),
944            row!(24 0 0 0 0 0 0 0 0),
945        ],
946        // i = 15
947        vec![
948            row!(0 51 68 0 116 139 137 174 38),
949            row!(10 175 63 73 200 96 103 108 217),
950            row!(11 213 81 99 110 128 40 102 157),
951            row!(25 0 0 0 0 0 0 0 0),
952        ],
953        // i = 16
954        vec![
955            row!(1 203 87 0 75 48 78 125 170),
956            row!(9 142 177 79 158 9 158 31 23),
957            row!(11 8 135 111 134 28 17 54 175),
958            row!(12 242 64 143 97 8 165 176 202),
959            row!(26 0 0 0 0 0 0 0 0),
960        ],
961        // i = 17
962        vec![
963            row!(1 254 158 0 48 120 134 57 196),
964            row!(5 124 23 24 132 43 23 201 173),
965            row!(11 114 9 109 206 65 62 142 195),
966            row!(12 64 6 18 2 42 163 35 218),
967            row!(27 0 0 0 0 0 0 0 0),
968        ],
969        // i = 18
970        vec![
971            row!(0 220 186 0 68 17 173 129 128),
972            row!(6 194 6 18 16 106 31 203 211),
973            row!(7 50 46 86 156 142 22 140 210),
974            row!(28 0 0 0 0 0 0 0 0),
975        ],
976        // i = 19
977        vec![
978            row!(0 87 58 0 35 79 13 110 39),
979            row!(1 20 42 158 138 28 135 124 84),
980            row!(10 185 156 154 86 41 145 52 88),
981            row!(29 0 0 0 0 0 0 0 0),
982        ],
983        // i = 20
984        vec![
985            row!(1 26 76 0 6 2 128 196 117),
986            row!(4 105 61 148 20 103 52 35 227),
987            row!(11 29 153 104 141 78 173 114 6),
988            row!(30 0 0 0 0 0 0 0 0),
989        ],
990        // i = 21
991        vec![
992            row!(0 76 157 0 80 91 156 10 238),
993            row!(8 42 175 17 43 75 166 122 13),
994            row!(13 210 67 33 81 81 40 23 11),
995            row!(31 0 0 0 0 0 0 0 0),
996        ],
997        // i = 22
998        vec![
999            row!(1 222 20 0 49 54 18 202 195),
1000            row!(2 63 52 4 1 132 163 126 44),
1001            row!(32 0 0 0 0 0 0 0 0),
1002        ],
1003        // i = 23
1004        vec![
1005            row!(0 23 106 0 156 68 110 52 5),
1006            row!(3 235 86 75 54 115 132 170 94),
1007            row!(5 238 95 158 134 56 150 13 111),
1008            row!(33 0 0 0 0 0 0 0 0),
1009        ],
1010        // i = 24
1011        vec![
1012            row!(1 46 182 0 153 30 113 113 81),
1013            row!(2 139 153 69 88 42 108 161 19),
1014            row!(9 8 64 87 63 101 61 88 130),
1015            row!(34 0 0 0 0 0 0 0 0),
1016        ],
1017        // i = 25
1018        vec![
1019            row!(0 228 45 0 211 128 72 197 66),
1020            row!(5 156 21 65 94 63 136 194 95),
1021            row!(35 0 0 0 0 0 0 0 0),
1022        ],
1023        // i = 26
1024        vec![
1025            row!(2 29 67 0 90 142 36 164 146),
1026            row!(7 143 137 100 6 28 38 172 66),
1027            row!(12 160 55 13 221 100 53 49 190),
1028            row!(13 122 85 7 6 133 145 161 86),
1029            row!(36 0 0 0 0 0 0 0 0),
1030        ],
1031        // i = 27
1032        vec![
1033            row!(0 8 103 0 27 13 42 168 64),
1034            row!(6 151 50 32 118 10 104 193 181),
1035            row!(37 0 0 0 0 0 0 0 0),
1036        ],
1037        // i = 28
1038        vec![
1039            row!(1 98 70 0 216 106 64 14 7),
1040            row!(2 101 111 126 212 77 24 186 144),
1041            row!(5 135 168 110 193 43 149 46 16),
1042            row!(38 0 0 0 0 0 0 0 0),
1043        ],
1044        // i = 29
1045        vec![
1046            row!(0 18 110 0 108 133 139 50 25),
1047            row!(4 28 17 154 61 25 161 27 57),
1048            row!(39 0 0 0 0 0 0 0 0),
1049        ],
1050        // i = 30
1051        vec![
1052            row!(2 71 120 0 106 87 84 70 37),
1053            row!(5 240 154 35 44 56 173 17 139),
1054            row!(7 9 52 51 185 104 93 50 221),
1055            row!(9 84 56 134 176 70 29 6 17),
1056            row!(40 0 0 0 0 0 0 0 0),
1057        ],
1058        // i = 31
1059        vec![
1060            row!(1 106 3 0 147 80 117 115 201),
1061            row!(13 1 170 20 182 139 148 189 46),
1062            row!(41 0 0 0 0 0 0 0 0),
1063        ],
1064        // i = 32
1065        vec![
1066            row!(0 242 84 0 108 32 116 110 179),
1067            row!(5 44 8 20 21 89 73 0 14),
1068            row!(12 166 17 122 110 71 142 163 116),
1069            row!(42 0 0 0 0 0 0 0 0),
1070        ],
1071        // i = 33
1072        vec![
1073            row!(2 132 165 0 71 135 105 163 46),
1074            row!(7 164 179 88 12 6 137 173 2),
1075            row!(10 235 124 13 109 2 29 179 106),
1076            row!(43 0 0 0 0 0 0 0 0),
1077        ],
1078        // i = 34
1079        vec![
1080            row!(0 147 173 0 29 37 11 197 184),
1081            row!(12 85 177 19 201 25 41 191 135),
1082            row!(13 36 12 78 69 114 162 193 141),
1083            row!(44 0 0 0 0 0 0 0 0),
1084        ],
1085        // i = 35
1086        vec![
1087            row!(1 57 77 0 91 60 126 157 85),
1088            row!(5 40 184 157 165 137 152 167 225),
1089            row!(11 63 18 6 55 93 172 181 175),
1090            row!(45 0 0 0 0 0 0 0 0),
1091        ],
1092        // i = 36
1093        vec![
1094            row!(0 140 25 0 1 121 73 197 178),
1095            row!(2 38 151 63 175 129 154 167 112),
1096            row!(7 154 170 82 83 26 129 179 106),
1097            row!(46 0 0 0 0 0 0 0 0),
1098        ],
1099        // i = 37
1100        vec![
1101            row!(10 219 37 0 40 97 167 181 154),
1102            row!(13 151 31 144 12 56 38 193 114),
1103            row!(47 0 0 0 0 0 0 0 0),
1104        ],
1105        // i = 38
1106        vec![
1107            row!(1 31 84 0 37 1 112 157 42),
1108            row!(5 66 151 93 97 70 7 173 41),
1109            row!(11 38 190 19 46 1 19 191 105),
1110            row!(48 0 0 0 0 0 0 0 0),
1111        ],
1112        // i = 39
1113        vec![
1114            row!(0 239 93 0 106 119 109 181 167),
1115            row!(7 172 132 24 181 32 6 157 45),
1116            row!(12 34 57 138 154 142 105 173 189),
1117            row!(49 0 0 0 0 0 0 0 0),
1118        ],
1119        // i = 40
1120        vec![
1121            row!(2 0 103 0 98 6 160 193 78),
1122            row!(10 75 107 36 35 73 156 163 67),
1123            row!(13 120 163 143 36 102 82 179 180),
1124            row!(50 0 0 0 0 0 0 0 0),
1125        ],
1126        // i = 41
1127        vec![
1128            row!(1 129 147 0 120 48 132 191 53),
1129            row!(5 229 7 2 101 47 6 197 215),
1130            row!(11 118 60 55 81 19 8 167 230),
1131            row!(51 0 0 0 0 0 0 0 0),
1132        ],
1133    ]
1134}