uncertainties-cpp
|
C++ header library for first- and second-order uncertainty propagation. More or less a port of the python packages uncertainties and soerp (but see also gvar and measurements.jl).
It is a header library so there is no need to compile and install a binary. Download the code from github, place the directory uncertainties
in a place of your choice (possibly alongside your code) and make sure to include the special header uncertainties/impl.hpp
in one (and only one) of your source files.
The C++ dialect is C++11. The header ureals.hpp
(not to be confused with ureal.hpp
) and the second-order propagation class require Eigen.
All the definitions are in the namespace uncertainties
. The library is split in various headers. For first-order propagation, the principal header is ureal.hpp
which defines the class template UReal
, which is aliased to udouble = UReal<double>
and ufloat = UReal<float>
. The header ureal2.hpp
defines the similar class UReal2
that does second-order propagation.
Basic example:
Note: complex numbers are not supported.
The gradients and hessians are computed with forward propagation. They are always sparse, implemented with C++ maps (trees), and can be updated in-place. Ab-initio covariance matrices are not supported, variables with arbitrary given correlations can be created as a linear transformations of independent variables. This software is not appropriate for efficient numerical calculation, but won't hang catastrophically.
The documentation is here. Use doxygen
in the doc
directory to generate the documentation.
Use make
in the directory test
to compile and run all the tests.
This software is released under the GNU Lesser General Public license v3.0, which means you can use it with differently licensed (eventually proprietary) software provided that you release under the GPL/LGPL any modifications to this library.