GithubHelp home page GithubHelp logo

gattocrucco / uncertainties-cpp Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 2.0 285 KB

C++ header library for first- and second-order uncertainty propagation

Home Page: http://www.giacomopetrillo.com/software/uncertainties-cpp/doc/html

License: GNU Lesser General Public License v3.0

Makefile 0.44% C++ 87.34% Python 12.22%
cpp cpp11 uncertainty-propagation error-propagation uncertainties physics statistics

uncertainties-cpp's Introduction

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).

Installation

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.

Requirements

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.

Usage

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:

#include <iostream>
#include <uncertainties/ureal.hpp>
#include <uncertainties/io.hpp>
#include <uncertainties/impl.hpp>
namespace unc = uncertainties;
int main() {
    unc::udouble x(2, 1), y(2, 1);
    unc::udouble a = x - x;
    unc::udouble b = x - y;
    std::cout << a << ", " << b << "\n";
}

Features

  • Clear distinction between mean estimation and bias correction for second-order propagation.

  • User-defined types supported.

  • Same class for independent and dependent variables.

  • First-order independent variables do not use the heap.

Note: complex numbers are not supported.

Technical details

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 linear transformations of independent variables. This software is not appropriate for efficient numerical calculation, but won't hang catastrophically.

Documentation

The documentation is here. Use doxygen in the doc directory to generate the documentation.

Tests

Use make in the directory test to compile and run all the tests.

License

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.

uncertainties-cpp's People

Contributors

gattocrucco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

morning-ye nsahoo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.