Add functors for distributions, and templated newton-raphson function in C++.