0

Is there an easy way to pass only the real/imaginary part of an array of complex numbers in C?

If the array is defined like

double _Complex arr[100];

and I have a function findMean(double *) which only works on real data, is there a way I can pass the real and imaginary part of the array separately?

Kitchi
  • 1,874
  • 4
  • 28
  • 46
  • 3
    I imagine (no pun intended) the only portable way to do this is to copy the real/imaginary parts to different arrays, since the implementation of complex variables could vary across different compilers/platforms. – Drew McGowen Jul 11 '13 at 13:33
  • @H2CO3 - I'd say not an exact question, but rather an extension of that. The other question doesn't deal with arrays... but considering the answer here is no anyway, it's quite safe to close it. :P – Kitchi Jul 11 '13 at 13:37

1 Answers1

2

No, you can't do that. You'll have to either write a variant function

double findMeanReal(double complex const *);

or copy the real parts into a separate array and call findMean on that.

Fred Foo
  • 355,277
  • 75
  • 744
  • 836