Giter Site home page Giter Site logo

aplaus228 / math Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stan-dev/math

0.0 1.0 0.0 392.55 MB

The Stan Math Library is a C++ template library for automatic differentiation of any order using forward, reverse, and mixed modes. It includes a range of built-in functions for probabilistic modeling, linear algebra, and equation solving.

Home Page: https://mc-stan.org

License: BSD 3-Clause "New" or "Revised" License

C++ 88.84% Makefile 0.09% Python 0.71% HTML 5.79% C 3.40% Perl 0.02% Batchfile 0.02% Shell 0.18% CSS 0.04% JavaScript 0.01% CMake 0.12% M4 0.02% Cuda 0.17% DIGITAL Command Language 0.01% Assembly 0.24% Objective-C 0.01% Yacc 0.01% XSLT 0.26% Fortran 0.07% Ruby 0.01%

math's Introduction

The Stan Math Library is a C++, reverse-mode automatic differentiation library designed to be usable, extensive and extensible, efficient, scalable, stable, portable, and redistributable in order to facilitate the construction and utilization of algorithms that utilize derivatives.

DOI

Licensing

The Stan Math Library is licensed under the new BSD license.

The Stan Math Library depends on the Intel TBB library which is licensed under the Apache 2.0 license. This dependency implies an additional restriction as compared to the new BSD lincense alone. The Apache 2.0 license is incompatible with GPL-2 licensed code if distributed as a unitary binary. You may refer to the Apache 2.0 evaluation page on the Stan Math wiki.

Required Libraries

Stan Math depends on four libraries:

These are distributed under the lib/ subdirectory. Only these versions of the dependent libraries have been tested with Stan Math.

Documentation

Documentation for Stan math is available at mc-stan.org/math

Installation

The Stan Math Library is a C++ library which depends on the Intel TBB library and requires for some functionality (ordinary differential equations and root solving) on the Sundials library.

A simple hello world program using Stan Math is as follows:

#include <stan/math.hpp>
#include <iostream>

int main() {
  std::cout << "log normal(1 | 2, 3)="
            << stan::math::normal_log(1, 2, 3)
            << std::endl;
}

If this is in the file /path/to/foo/foo.cpp, then you can compile and run this with something like this, with the path/to business replaced with actual paths:

> cd /path/to/foo
> clang++ -std=c++1y -I /path/to/stan-math -I /path/to/Eigen -I /path/to/boost -I /path/to/sundials -I /path/to/tbb -L /path/to/tbb-libs -ltbb -D_REENTRANT  foo.cpp
> ./a.out
log normal(1 | 2, 3)=-2.07311

The -I includes provide paths pointing to the five necessary includes:

  • Stan Math Library: path to source directory that contains stan as a subdirectory
  • Eigen C++ Matrix Library: path to source directory that contains Eigen as a subdirectory
  • Boost C++ Library: path to source directory that contains boost as a subdirectory
  • SUNDIALS: path to source directory that contains cvodes and idas as a subdirectory
  • Intel TBB: path to source directory that contains tbb as a subdirectory

Note that the paths should not include the final directories stan, Eigen, or boost on the paths. An example of a real instantiation:

clang++ -std=c++1y -I ~/stan-dev/math -I ~/stan-dev/math/lib/eigen_3.3.3/ -I ~/stan-dev/math/lib/boost_1.69.0/ -I ~/stan-dev/math/lib/sundials_4.1.0/include  -I ~/stan-dev/math/lib/tbb_2019_U8/include -L ~/stan-dev/math/lib/tbb -ltbb -Wl,-rpath,"~/stan-dev/math/lib/tbb" -D_REENTRANT foo.cpp

The following directories all exist below the links given to -I: ~/stan-dev/math/stan and ~/stan-dev/math/lib/eigen_3.3.3/Eigen and ~/stan-dev/math/lib/boost_1.69.0/boost and ~/stan-dev/math/lib/sundials_4.1.0/include and ~/stan-dev/math/lib/tbb_2019_U8/include. The ~/stan-dev/math/lib/tbb directory is created by the stan-math makefiles automatically when running any unit test (for example with ./runTests.py test/unit/math/rev/core/agrad_test.cpp). The -Wl,-rpath,... instruct the linker to hard-code the path to the Intel TBB library inside the stan-math directory into the final binary. This way the Intel TBB is found when executing the program.

Other Compilers

There's nothing special about clang++ --- the g++ compiler behaves the same way. You'll need to modify the commands for other compilers, which will need to be up-to-date enough to compile the Stan Math Library.

math's People

Contributors

syclik avatar peterli2016 avatar stevebronder avatar rok-cesnovar avatar stan-buildbot avatar seantalts avatar betanalpha avatar maverickg avatar rtrangucci avatar mbrubake avatar randommm avatar wds15 avatar charlesm93 avatar t4c1 avatar yashikno avatar bbbales2 avatar mitzimorris avatar akucukelbir avatar sakrejda avatar bgoodri avatar vmatthijs avatar weberse2 avatar jrnold avatar mcol avatar matthewdhoffman avatar roualdes avatar aadler avatar dustinvtran avatar peterwicksstringfield avatar ksvanhorn avatar

Watchers

James Cloos avatar

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.