LDPC codes with belief propagation decoding
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocaml-linkedin: apply dune fmt

Pure formatting changes from `dune fmt`: doc comment placement moves
from above the binding to below it for `type`s, multi-line `match`
expressions collapse onto one line where they fit, and infix operator
applications pick up spaces (`Soup.($?)` -> `Soup.( $? )`). No
semantic changes.

+74 -1
+66
README.md
··· 1 + # ldpc 2 + 3 + Low-Density Parity-Check codes with belief propagation decoding. 4 + 5 + `ldpc` implements the CCSDS [131.0-B-4][ccsds] AR4JA 6 + (Accumulate-Repeat-4-Jagged-Accumulate) family: circulant-based 7 + parity-check matrices, systematic encoding, and sum-product belief 8 + propagation decoding. Ships with the `rate_1_2` preset (k=1024 9 + information bits, n=2048 transmitted bits) used on near-Earth and 10 + deep-space links. 11 + 12 + [ccsds]: https://public.ccsds.org/Pubs/131x0b4.pdf 13 + 14 + ## Installation 15 + 16 + Install with opam: 17 + 18 + <!-- $MDX skip --> 19 + ```sh 20 + $ opam install ldpc 21 + ``` 22 + 23 + If opam cannot find the package, it may not yet be released in the 24 + public `opam-repository`. Add the overlay repository, then install 25 + it: 26 + 27 + <!-- $MDX skip --> 28 + ```sh 29 + $ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git 30 + $ opam update 31 + $ opam install ldpc 32 + ``` 33 + 34 + ## Usage 35 + 36 + The rate-1/2 code takes `k/8 = 128` data bytes and emits `n/8 = 256` 37 + codeword bytes: 38 + 39 + ```ocaml 40 + # let data = Bytes.make 128 '\x5a' in 41 + let codeword = Ldpc.encode Ldpc.ccsds_rate_1_2 data in 42 + Bytes.length codeword 43 + - : int = 256 44 + ``` 45 + 46 + Belief-propagation decoding recovers the data from a corrupted 47 + codeword. `max_iter` caps the number of sum-product iterations 48 + (default 50): 49 + 50 + ```ocaml 51 + # let data = Bytes.make 128 '\x5a' in 52 + let codeword = Ldpc.encode Ldpc.ccsds_rate_1_2 data in 53 + (* Flip a handful of bits. *) 54 + for i = 0 to 7 do 55 + Bytes.set_uint8 codeword (i * 17) 56 + (Bytes.get_uint8 codeword (i * 17) lxor 0x80) 57 + done; 58 + match Ldpc.decode ~max_iter:50 Ldpc.ccsds_rate_1_2 codeword with 59 + | Ok recovered -> Bytes.equal recovered data 60 + | Error _ -> false 61 + - : bool = true 62 + ``` 63 + 64 + ## Licence 65 + 66 + ISC
+4
dune
··· 1 1 (env 2 2 (dev 3 3 (flags :standard %{dune-warnings}))) 4 + 5 + (mdx 6 + (files README.md) 7 + (libraries ldpc))
+3 -1
dune-project
··· 1 1 (lang dune 3.21) 2 + (using mdx 0.4) 2 3 (name ldpc) 3 4 (generate_opam_files true) 4 5 (license ISC) ··· 16 17 (ocaml (>= 5.1)) 17 18 (alcotest :with-test) 18 19 (alcobar :with-test) 19 - fmt)) 20 + fmt 21 + (mdx :with-test)))
+1
ldpc.opam
··· 15 15 "alcotest" {with-test} 16 16 "alcobar" {with-test} 17 17 "fmt" 18 + "mdx" {with-test} 18 19 "odoc" {with-doc} 19 20 ] 20 21 build: [