CarlKenner/cnl

A Compositional Numeric Library for C++

★ 0Forks 0GitHub ↗Compare

README

Compositional Numeric Library

Build Status Build status CircleCI Join the chat at https://gitter.im/cppcnl/community

The Compositional Numeric Library (CNL) is a C++ library of fixed-precision numeric classes which enhance integers to deliver safer, simpler, cheaper arithmetic types. Documentation can be found here.

Requirements

Linux

Compiled on x86-64 and armv7. Tested on x86-86 using Travis and CircleCI.

Requires:

Windows

Tested on AppVeyor and on Windows 10 Professional with CMake 3.8.0.

Requires:

  • MSBuild 15.0 (VS 2017)
  • CMake 3.8.0

Instructions

Download

The library is hosted on GitHub:

git clone https://github.com/johnmcfarlane/cnl.git
cd cnl

Build

The CNL library is comprised of headers found in the src directory. CMake scripts are provided.

To build and install CNL on your system:

mkdir build && cd build
cmake ..
cmake --build . --target install

Test

The test suite uses CMake and depends on Google Test and Google Benchmark. Optional integration tests use Boost.Multiprecision and Boost.SIMD.

  1. Conan can be used to pull in essential dependencies:

    conan remote add --force johnmcfarlane/cnl https://api.bintray.com/conan/johnmcfarlane/cnl
    conan profile new --detect --force default
    conan profile update settings.compiler.libcxx=libstdc++11 default
    conan install --build=missing ..
  2. Configure the project for development

    cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PROJECT_cnl_INCLUDE:FILEPATH="$(pwd)"/conan_paths.cmake ..
  3. Build tests:

    cmake --build . --target test-all
  4. Run tests:

    ctest -R test-unit
  5. Run benchmarks:

    ctest -R test-benchmark

Additional build system generation options:

  1. To describe CNL build options:

    cmake -LH ..

  2. Then to apply an option, e.g. to disabled exceptions:

    cmake -DCNL_EXCEPTIONS=OFF ..

Integration

The API is exposed through headers in the include directory. Add this to your system header list and include, e.g.:

// to use a specific type:
#include <cnl/scaled_integer.h>

// or to include all CNL types:
#include <cnl/all.h>

Example Projects

Examples of projects using CNL:

  • CDSP - Compositional DSP Library for C++;
  • BrewBlox firmware - firmware for a brewery controller
  • cnl_example - minimal CMake-based project which uses CNL as a dependency.

Further Reading

Contact Information

All feedback greatly appreciated.

Developed with CLion: A Cross-Platform IDE for C and C++ by JetBrains.

Contributors

johnmcfarlanehbe72Elcquidtorfinnbersetselavykeryellsethmlgitter-badger

Issues