e9068c56b1
clad is a C++ plugin for clang and cling that implements automatic differentiation of user-defined functions by employing the chain rule in forward and reverse mode, coupled with source code transformation and AST constant fold. In mathematics and computer algebra, automatic differentiation (AD) is a set of techniques to numerically evaluate the derivative of a function specified by a computer program. AD exploits the fact that every computer program, no matter how complicated, executes a sequence of elementary arithmetic operations (addition, subtraction, multiplication, division, etc.) and elementary functions (exp, log, sin, cos, etc.). By applying the chain rule repeatedly to these operations, derivatives of arbitrary order can be computed automatically, accurately to working precision, and using at most a small constant factor more arithmetic operations than the original program. AD is an alternative technique to symbolic and numerical differentiation. These classical methods run into problems: symbolic differentiation leads to inefficient code (unless done carefully) and faces the difficulty of converting a computer program into a single expression, while numerical differentiation can introduce round-off errors in the discretization process and cancellation. Both classical methods have problems with calculating higher derivatives, where the complexity and errors increase. Finally, both classical methods are slow at computing the partial derivatives of a function with respect to many inputs, as is needed for gradient-based optimization algorithms. Automatic differentiation solves all of these problems, at the expense of introducing more software dependencies. This patch allows ROOT to interoperate with clad. Namely, users can ask the interpreter to produce a derivative or a gradient to a known function. An illustrative example code for first order derivative: root [0] #include "Math/CladDerivator.h" root [1] double my_pow2(double x) { return x*x; } root [2] auto meta_obj = clad::differentiate(my_pow2, /*wrt 1-st argument*/0); root [3] meta_obj.dump(); The code is: double my_pow2_darg0(double x) { return (1. * x + x * 1.); } root [5] meta_obj.execute(1) // no iterations, at the cost of function call. (double) 2.0000000 Learn more about clad at https://github.com/vgvassilev/clad Patch by Aleksandr Efremov and me! |
||
---|---|---|
cmake/modules | ||
demo | ||
docs | ||
include/cling | ||
lib | ||
patches | ||
test | ||
tools | ||
www | ||
.clang-format | ||
.travis.yml | ||
appveyor.yml | ||
CMakeLists.txt | ||
CREDITS.txt | ||
LastKnownGoodLLVMSVNRevision.txt | ||
LICENSE.TXT | ||
README.md | ||
VERSION |
Cling - The Interactive C++ Interpreter
The main repository is at https://github.com/root-project/cling
Overview
Cling is an interactive C++ interpreter, built on top of Clang and LLVM compiler infrastructure. Cling realizes the read-eval-print loop (REPL) concept, in order to leverage rapid application development. Implemented as a small extension to LLVM and Clang, the interpreter reuses their strengths such as the praised concise and expressive compiler diagnostics.
See also cling's web page.
Please note that some of the resources are rather old and most of the stated limitations are outdated.
- talks
- http://blog.coldflake.com/posts/2012-08-09-On-the-fly-C++.html
- http://solarianprogrammer.com/2012/08/14/cling-cpp-11-interpreter/
- https://www.youtube.com/watch?v=f9Xfh8pv3Fs
- https://www.youtube.com/watch?v=BrjV1ZgYbbA
- https://www.youtube.com/watch?v=wZZdDhf2wDw
- https://www.youtube.com/watch?v=eoIuqLNvzFs
Installation
Release Notes
See our release notes to find what's new.
Binaries
Our nightly binary snapshots can be found here.
Building from Source with Cling Packaging Tool
Cling's tree has a user-friendly, command-line utility written in Python called Cling Packaging Tool (CPT) which can build Cling from source and generate installer bundles for a wide range of platforms. CPT requires Python 2.7 or later.
If you have Cling's source cloned locally, you can find the tool in
tools/packaging
directory. Alternatively, you can download the script
manually, or by using wget
:
wget https://raw.githubusercontent.com/root-project/cling/master/tools/packaging/cpt.py
chmod +x cpt.py
./cpt.py --check-requirements && ./cpt.py --create-dev-env Debug --with-workdir=./cling-build/
Full documentation of CPT can be found in tools/packaging.
Usage
./cling '#include <stdio.h>' 'printf("Hello World!\n")'
To get started run:
./cling --help
or type
./cling
[cling]$ .help
Jupyter
Cling comes with a Jupyter kernel. After building cling, install Jupyter and cling's kernel by following the README.md in tools/Jupyter. Make sure cling is in your PATH when you start jupyter!
Developers' Corner
Cling's latest doxygen documentation
Contributions
Every contribution is considered a donation and its copyright and any other related rights become exclusive ownership of the person who merged the code or in any other case the main developers of the "Cling Project".
We warmly welcome external contributions to the Cling! By providing code, you agree to transfer your copyright on the code to the "Cling project". Of course you will be duly credited and your name will appear on the contributors page, the release notes, and in the CREDITS file shipped with every binary and source distribution. The copyright transfer is necessary for us to be able to effectively defend the project in case of litigation.
License
Please see our LICENSE.
Releases
Our release steps to follow when cutting a new release:
- Update release notes
- Remove
~dev
suffix from VERSION - Add a new entry in the news section of our website
- Commit the changes.
git tag -a v0.x -m "Tagging release v0.x"
- Create a draft release in github and copy the contents of the release notes.
- Wait for green builds.
- Upload binaries to github (Travis should do this automatically).
- Publish the tag and announce it on the mailing list.
- Increment the current version and append
~dev
.