Numerical optimization in C++