Documentation ¶
Overview ¶
Package ctw provides an implementation of the Context Tree Weighting algorithm. Also contained is an implementation of the Rissanen-Langdon Arithmetic Coding algorithm, which is combined with Context Tree Weighting to create a lossless compression/decompression utility.
Below is an example of using this package to compress Lincoln's Gettysburg address:
go run compress/main.go gettysburg.txt > gettys.ctw cat gettys.ctw | go run decompress/main.go > gettys.dctw diff gettysburg.txt gettys.dctw
Reference: F.M.J. Willems and Tj. J. Tjalkens, Complexity Reduction of the Context-Tree Weighting Algorithm: A Study for KPN Research, Technical University of Eindhoven, EIDMA Report RS.97.01.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compress ¶
(Compress) compresses the named file using arithmetic coding supplied with a Context Tree Weighting probabilistic model of depth <depth>. The compressed result is written to <w>.
func Decompress ¶
Decompress decompress a compressed stream of bytes generated by Compress. Decompress reads the compressed bytes from r, and writes the decompressed result to w. Decompress expects the same Context Tree Weighting depth used in Compress.
Types ¶
type CTW ¶
type CTW struct { Bits []int Root *treeNode }
A CTW is a Context Tree Weighting based probabilistic model for binary data. CTW implements the arithmetic coding Model interface.
func NewCTW ¶
NewCTW returns a new CTW whose context tree's depth is len(bits). The prior context of the tree is given by bits.
type CTWReverter ¶
type CTWReverter struct {
// contains filtered or unexported fields
}
A CTWReverter is a CTW model that allows reverting to its previous state. This is useful for predicting several steps ahead, while keeping the model's original state intact.
func NewCTWReverter ¶
func NewCTWReverter(model *CTW) *CTWReverter
func (*CTWReverter) Observe ¶
func (cr *CTWReverter) Observe(bit int)
func (*CTWReverter) Prob0 ¶
func (cr *CTWReverter) Prob0() float64
func (*CTWReverter) Unobserve ¶
func (cr *CTWReverter) Unobserve()
type FCTW ¶
An FCTW is a probabilistic model for structured binary data constructed from CTW models for each bit position within a block. FCTW implements the arithmetic coding Model interface
func NewFCTW ¶
NewFCTW returns a new FCTW whose context tree's depth is len(bits). The prior context of the trees is given by bits. The initial index position is len(bits) mod block_len.
Directories ¶
Path | Synopsis |
---|---|
Package ac defines the interfaces the arithmetic coding algorithm requires.
|
Package ac defines the interfaces the arithmetic coding algorithm requires. |
willems
Package willems implements the arithmetic coding algorithm described in Chapter 6.
|
Package willems implements the arithmetic coding algorithm described in Chapter 6. |
witten
Package witten implements the arithmetic coding algorithm described in Witten, Ian H.; Neal, Radford M.; Cleary, John G. (June 1987).
|
Package witten implements the arithmetic coding algorithm described in Witten, Ian H.; Neal, Radford M.; Cleary, John G. (June 1987). |
app
|
|