Giter Site home page Giter Site logo

permutation_compression's Introduction

permutation_compression

Rust

A Rust library to compress permutations.

// create a random permutation by shuffling
let mut rng = rand::thread_rng();
let mut data: Vec<u32> = (0..1_000_000_u32).collect();
data.shuffle(&mut rng);
let orig_perm = data.clone();

// compress the permutation
let compressed = compress_permutation(CompressionMode::Slow, data);

// recover the compressed permutation
let recovered = decompress_permutation(CompressionMode::Slow, &compressed);

assert_eq!(recovered, orig_perm);

The information-theoretic lower bound for compressing a permutation of size n is O(log2(n!)). In fast mode, we achieve O(n log n) compression using bitpacking. In slow mode, we remove another O(n).

On my personal hardware:

mode n compression time decompression time uncompressed size compressed size compression ratio
Fast 1M < 5ms < 5ms 4MB 2.5MB 1.595
Slow 1M 220ms 185ms 4MB 2.4MB 1.684

This code is available under the AGPL-3.0 license. See COPYING for more information.

permutation_compression's People

Contributors

ryanmarcus avatar

Stargazers

Mihail Stoian avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.