Giter Site home page Giter Site logo

arugula's Introduction

arugula

This is a small C++ lattice library using expression templates. The basic template of a lattice is Lattice<T, Func> where T is some C++ type, and Func is a functor to do the lattice join (i.e. merge) operation, which is represented as operator+() (or operator+=).

Given this structure, most of the logic is in the merge functors in include/merges.

A simple example

For example, the code below builds two lattices lefts and rights. Each has the C++ type is Lattice<std::set<int>, Union, or in mathematical terms a join semi-lattice (P(Z), U).

  std::set<int> lefts({1, 20, 30});
  std::set<int> rights({1, 2, 3});

  Lattice ls(lefts, Union{});
  Lattice rs(rights, Union{});

  Lattice<std::set<int>, Union> expr = ls + rs;

Lattice composition

The test/smoke directory shows many more examples of how to build lattices using standard C++ types and the merge functors. Among the more interesting examples are lattices composed of other lattices, e.g. in include/merges/vector_clock_mrg.h:

using VectorClock = Lattice<std::map<std::string, Lattice<unsigned, Max> >, MapUnion>;

A VectorClock is a Lattice based on a map data structure, where the key is a std::string, and the value is a nested lattice (of unsigned under Max). The merge function for map lattices recursively merges the values using the type of the nested lattice.

You can of course compose the VectorClock lattice into a superlattice, e.g. for causality tracking as shown in the test directory.

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.