473,574 Members | 3,176 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FFTW change from complex struct to float[2]

I'm looking into upgrading from version 2 to version 3 of the FFT code
package FFTW (www.fftw.org). The two versions are incompatible - a lot
of it has to do with changing from a complex struct with two members
(eg. a.re and a.im) to a two element array float[2] (eg. a[0] and a[1])
to hold the real and imaginary parts.

So whereas before

fftw_complex a[1000];

would give you 1000 structs with the following members a[i].re and
a[i].im, you now have

fftw_complex a[1000];

existing as float a[2][1000].

I'm wondering what advantages this change has - I mean, why would one
break compatibility for this?

Nov 15 '05 #1
5 8082
sp******@yahoo. com wrote:
I'm looking into upgrading from version 2 to version 3 of the FFT code
package FFTW (www.fftw.org). The two versions are incompatible - a lot
of it has to do with changing from a complex struct with two members
(eg. a.re and a.im) to a two element array float[2] (eg. a[0] and a[1])
to hold the real and imaginary parts.

So whereas before

fftw_complex a[1000];

would give you 1000 structs with the following members a[i].re and
a[i].im, you now have

fftw_complex a[1000];

existing as float a[2][1000].

I'm wondering what advantages this change has - I mean, why would one
break compatibility for this?


Perhaps check the project FAQ...
http://www.fftw.org/faq/section3.html#fftw2to3

-Charlie

Nov 15 '05 #2

Charles Mills wrote:

Perhaps check the project FAQ...
http://www.fftw.org/faq/section3.html#fftw2to3


Now, why didn't I think of that? Thanks :)

Nov 15 '05 #3
sp******@yahoo. com wrote:
I'm looking into upgrading from version 2 to version 3 of the FFT code
package FFTW (www.fftw.org). The two versions are incompatible - a lot
of it has to do with changing from a complex struct with two members
(eg. a.re and a.im) to a two element array float[2] (eg. a[0] and a[1])
to hold the real and imaginary parts.
This and other changes are described in the manual:

http://www.fftw.org/doc/Upgrading-fr...version-2.html

(The change in fftw_complex is really the least of the changes.)
So whereas before

fftw_complex a[1000];

would give you 1000 structs with the following members a[i].re and
a[i].im, you now have

fftw_complex a[1000];

existing as float a[2][1000].

I'm wondering what advantages this change has - I mean, why would one
break compatibility for this?


Defining fftw_complex as double[2] is guaranteed to be binary
compatible with the C complex type in the 1999 ANSI C standard (and is
also guaranteed to be binary compatible with the C++ complex<double>
template class). In fact, if you #include <complex.h> before
<fftw3.h>, then the interface will use the C99 complex type, which is a
great convenience. See also:

http://www.fftw.org/doc/Complex-numbers.html

in the manual. In contrast, a struct { double re, im; } type, which
was the old type, is strictly speaking not binary-compatible with
double[2], since the compiler is allowed to add padding. This is why
we switched.

(In practice, the difference is mostly academic, because on every
system in modern use the two are binary compatible. The only exception
that I have ever heard of was some old Cray system. But, since we were
changing many other parts of the API anyway, we figured we might as
well be standard-conforming.)

Cordially,
Steven G. Johnson

Nov 15 '05 #4

st*****@alum.mi t.edu wrote:
sp******@yahoo. com wrote:
I'm looking into upgrading from version 2 to version 3 of the FFT code
package FFTW (www.fftw.org). The two versions are incompatible - a lot
of it has to do with changing from a complex struct with two members
(eg. a.re and a.im) to a two element array float[2] (eg. a[0] and a[1])
to hold the real and imaginary parts.


This and other changes are described in the manual:

http://www.fftw.org/doc/Upgrading-fr...version-2.html

(The change in fftw_complex is really the least of the changes.)
So whereas before

fftw_complex a[1000];

would give you 1000 structs with the following members a[i].re and
a[i].im, you now have

fftw_complex a[1000];

existing as float a[2][1000].

I'm wondering what advantages this change has - I mean, why would one
break compatibility for this?


Defining fftw_complex as double[2] is guaranteed to be binary
compatible with the C complex type in the 1999 ANSI C standard (and is
also guaranteed to be binary compatible with the C++ complex<double>
template class). In fact, if you #include <complex.h> before
<fftw3.h>, then the interface will use the C99 complex type, which is a
great convenience. See also:

http://www.fftw.org/doc/Complex-numbers.html

in the manual. In contrast, a struct { double re, im; } type, which
was the old type, is strictly speaking not binary-compatible with
double[2], since the compiler is allowed to add padding. This is why
we switched.

(In practice, the difference is mostly academic, because on every
system in modern use the two are binary compatible. The only exception
that I have ever heard of was some old Cray system. But, since we were
changing many other parts of the API anyway, we figured we might as
well be standard-conforming.)


Don't be too certain this is just academic.
You also have to take into acount future implementations . What
about the machine on which 128 bit reads are much faster than
64 bit reads. An implementation on such a machine might well
choose 64 bit doubles for backward compatibility and
add padding to struct { double re, im; }.

-William Hughes

Nov 15 '05 #5

st*****@alum.mi t.edu wrote:
sp******@yahoo. com wrote:
I'm looking into upgrading from version 2 to version 3 of the FFT code
package FFTW (www.fftw.org). The two versions are incompatible - a lot
of it has to do with changing from a complex struct with two members
(eg. a.re and a.im) to a two element array float[2] (eg. a[0] and a[1])
to hold the real and imaginary parts.


This and other changes are described in the manual:

http://www.fftw.org/doc/Upgrading-fr...version-2.html

(The change in fftw_complex is really the least of the changes.)

(snip)


Thanks for your comments, I like the new interface much better. The
only issue is getting everyone in my lab who uses the fftw_complex type
to update their code - I guess biting the bullet occasionally isn't a
bad thing.

Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
5049
by: seia0106 | last post by:
Hello, Writing a program in c++ that should use complex numbers I have two choices before me. 1- define a struct for complex data i.e struct {float real,imag; }ComplexNum; 2-use an array of float type
6
3928
by: Stanley | last post by:
Hi, I'm using FFTW library to do my FFT calculation. My sample size is so large to get the resolution I want ( >10^7 samples). It's time and memory consuming. Since I'm just interested in the first 1000 or 10000 points in the fequency domain. So custom functions will be so useful to me and I can only calculate the first some points I want....
4
4343
by: Erica | last post by:
Hi, I am currently working on a program using FFTW-> http://www.fftw.org . My basic C program to compute the 2D Fourier transform of a bunch of data works fine when I compile it with gcc. However, I would like to incorporate that code into a larger program that I wrote with C++. Unfortunately, I cannot get my program to compile with g++. ...
6
2545
by: mark | last post by:
I've got a C library that I want to access from C++. I'd like to pass complex number portably between them. Right now, I've got code in the header file to define the argument according to C or C++. #ifdef __cplusplus # include <complex> typedef std::complex<float> float_complex; #else # include <complex.h> typedef float complex ...
3
2289
by: Fabio Garufi | last post by:
Hi, all, I built the fftw-3.0.1-fma on a LynxOS 4.0 running on a board equipped with a PowerPC G4 7457. To compile it I had to slightly modify the configure script to use the -fvec instead of -faltivec and use the our-malloc16 function. I never could run the checks in tests directory, since they always failed with signal 11. Here follow the...
11
4898
by: Osiris | last post by:
I have these pieces of C-code (NOT C++ !!) I want to call from Python. I found Boost. I have MS Visual Studio 2005 with C++. is this the idea: I write the following C source file: ============================ #include <iostream> #include <stdafx.h>
3
1062
by: Klaas Vantournhout | last post by:
Hi all, I was wondering why there is one extra argument for the return values of complex functions. And why is this not the case with any other data type (except char) example : * In case of a non complex value
11
2399
by: jacob navia | last post by:
hi I am trying to use the complex data type. Consider this code, taken from the cclib library: struct complex csqrt(Cpx z) { double r; r=sqrt(z.re*z.re+z.im*z.im); r=sqrt(ldexp(r+fabs(z.re),-1));
9
9935
by: void main | last post by:
I'm rather new to complex numbers in C and was wondering, how do I initialize a complex variable properly if the imaginary part is 0. I tried -------- #include <complex.h> float complex c = 1.0f; --------
0
8110
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8273
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7862
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6514
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5658
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5336
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1375
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1102
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.