J
jwest
I am writing a class to wrap around a C numerical routine that processes
the real and imaginary parts of complex data in two different arrays.
The wrapper I have so far is
class COMPLEX_DATA {
std::valarray<std::complex<double> > real_data, imag_data;
public:
// (functions that call the C-code to process)
}
In order to make access to this class as transparent as possible within
our C++ code, I would like to overload equal sign and [ ] operators so
we can both read from and write to the internal valarrays directly from a
complex variable. That is, I would like to be able to do the following
COMPLEX_DATA d_c;
std::complex<double> a, b;
// Set a to the value std::complex<double>(d_c.real_data, d_c.imag_data)
// using
a = d_c;
// Set d_c.real_data = real(b) and d_c.imag_data = imag(b) using
d_c = b;
The first one is easy, but the second one is unfortunately beyond my
abilities (if it is even possible). Can anyone enlighten me?
the real and imaginary parts of complex data in two different arrays.
The wrapper I have so far is
class COMPLEX_DATA {
std::valarray<std::complex<double> > real_data, imag_data;
public:
// (functions that call the C-code to process)
}
In order to make access to this class as transparent as possible within
our C++ code, I would like to overload equal sign and [ ] operators so
we can both read from and write to the internal valarrays directly from a
complex variable. That is, I would like to be able to do the following
COMPLEX_DATA d_c;
std::complex<double> a, b;
// Set a to the value std::complex<double>(d_c.real_data, d_c.imag_data)
// using
a = d_c;
// Set d_c.real_data = real(b) and d_c.imag_data = imag(b) using
d_c = b;
The first one is easy, but the second one is unfortunately beyond my
abilities (if it is even possible). Can anyone enlighten me?