From: Jan-Benedict Glaw <jbglaw@lug-owl.de>
To: linux prg <linux-c-programming@vger.kernel.org>
Subject: Re: Floating point exception
Date: Sat, 11 Sep 2004 16:58:15 +0200 [thread overview]
Message-ID: <20040911145815.GP19967@lug-owl.de> (raw)
In-Reply-To: <20040911113913.86435.qmail@web52904.mail.yahoo.com>
[-- Attachment #1: Type: text/plain, Size: 1820 bytes --]
On Sat, 2004-09-11 12:39:13 +0100, Ankit Jain <ankitjain1580@yahoo.com>
wrote in message <20040911113913.86435.qmail@web52904.mail.yahoo.com>:
> #include<stdlib.h>
> #include<string.h>
> #include<complex.h>
> #include<errno.h>
> #include<time.h>
> #include<stdio.h>
> #define NX 4
> #define NY 4
> #define N 2*NX*NY //N is the size of 2 D DFT
Braces missing
> #include <math.h>
You'd first finish all includes, then add your own defines.
> #define num 2
> #define SWAP(a,b) tempr=(a);(a)=(b);(b)=tempr
This may cause subtle errors. Consider
if (something)
SWAP (x, y);
Only the part "tempr=(a);" would be executed conditionally, what is not
exactly what you intended. I suggest using:
#define SWAP(a,b) \
do { \
tempr = (a); \
(a) = (b); \
(b) = tempr; \
} while (0)
> void fft(float data[], unsigned long nn[], int ndim,
> int isign)
> {
> int idim;
> unsigned long
> i1,i2,i3,i2rev,i3rev,ip1,ip2,ip3,ifp1,ifp2;
> unsigned long ibit,k1,k2,n,nprev,nrem,ntot;
> float tempi,tempr;
> double theta,wi,wpi,wpr,wr,wtemp; //Double precision
> for trigonometric recur-rences.
> for (ntot=1,idim=1;idim<=ndim;idim++) //Compute
> total number of complex val-ues.
> ntot *= nn[idim];
> nprev=1;
>
> for (idim=ndim;idim>=1;idim--)
> { // Main loop over the dimensions.
> n=nn[idim];
> nrem=ntot/(n*nprev);
In your example code, n may become zero, so you devide by zero, which
isn't legal.
MfG, JBG
--
Jan-Benedict Glaw jbglaw@lug-owl.de . +49-172-7608481 _ O _
"Eine Freie Meinung in einem Freien Kopf | Gegen Zensur | Gegen Krieg _ _ O
fuer einen Freien Staat voll Freier Bürger" | im Internet! | im Irak! O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2004-09-11 14:58 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-11 11:39 Floating point exception Ankit Jain
2004-09-11 14:58 ` Jan-Benedict Glaw [this message]
-- strict thread matches above, loose matches on Subject: below --
2008-09-03 19:31 john bryant
[not found] <22AECFD3-98E0-44F9-A19C-1667B41D0675@itfreedom.com>
2008-07-10 17:56 ` Floating Point Exception Cody Jarrett
2008-07-10 18:01 ` Samuel Thibault
2008-07-11 16:27 ` Cody Jarrett
2008-07-11 17:21 ` Samuel Thibault
2008-07-11 18:02 ` Cody Jarrett
2008-07-11 19:20 ` Samuel Thibault
2004-05-31 3:12 Floating point exception kas turi
2002-12-27 14:18 Floating Point Exception Nandakumar NarayanaSwamy
[not found] <000601c28c56$4b9d20a0$7301a8c0@zhongqx>
2002-11-15 4:44 ` Floating point exception rekha gvv
2002-01-14 10:56 floating " Zwane Mwaikambo
2002-01-14 21:26 ` Christian Thalinger
2002-01-15 14:34 ` Zwane Mwaikambo
2002-01-15 14:46 ` Richard B. Johnson
2002-01-15 18:19 ` Christian Thalinger
2002-01-15 18:31 ` Richard B. Johnson
2002-01-15 18:49 ` Christian Thalinger
2002-01-16 5:45 ` Zwane Mwaikambo
2002-01-16 11:55 ` Christian Thalinger
2002-01-16 14:32 ` Zwane Mwaikambo
2002-01-16 20:26 ` Christian Thalinger
2002-01-16 21:23 ` Richard B. Johnson
2002-01-16 21:59 ` Brian Gerst
2002-01-16 22:05 ` Richard B. Johnson
2002-01-16 22:12 ` Mark Zealey
2002-01-16 22:23 ` Richard B. Johnson
2002-01-16 23:35 ` Christian Thalinger
2002-01-13 12:43 Christian Thalinger
2002-01-15 23:28 ` Brian Gerst
2002-01-16 11:45 ` Christian Thalinger
2002-01-16 11:58 ` Dave Jones
2002-01-16 13:14 ` Bruce Harada
2002-01-16 20:06 ` Christian Thalinger
2002-01-17 19:26 ` bill davidsen
2002-01-16 13:52 ` Brian Gerst
2002-01-16 14:28 ` M. Edward (Ed) Borasky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040911145815.GP19967@lug-owl.de \
--to=jbglaw@lug-owl.de \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.