Compositional Numeric Library
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
CNL requires a C++11-compatible tool chain and is tested on the following systems:
Linux
Tested:
- GCC 5 - 10 / Clang 5 - 11
- CMake 3.5.1
OS X
Tested:
- GCC 10
- CMake 3.5.1
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.
-
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 ..
-
Configure the project for development
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PROJECT_cnl_INCLUDE:FILEPATH="$(pwd)"/conan_paths.cmake ..
-
Build tests:
cmake --build . --target test-all
-
Run tests:
ctest -R test-unit
-
Run benchmarks:
ctest -R test-benchmark
Additional build system generation options:
-
To describe CNL build options:
cmake -LH ..
-
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
- CNL documentation
- CppCon 2017 presentation
- Embedded Artistry article
- ISO C++ papers:
Contact Information
All feedback greatly appreciated.