typedef double complex[2]

Discussion in 'C Programming' started by seia0106, May 11, 2004.

  1. seia0106

    seia0106 Guest

    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.
     
    seia0106, May 11, 2004
    #1
    1. Advertising

  2. seia0106

    Kevin Bracey Guest

    In message <>
    (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.

    Does that answer your question?

    --
    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/
     
    Kevin Bracey, May 11, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. news.amnet.net.au
    Replies:
    1
    Views:
    581
    =?UTF-8?b?TMSByrtpZSBUZWNoaWU=?=
    Apr 13, 2004
  2. Sydex
    Replies:
    12
    Views:
    6,503
    Victor Bazarov
    Feb 17, 2005
  3. J.M.
    Replies:
    3
    Views:
    635
    Sarath
    Mar 6, 2007
  4. oor
    Replies:
    0
    Views:
    1,356
  5. Replies:
    5
    Views:
    433
    James Kanze
    Jun 27, 2008
Loading...

Share This Page