Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ULDT-Codec: Exact Unimodular Lattice Decorrelation Transform

License: MIT Python 3.8+

ULDT-Codec is an open-source lossless multi-channel compression library powered by Exact Unimodular Lattice Decorrelation (ULDT). It bridges algebraic number theory and multi-channel signal compression using Lenstra–Lenstra–Lovász (LLL) lattice basis reduction over the unimodular group $GL(d, \mathbb{Z})$.


1. The Core Innovation

General-purpose archivers (7-Zip, Zstandard, gzip) and audio codecs (FLAC, ALAC, WavPack) compress multi-channel data along one dimension at a time:

  • FLAC/ALAC: Run 1D temporal linear prediction (LPC) per channel independently (or 2-channel $L \pm R$ Mid/Side).
  • Blosc/HDF5: Use byte-shuffling to transpose arrays, but apply zero cross-channel algebraic decorrelation.
  • Continuous PCA / KLT: Finds optimal orthogonal rotation matrices $V \in O(d, \mathbb{R})$, but requires lossy quantization because real matrix multiplication destroys bit-for-bit invertibility.

How ULDT Solves This

ULDT maps empirical cross-channel covariance minimization to Euclidean lattice basis reduction:

  1. It computes the Cholesky factor $L$ of the empirical covariance matrix $\Sigma = L L^T$.
  2. It uses the LLL algorithm to discover an optimal integer transformation matrix $U \in GL(d, \mathbb{Z})$ satisfying $\det(U) \in {-1, +1}$.
  3. Because $\det(U) = \pm 1$, the inverse matrix $U^{-1} = \pm \text{adj}(U)$ consists strictly of pure integers with zero fractional division.
  4. Both forward transformation $\mathbf{y} = U \mathbf{x}$ and reconstruction $\mathbf{x} = U^{-1} \mathbf{y}$ are exact algebraic automorphisms on $\mathbb{Z}^d$, achieving up to 36.8% smaller compressed sizes than FLAC and 7-Zip with 100% bit-for-bit SHA-256 validation.

2. Benchmark Matrix

Dataset Domain Uncompressed Raw LZMA-9 FLAC Delta-2 + LZMA ULDT Codec ULDT vs Best Competitor SHA-256
6D Flight IMU Telemetry 240,000 B 108,300 B 107,140 B 82,198 B -24,942 B (+23.28%) 100% Match
Financial Order Book (4-Level) 240,000 B 35,096 B 34,732 B 21,924 B -12,808 B (+36.88%) 100% Match
4-Mass Mechanical Mesh 144,000 B 62,260 B 46,336 B 48,492 B -4.65% (FLAC won) 100% Match
Uniform Random Noise 65,536 B 65,600 B 65,600 B 65,680 B Bounded Pass-through 100% Match

3. Installation

git clone https://github.com/ononymuos/uldt-codec.git
cd uldt-codec
pip install -r requirements.txt

4. Quickstart

Python API

import numpy as np
from uldt import ULDTCodec

# Multi-channel integer matrix of shape (d, N)
# e.g., 6 channels (accelerometer + gyroscope) with 10,000 time steps
X = np.random.randint(-1000, 1000, size=(6, 10000), dtype=np.int32)

# Compress to minimal ULDT payload
payload = ULDTCodec.encode_channels(X)
print(f"Original: {X.nbytes:,} bytes -> ULDT: {len(payload):,} bytes")

# Decompress bit-for-bit exact copy
reconstructed = ULDTCodec.decode_payload(payload)
assert np.array_equal(X, reconstructed)
print("100% bit-for-bit SHA-256 identical.")

Command-Line Interface (CLI)

# Compress 4-channel interleaved binary data
python3 -m uldt.cli compress telemetry.bin telemetry.uldt -d 4 --dtype int32

# Decompress back to original binary
python3 -m uldt.cli decompress telemetry.uldt reconstructed.bin

5. Mathematical References

  1. Lenstra, A. K., Lenstra, H. W., & Lovász, L. (1982). Factoring polynomials with rational coefficients. Mathematische Annalen, 261(4), 515-534.
  2. Shannon, C. E. (1948). A Mathematical Theory of Communication. Bell System Technical Journal, 27(3), 379-423.
  3. Minkowski, H. (1896). Geometrie der Zahlen. Teubner, Leipzig.

License

MIT License. Copyright (c) 2026 Usama Baig.

About

Exact Unimodular Lattice Decorrelation Transform for Lossless Multi-Channel Compression

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages