1
0
Fork 0
A collection of algorithms implemented in OCaml.
Ir para arquivo
Frédéric Bour 60dfaff175 Add binder introducer 2022-04-01 16:21:30 +09:00
balmap rename grenier_balmap to balmap 2021-03-30 12:10:22 +02:00
baltree emergency fix in baltree 2019-06-10 12:39:52 +02:00
biarray implement Biarray 2020-03-04 10:29:48 +01:00
binder_introducer Add binder introducer 2022-04-01 16:21:30 +09:00
binpacking Fix warnings and update tests 2020-11-24 09:23:29 +01:00
countish add approximate frequency counts poc, inspired by https://github.com/shanemhansen/countish 2017-06-23 13:33:21 +02:00
dbseq Document dbseq 2021-03-30 11:48:26 +02:00
doc documentation index 2016-10-05 16:17:56 +02:00
doubledouble Doubledouble: disable FMADD 2021-12-16 10:42:30 +01:00
fastdom Add fastdom 2021-12-15 14:21:54 +01:00
hll jbuild -> dune 2019-06-10 12:19:50 +02:00
jmphash jbuild -> dune 2019-06-10 12:19:50 +02:00
orderme jbuild -> dune 2019-06-10 12:19:50 +02:00
physh Require OCaml >= 4.04 2020-01-27 10:03:44 +01:00
state_elimination Update state elimination tests 2020-11-24 09:23:29 +01:00
strong Strong.Finite.Set.Gensym: add prophesized sets 2020-11-27 12:17:56 +01:00
trope jbuild -> dune 2019-06-10 12:19:50 +02:00
valmari Fix bugs in valmari 2021-12-15 15:42:08 +01:00
.gitignore Port everything to dune 2018-06-16 19:09:58 +02:00
.travis.yml Add missing (but supported) versions of OCaml to the CI 2020-02-26 17:10:09 +01:00
CHANGES.md Add binder introducer 2022-04-01 16:21:30 +09:00
LICENSE switch license to ISC 2016-10-05 15:11:38 +02:00
Makefile jbuild -> dune 2019-06-10 12:19:50 +02:00
README.md Add binder introducer 2022-04-01 16:21:30 +09:00
TODO Update TODO 2020-03-04 10:30:15 +01:00
dune-project remove META, jbuilder -> dune 2019-09-17 12:03:56 +02:00
grenier.opam Update opam file 2021-03-30 14:12:07 +02:00

README.md

grenier — A collection of various algorithms in OCaml.

Licensed under ISC license.

baltree : Generic balanced-tree

A binary tree with smart constructors that ensure the resulting tree is balanced.

This data structure can be used as a primitive on top of which one can easily build balanced data structures, including but not limited to binary search trees.

For instance, implementing stdlib-like Set/Map is trivial and suffers only a ~5 % overhead (and one gains a O(1) length/cardinal operation).

balmap : Alternative to Map & Set implemented on top of baltree

These two modules can be used as a drop-in replacement for Map and Set. The performance characteristics are slightly different: cardinal is now O(1), some operations use that as a shortcut (compare, subset, ...).

In addition, the representation is exposed (the internal structure of the tree can be pattern matched). It is protected by a private modifier, such that invariants cannot be broken. However, custom operations are much easier to implement (e.g. rank to access the n'th element, which enables uniform sampling in O(log n)).

binder introducer: transform graphs into trees by introducing binding nodes

A generic algorithm that turns a directed graph intro a tree. It finds where binding nodes should be introduced to make the resulting tree readable. The idea is described in this blog post.

For instance, this is useful to print cyclic values (see Cmon).

dbseq: fast sequence datastructure for DeBruijn-indexed environments

Dbseq is a small data structure that offers operations halfway between a list and an immutable array. Most operations have a logarithmic cost. In practice, it is a log with base 4 and small constant factors.

The name comes from the fact that the data structure is particularly suitable to associate metadata to variables in De-Bruijn notation when traversing terms.

trope : Track objects accross rope-like operations

This data structure allows efficient implementation of text markers for text editors (see Emacs Markers).

More generally it allows to track the movement of objects on a line where chunks are added and removed, with queries O(log n) amortized time.

Finally, it is persistent so you easily compare markers movement between different revisions.

orderme : Order-maintenance problem

See Order-maintenance problem for a detailed description of what this intent to solve.

Main algorithm follows the amortized solution from "Two Simplified Algorithms for Maintaining Order in a List", Michael A. Bender, Richard Cole, Erik D. Demaine, Martín Farach-Colton, and Jack Zito.

A managed implementation provide finer integration with OCaml GC to collect items that are no longer reachable via the public API.

binpacking : Maxrects rectangle packing implementation

An implementation of Maxrects packing algorithm in 2D. This algorithm try to pack a maximum number of 2d boxes inside a 2d rectangle.

See Even More Rectangle Bin Packing

Useful for generating spritesheets, texture atlases, etc.

doubledouble : Floating points with around 107-bits precision

An implementation of double-double arithmetic.

Code is translated from DD by Martin Davis. See tsusiatsoftware for more information.

hll : HyperLogLog

An implementation of the HyperLogLog probabilistic cardinality estimator. See HyperLogLog.

jmphash : Jump consistent hashing

An implementation of "A Fast, Minimal Memory, Consistent Hash Algorithm" from John Lamping and Eric Veach.

physh : Physical hashtable

Hashtables indexing OCaml values by their physical indentities. A proof-of-concept, playing with the GC in tricky ways.

Its main purpose is to efficiently observe sharing, detect cycles, etc, in arbitrary OCaml values without having to stop and stay out of the OCaml runtime.

Can be used to experiment and learn about the GC but do expect bugs and don't expect any kind of compatibility with future OCaml versions. (Would be nice to have proper upstream support for such feature though!)

state elimination : convert an e-nfa to a regex

This library converts e-NFA (including NFA and DFA) to regular expressions.

Unfortunately the regular expression is often of exponential size, unless you extend the language to allow sharing sub-expressions (for instance with let binders).

strong : Some strongly typed primitives (typed equality, ordering, finite sets)

This library defines a few strongly typed idioms that are sometimes useful in OCaml codebase:

  • type-level equality and ordering
  • unhabitated type
  • an encoding of type-level naturals
  • finite sets (the set of numbers less than a given constant)

valmari : Valmari's DFA minimization algorithm

An implementation of the algorithm desribed in Fast brief practical DFA minimization by Valmari et al.

The tests and some fixes come from WalkerCodeRanger/dfaMinimizationComparison, thanks!

fastdom

An implementation of A Simple, Fast Dominance Algorithm by Keith D. Cooper, Timothy J. Harvey, and Ken Kennedy.