Skip to content
/ cnl Public
forked from johnmcfarlane/cnl

A Compositional Numeric Library for C++

License

Notifications You must be signed in to change notification settings

decaf-emu/cnl

 
 

Repository files navigation

Compositional Numeric Library

Test Join the chat at https://gitter.im/cppcnl/community Download

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

The latest version of CNL requires a C++20-compatible tool chain. (Version 1.x supports C++11.) CNL is tested on the following systems:

Linux

Tested:

  • GCC 5 - 10 / Clang 5 - 11
  • CMake 3.5.1

OS X

Tested:

Windows

Tested:

  • Visual Studio 2019 Version 16.7
  • 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 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.

About

A Compositional Numeric Library for C++

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 96.4%
  • C 1.4%
  • Other 2.2%