Re: C complex number usage

2008-01-07 Thread Bruce Labitt
Thanks everyone, I have something working using FFTW. My first program looks ok. It takes the IFFT ( FFT (x,N) , N). My second program is, shall we say, a work in progress. It runs, but the output is not as expected. C is pretty ugly. My code is even uglier. As for parallel processing, I

Re: C complex number usage

2008-01-07 Thread Kevin D. Clark
You might consider using Perl's Math::FFTW module for your problem: http://steffen-mueller.net/modules/Math-FFTW/ Another module that you might find to be useful is Perl's Math::Complex module: http://search.cpan.org/~nwclark/perl/lib/Math/Complex.pm Or, depending on the size and scope of

Re: C complex number usage

2008-01-06 Thread Michael ODonnell
JerryF wrote: >There is a bug in your code: >c = (a,b); // form the complex number >This is not initialzing c. It is assigning a to c. Oh. Duh. He's right. Some variations: #include #include #include using namespace std; int main(int argc, char *argv[]) { double a, b; a = 1.1

Re: C complex number usage

2008-01-06 Thread Jerry Feldman
On Sun, 06 Jan 2008 16:47:23 -0500 Bruce Labitt <[EMAIL PROTECTED]> wrote: > Nope, I'm using Dev-C++ which is based on the MinGW compiler. (gcc) > > I'm just a bit frustrated that I can't even form a single complex number > and print it out. :( > > I've got a simpler scrap of code that doesn't

Re: C complex number usage

2008-01-06 Thread Michael ODonnell
(sigh!) Never mind - I should have actually compiled that program before responding - it doesn't work either. I'll poke at it after I finish some errands. Yeesh! That "g++ -E" trick yields approx 30,000 lines of code after all the #includes and macro expansions... __

Re: C complex number usage

2008-01-06 Thread Bruce Labitt
I did find a solution. Not online though... From brute force try anything... This snippet does work. However, as noted in the code, even though the standard says it will work - it didn't... #include #include #include using namespace std; using std::complex; int main(int argc, char *argv[]

Re: C complex number usage

2008-01-06 Thread Michael ODonnell
Um, I think you're basically OK and only need to extract the real and imaginart portions properly, maybe something like this: #include #include #include using namespace std; int main(int argc, char *argv[]) { double a, b; complex c; a = 1.0;// a is the real part b = 1.0;

Re: C complex number usage

2008-01-06 Thread Michael ODonnell
>> What's the compiler version? > > I can tell from the directory path in his original post that > it's almost certainly some flavor of Microsoft Visual C++. Yah, I also noticed that pathname but thought it possible he was maybe using some flavor of something like Cygwin. [...] >> Also

Re: C complex number usage

2008-01-06 Thread Bruce Labitt
Nope, I'm using Dev-C++ which is based on the MinGW compiler. (gcc) I'm just a bit frustrated that I can't even form a single complex number and print it out. :( I've got a simpler scrap of code that doesn't work either. ;) compiled with c++ compiler... #include #include #include using name

Re: C complex number usage

2008-01-06 Thread Ben Scott
On Jan 6, 2008 2:05 PM, Michael ODonnell <[EMAIL PROTECTED]> wrote: > What's the compiler version? I can tell from the directory path in his original post that it's almost certainly some flavor of Microsoft Visual C++. FWIW, Microsoft has some (limited) docs online: http://msdn2.microsoft.co

Re: C complex number usage

2008-01-06 Thread Kent Johnson
Bruce Labitt wrote: > Thanks, Kent. > > It actually did help. Maybe I'll show up to the January PySig and annoy > people there... Or January MerriLUG where I am presenting on Python. Do you know if Python (scientific/scipy) is available > for the CELL processor, aka PS3? This document sugge

Re: C complex number usage

2008-01-06 Thread Michael ODonnell
Also, if you post your code here (trimmed down so it's just enough to demo the problem) some of us might be better able to offer an analysis. ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug

Re: C complex number usage

2008-01-06 Thread Michael ODonnell
> I'm not sure where to find out about complex number support in C > (or C++). Most of the pages I've googled so far haven't been > too helpful. What's the compiler version? Assuming gcc or g++ try invoking with only the -v option to learn the version. Try adding the -E option and then lookin

Re: C complex number usage

2008-01-06 Thread Bruce Labitt
Thanks, Kent. It actually did help. Maybe I'll show up to the January PySig and annoy people there... Do you know if Python (scientific/scipy) is available for the CELL processor, aka PS3? I've got a massively parallel problem I need to solve... My initial look at python was favorable - it

Re: C complex number usage

2008-01-06 Thread Bruce Labitt
I was going to try casting next, but I didn't understand why the expression would automatically be of that type. "I" is type double _Complex, I think. So why isn't the expression on the RHS already double _Complex? I'm not sure where to find out about complex number support in C (or C++). M

Re: C complex number usage

2008-01-06 Thread Chris Linstid
The problem it's complaining about is that mymean and mystdev are variables of type "double" and gaussrand() returns a "double"... and you're trying to assign the result to g[ii] which is type "double _Complex". You could try casting the result to "double _Complex" like this: g[ii] = (double _Com

Re: C complex number usage

2008-01-06 Thread Kent Johnson
Bruce Labitt wrote: > Hopefully a simple question. I'm trying to write a C program that uses > complex numbers. > Hopefully someone can point me in the write direction. TIA. If you don't have a specific requirement for C, you might consider learning Python instead. > python.org :-) Python

C complex number usage

2008-01-06 Thread Bruce Labitt
Hopefully a simple question. I'm trying to write a C program that uses complex numbers. (I'm a "C" illiterate. Just wrote my second program...) Reading the header file complex.h hasn't helped too much. Can someone give me a hint on how to "fix" this? Most of the references on C are *anci