comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » External development: Populating a complex array in C
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: External development: Populating a complex array in C [message #91533 is a reply to message #91532] Sat, 25 July 2015 14:18 Go to previous messageGo to previous message
Heinz Stege is currently offline  Heinz Stege
Messages: 189
Registered: January 2003
Senior Member
Hi David.

On Sat, 25 Jul 2015 11:08:28 -0700 (PDT), David Grier wrote:

> [...]
>
> Next, I'd like to populate the idl_array with values, ideally using memcpy for
> speed and clarity. Attempts resembling
>
> memcpy(pd, src, 512*512*sizeof(float));
>
Just an idea: The size of the complex array is 512*512. A complex
number consists of two floats. So shouldn't you copy
512*512*sizeof(float)*2 bytes?

> seem not to change the data in idl_array. Does anyone know the right way
> to copy floating point data from the C src array to the idl_array?
>
> Alternatively, does anyone know how to convert two IDL_TYPE_FLOAT arrays
> into one IDL_TYPE_COMPLEX array along the lines of the COMPLEX(real,imag)
> function in IDL?
>
Yes, here is an example:
real=findgen(5)
imag=4.-findgen(5)
comp=complex(real,imag)
help,comp
print,comp
IDL prints:
COMP COMPLEX = Array[5]
( 0.000000, 4.00000)( 1.00000, 3.00000)
( 2.00000, 2.00000)( 3.00000, 1.00000)
( 4.00000, 0.000000)

Cheers, Heinz
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Dynamic Resize Moves Window
Next Topic: Current color table

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:53:01 PDT 2025

Total time taken to generate the page: 0.00393 seconds