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
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 _Complex)
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++).
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
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 looking
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
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 suggests
The monthly meeting of CentraLUG, the Concord/Central NH GNHLUG chapter,
happens the first Monday of most months at 7 PM. Next month's meeting is
on January 7th, 2008 at 7 PM at Miles Smith Farm in Loudon. Directions
and maps are available at http://www.milessmithfarm.net/directions.html
Open to
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:
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 cstdlib
#include iostream
Um, I think you're basically OK and only need to
extract the real and imaginart portions properly,
maybe something like this:
#include cstdlib
#include iostream
#include complex
using namespace std;
int main(int argc, char *argv[])
{
double a, b;
complexdouble c;
a = 1.0;// a
(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...
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 work
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 cstdlib
#include iostream
#include complex
using namespace std;
int main(int argc, char *argv[])
{
14 matches
Mail list logo