[C++-sig] Re: std::complex<double>?

Neal D. Becker nbecker at hns.com
Fri Jan 9 20:37:55 CET 2004


David Abrahams wrote:

> "Neal D. Becker" <nbecker at hns.com> writes:
> 
>>>From reading the docs, I got the idea that to_python_converter
>> should work.
> 
> The library is already handling std::complex<double>.
> It will work for std::complex<int>, but then you need the other part
> of the equation: something in the indexing suite to say that the
> vector's values need to be returned by value and not by reference.
> 
>>
>> 1. I don't know why this doesn't work.
>> 2. I don't know if this has the right semantics.  I want the python
>> complex value to be a reference to the c++ one.
> 
> No you don't; trust me ;-)
> 
> There isn't really a good way to do that, since the library already
> has decided that std::complex<double> becomes a Python complex object.
> 
>> Am I on the correct track here?  Can anyone give me a clue?
> 
> Been trying?  How'm I doing?
> 

I'm still confused.

Let's try 1 thing at a time.  Forget about complex<int> for now.

All I want, is to write C++ algorithms that use 
std::vector< std::complex<double> > as arguments.  I want to 

1. pass such data from python -> c++.
2. read elements of data in python (e.g. print v[i])
3. write elements from python (e.g., v[i] = 10)

So, what I need is probably not surprising.  What do I need to do?

If I can get this one working, then I'll see about complex<int> later.






More information about the Cplusplus-sig mailing list