I'm successfully using <complex.h> functionality, but I'm a little confused. I'm trying to keep everything in float instead of double and I was uncertain what "I" was, so just to be sure, I defined "If":
After doing this and replacing all my I's with If's, nothing worked, all my answers were wrong. Why would that be?
Also, after switching from double to float, some things got incredibly slow, specifically:
This is really bogged down. I was using "cexpf" which was incredibly slow too, so I tried this just in case.
> After doing this and replacing all my I's with If's, nothing worked, all my answers were wrong. Why would that be?
What were you trying to do?
> Also, after switching from double to float, some things got incredibly slow, specifically:
What was switched from double to float? What are all the other identifiers declared as?
I've not used C99 complex, but I would think it would have to be (complex float)I if anything. I'm pretty sure (float)I would end up being 0.
Anyone have thoughts on the slowness?
Yes. I think you're not using the right function for the types. So... what are the identifiers declared as?
Reading about complex.h I believe that I is just what it is in math, the imaginary number i. It says that it is actually a macro expanding to a const expression of type _Imaginary float and have a value of I.
To declare a complex number with float values you, lets say z, you declare float complex z.
Isn't this right? Haven't use it, just read the manual for complex.h.
So the If is a float complex number. The I is the imaginary number i (or j). So the
makes no sense to me. The casting also makes no sense.
Now, I don't know what you changed here:
Do you actually mean If instead of I? If that is the case then correctly nothing works.
But if my understanding is correct, then:
1) temp should be declared as float complex
2) I should be as it is
Try actually declaring temp as double complex and then as float complex. Then check the size with sizeof(). If it is different then you know now that float complex is what you want, a complex number with float variables.
Yeah, I made a mistake and should have said:
I don't think this is necessary, but I just wanted to make sure I wasn't expanding to double.
The line of code was a different thought. It could be "I" or "If". Using "If" is probably not necessary. Either way, it's a bottleneck in my code and I'm trying to figure out why.
I'm actually using FFTW in my program, so my complex values are of type fftwf_complex:
That's the basic idea.
fftwf_complex *data, temp,*answer;
... //Big loop
I read someplace that FFTW uses some fast sine and cosine routines, but I haven't been able to figure out how to use them alone...