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++

### Like this:

Like Loading...

*Related*

Filed under: Uncategorized | Tagged: c++, IT++ |

kurniawano, on November 26, 2008 at 6:12 am said:I tried to install IT++ in one of my workstation, somehow it couldn’t find the fftw3 library. So I need to specify it in my ./configure parameters. Before that, I need to install fftw3 library with -fPIC flag.

then configure IT++ with

./configure –prefix=$HOME/local CPPFLAGS=-I/your/include/folder LDFLAGS=-L/your/library/folder

Heartburn Home Remedy, on April 15, 2009 at 11:45 am said:This is quite a up-to-date information. I’ll share it on Delicious.

gg2009, on July 17, 2009 at 12:00 pm said:Hello every one

I just start trying ITPP, it looks like quite nice.

But I have one big problem initializing a cvec object and I have two questions:

1) first, is there any special forums for itpp’s users? I didn’t any solution in find http://sourceforge.net/forum/forum.php

2) if not, can you help for the folowing problem:

Written with GnuScientificLibrary, it should look like this

// creating complex

gsl_comple z;

gsl_complex* signal = malloc(sizeof(gsl_complex) * nb_of_samples);

if( signal == NULL) {exit(EXICT_FAILURE);}

// reading a file, for each sample,

//beginning_of_loop

real=fread… imag=fread…

// Building the complex number

z = gsl_complex_rec(real, imag);

*(signal + index_of_sample) = z;

//end_of_loop

gg2009, on July 17, 2009 at 2:18 pm said:And to get a complex back

real = REAL(*(signal + index_of_sample));

imag = IMAG(*(signal + index_of_sample));

I would like to do the same with itpp

first:

I guess it would be something like

std::complex my_complex(real, imag); to create a complex,

but I am not sur.

then it should be something like

(cvec signal).set(index, my_complex);

Actually I have no idea of how to get real and imag part back from complex.

Thank you very much for your help !

kurniawano, on July 22, 2009 at 2:41 am said:to set a complex simply use in your header and type

std::complex my_complex(3,2);

and to obtain the real and imaginary part back you can type:

itpp::real(my_complex);

itpp::imag(my_complex);

GG, on July 28, 2009 at 11:47 am said:thank you a lot,

I keep on studiing itpp and cpp, Now I may have some problems with members and pointers:

I would like to save memory, so, in C langage, I would use pointers, malloc and free.

with CPP, I would like to use cvec* in a member, but I cannot use any

cvec* my_cvec_pointer = new cvec(nomber_of_samples);

I still look for a solution,

Have a nice day!