units
Use physical dimensions at compile-time or run-time.
units: Header-only C++ Library for Physical Quantities

The vnix::units library defines types and constants that can be used to model any quantity with physical dimension.

Continual Integration and Continually Generated Documentation

The github-site for units is connected to TravisCI, and thereby to CodeCov.

On each push to github, several actions are taken via TravisCI.

Overview of Library

In the present implementation, there are five fundamental dimensions:

Internally,

However, the user need not even know about dim and dimval. One may write a simple program, for example, as follows:

#include <vnix/units.hpp>
using namespace std;
using namespace vnix::units::flt; // or vnix::units::dbl or vnix::units::ldbl
int main() {
// Explicit namespace needed for 'time' in order to avoid collision with
// function in C standard library.
units::flt::time t = 4 * ms; // Multiplication of number by unit.
length d = 3.0_km; // Literal for unit.
speed v1 = d / t; // Dimension stored in type of v1.
dyndim v2 = d / t; // Dimension stored in instance of v2.
cout << v1 << endl;
return 0;
}

Some Details

Fetching, Building, and Installing

1 git clone https://github.com/tevaughan/units.git
2 cd units # Change the working directory into the new clone.
3 vim Makefile # Change PREFIX to specify installation-directory.
4 vim test/Makefile # Change CXX to set compiler.
5  # If Eigen be installed, change EIGEN_DIR to make sure
6  # that the Eigen-compatibility test is compiled and run.
7 make test # Build and run the tests.
8 make doc # Build the documentation via Doxygen.
9 make install # Install the headers to $(PREFIX)/include/vnix.

License

Copyright 2019 Thomas E. Vaughan; all rights reserved.

Distributed according to the terms of the BSD three-clause license; see LICENSE.