linear-code: A simple library for linear codes (coding theory, error correction)

[ gpl, library, math ] [ Propose Tags ]

Please see the README on GitHub at https://github.com/wchresta/linear-code#readme


[Skip to Readme]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0, 0.1.1, 0.2.0
Change log ChangeLog.md
Dependencies base (>=4.7 && <5), combinat, containers, data-default, ghc-typelits-knownnat, ghc-typelits-natnormalise, HaskellForMaths, matrix, random [details]
License GPL-3.0-only
Copyright 2018, Wanja Chresta
Author Wanja Chresta
Maintainer wanja dot hs at chrummibei dot ch
Revised Revision 1 made by wchresta at 2018-08-03T16:07:02Z
Category Math
Home page https://github.com/wchresta/linear-code#readme
Bug tracker https://github.com/wchresta/linear-code/issues
Source repo head: git clone https://github.com/wchresta/linear-code
Uploaded by wchresta at 2018-08-03T14:52:06Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 1595 total (8 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user [build log]
All reported builds failed as of 2018-08-03 [all 2 reports]

Readme for linear-code-0.1.0

[back to package description]

linear-code

Library to handle linear codes from coding theory.

The library is designed to carry the most important bits of information in the type system while still keeping the types sane.

This library is based roughly on Introduction to Coding Theory by Yehuda Lindell

Usage example

Working with random codes

> :m + Math.Code.Linear System.Random
> :set -XDataKinds
> c <- randomIO :: IO (LinearCode 7 4 F5)
> c
[7,4]_5-Code
> generatorMatrix c
( 1 0 1 0 0 2 0 )
( 0 2 0 0 1 2 0 )
( 0 1 0 1 0 1 0 )
( 1 0 0 0 0 1 1 )
> e1 :: Vector 4 F5
( 1 0 0 0 )
> v = encode c e1
> v
( 1 0 1 0 0 2 0 )
> 2 ^* e4 :: Vector 7 F3
( 0 0 0 2 0 0 0 )
> vWithError = v + 2 ^* e4
> vWithError
( 1 0 1 2 0 2 0 )
> isCodeword c v
True
> isCodeword c vWithError
False
> decode c vWithError
Just ( 1 0 2 2 2 2 0 )

Notice, the returned vector is NOT the one without error. The reason for this is that a random code most likely does not have a distance >2 which would be needed to correct one error. Let's try with a hamming code

Correcting errors with hamming codes

> c = hamming :: BinaryCode 7 4
> generatorMatrix c
( 1 1 0 1 0 0 0 )
( 1 0 1 0 1 0 0 )
( 0 1 1 0 0 1 0 )
( 1 1 1 0 0 0 1 )
> v = encode c e2
> vWithError = v + e3
> Just v' = decode c vWithError
> v' == v
True