Velocity Reviews > typedef double complex[2]

# typedef double complex[2]

seia0106
Guest
Posts: n/a

 05-11-2004
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.

Kevin Bracey
Guest
Posts: n/a

 05-11-2004
In message <(E-Mail Removed) >
http://www.velocityreviews.com/forums/(E-Mail Removed) (seia0106) wrote:

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

--
Kevin Bracey, Principal Software Engineer
Tematic Ltd Tel: +44 (0) 1223 503464
182-190 Newmarket Road Fax: +44 (0) 1223 503458
Cambridge, CB5 8HE, United Kingdom WWW: http://www.tematic.com/