This was my final project in the course 'Sparse Matrix Computations' taught by Charles Van Loan. It is a fluid solver mostly based around techniques proposed in the two papers Stable Fluids [Stam et al.] and Visual Simulation of Smoke [Fedkiw et al.] as well as the book Fluid Simulation for Computer Graphics by Bridson.
It currently has the following features:
This project is made available under the GPL license. It depends on Boost, OpenMP, OpenGL/GLUT and libpng.
Download: Source (12/17/2008)
For many types of functions, sybolic derivatives can exhibit an exponential growth in the amount of code required to evaluate them — hundreds up to thousands of lines of C code for the second derivative of a simple-looking expression are not uncommon. Maintaining such derivative implementations across modifications to the original function can be painful - here it often makes sense to switch to automatic differentiation (AD).
AD can evaluate the derivatives of any continuous function without running into the numerical issues traditionally encountered by the use of finite differences. The basic idea is to interpret a program as a big vector-valued function, which can be decomposed into a sequence of elementary function invocations. Once this is done, the chain rule can be repeatedly applied to propagate derivative information through each elementary function call. Since C++ supports polymorphism and operator overloading, all of this is greatly facilitated: the decomposition happens at compile-time and almost no code modifications are required. This C++ library is primarily meant for computing first and second derivative information.
This is an adapted C++ port of Jon Kaldor's Java-based automatic differentiation library, which in turn is inspired by a C version by Eitan Grinspun at Caltech. It is made available here under the LGPL license and depends on UBLAS, which is part of Boost. There is now also an Eigen 3 version.
Download (UBLAS version):
autodiff.h | cholesky.h | example.cpp
Download (Eigen version):
autodiff.h | example.cpp