typedef double complex[2]

S

seia0106

Hello,
I have an array
X=[0,0,1,0,0,0,-1,0,0,0,1,0,0,0,-1,0], whose even and odd indices
should represent
real and imaginary parts of complex numbers.
This I want to use in a routine that uses the
typedef double Cx[2]; for storing complex numbers.

I want to declare an array of complex numbers(with 8 elements) of this
type(Cx), such that even and odd indices of array X are loaded as real
and imaginary parts of complex numbers of this array. Would someone
please tell me how this can be done?

Thanks.
 
K

Kevin Bracey

Hello,
I have an array
X=[0,0,1,0,0,0,-1,0,0,0,1,0,0,0,-1,0], whose even and odd indices
should represent
real and imaginary parts of complex numbers.
This I want to use in a routine that uses the
typedef double Cx[2]; for storing complex numbers.

I want to declare an array of complex numbers(with 8 elements) of this
type(Cx), such that even and odd indices of array X are loaded as real
and imaginary parts of complex numbers of this array. Would someone
please tell me how this can be done?

Given the typedef, an array of complex numbers can be defined and initialised
as:

Cx myarray[8] = { {0,0}, {1,0}, {0,0}, {-1,0},
{0,0}, {1,0}, {0,0}, {-1,0} };

The inner braces can be optionally omitted, but it's probably best to
keep them for clarity.

Does that answer your question?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top