Converted correlationfuntcions to C++.