I am currently trying out IT++ and so far it was great. It is as easy as Octave but written for C++ programming. One thing that I had trouble was that in my code I need to compute

`complex acos(complex a)`

However, it gives me error

for the function acos. It turns out acos for complex number was not in the C++ 98 specification, it will only be on the C++ 0x specification. So I turn to Boost library.

To modify IT++, this is what I do:

1. go to “itpp-4.0.6/itpp/base/math” folder, and modify the file “trig_hyp.h”

2. Add this line:

#include <boost/math/complex/acos.hpp>

Of course you need to have Boost library.

3. Find the line for “acos” in trig_hyp.h file, and add these lines:

`//! Inverse cosine function vector`

inline cvec acos(const cvec &x) { return apply_function<std::complex >(boost::math::acos, x); }

//! Inverse cosine function matrix

inline cmat acos(const cmat &x) { return apply_function<std::complex >(boost::math::acos, x); }

//! Inverse cosine function scalar

inline std::complex acos(const std::complex &x) { return boost::math::acos( x); }

4. Go back to the root directory for IT++ and do a ./configure again

`./configure --prefix=$(HOME)/local F77=gfortran CPPFLAGS=-I`

where we have included the root folder of our Boost libraries.

5. Type “make”, “make check”, and “make install”

6. Now, in your code, you also need to include your Boost folder in your Makefile.

That’s all, now we have acos in IT++

Filed under: Uncategorized | Tagged: c++, IT++ | 6 Comments »