looking for the fastest complex number arithmetics...

L

Luna Moon

looking for the fastest complex number arithmetics...

Hi all,

I am looking for the fastest complex number arithmetics.

There is one part of my program which needs complex number
arithmetics.

The final result is a real number.

So I had two choices:

(1) Using the C++ class, and do all the operations in complex domain,
and finally extract out the real part of the result.

(2) Calculate the real part of result in closed-form by hand, and
program everything in C/C++ in real domain.

I used to do (2). And I used Maple to help me obtain the real part of
the complex-valued expressions in closed form and generate the C code.
The speed is about 10x faster than (1).

Now we are adding more and more terms into that expression and it
looks like it is going to go beyond the capability of Maple and the
limit of memory and CPU resources, in order to obtain the real part of
the complicated expressions. And also the code generated by Maple is
not readable and making a change to the expressions means redoing
everything...

So now we have to seriously consider the possibility of approach (1).

Where can I find the fastest complex number arithmetics? Why is the C+
+ complex class so slow? (my rough estimate is that it is probably
slower than Matlat's complex number operations)...

Any tricks/tips/thoughts on complex number programming?

Thanks!
 
T

Thomas Richter

In comp.lang.c Luna Moon said:
There is one part of my program which needs complex number
arithmetics.

The final result is a real number.

So I had two choices:

(1) Using the C++ class, and do all the operations in complex domain,
and finally extract out the real part of the result.

(2) Calculate the real part of result in closed-form by hand, and
program everything in C/C++ in real domain.


AFAIK C99 has a complex number type you might want to try.
I used to do (2). And I used Maple to help me obtain the real part of
the complex-valued expressions in closed form and generate the C code.
The speed is about 10x faster than (1).
Where can I find the fastest complex number arithmetics? Why is the C+
+ complex class so slow? (my rough estimate is that it is probably
slower than Matlat's complex number operations)...

That heavely depends on your compiler. There is no intrinsic reason why
the C++ version has to be slower.

So long,
Thomas
 
L

Luna Moon

AFAIK C99 has a complex number type you might want to try.


That heavely depends on your compiler. There is no intrinsic reason why
the C++ version has to be slower.

So long,
Thomas

I am using MSVS.Net 2003 and Intel Compiler C++.

You don't think option (1) will be slower than option (2)?
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

I am using MSVS.Net 2003 and Intel Compiler C++.

You don't think option (1) will be slower than option (2)?

He was referring to C++ complex operations being slower than Maple's.
There's a good chance that Maple is implemented in C++ (or C, but
there's no reason for C++ being slower than C). Perhaps the problem lies
in your usage of the C++ complex classes, such as excessive copying or
something like that. A good profiler might help you find the problem.

Also, specifying what exactly you are trying to do with the complex
numbers might aid people in better understanding your problem, I assume
that you have to perform a large number of operations on a large number
of complex numbers since performance is a problem. Are you using vectors
or matrices of complex numbers? If that's the case it might be those
operations that are slow rather than the complex operations.
 
M

Malcolm McLean

Erik Wikström said:
He was referring to C++ complex operations being slower than Maple's.
There's a good chance that Maple is implemented in C++ (or C, but there's
no reason for C++ being slower than C). Perhaps the problem lies in your
usage of the C++ complex classes, such as excessive copying or something
like that. A good profiler might help you find the problem.
Maple spits out C++ code from a human-readable mathematical expression.
If it does a better job of optimising the function than the human
programmer, which isn't too unlikely, it will produce faster functions.
 
A

Axel Vogt

Malcolm said:
Maple spits out C++ code from a human-readable mathematical expression.
If it does a better job of optimising the function than the human
programmer, which isn't too unlikely, it will produce faster functions.

Not quite, it is C code (and it does not care for memory stuff), but
yes, in can be quite optimal.
 
J

John Harper

looking for the fastest complex number arithmetics...

Hi all,

I am looking for the fastest complex number arithmetics. ....
So I had two choices:

(1) Using the C++ class, and do all the operations in complex domain,
and finally extract out the real part of the result.

(2) Calculate the real part of result in closed-form by hand, and
program everything in C/C++ in real domain.

(3) If it's complex floating-point try Fortran 95 instead of (1) above.
Obsolete Fortran dialects like f66 or f77 didn't automatically provide
double precision complex. Some f95 compilers provide quadruple precision
but double is the highest guaranteed by the f95 standard. Some are free.

-- John Harper, School of Mathematics, Statistics and Computer Science,
Victoria University, PO Box 600, Wellington 6140, New Zealand
e-mail (e-mail address removed) phone (+64)(4)463 5341 fax (+64)(4)463 5045
 
W

Wade Ward

john,

where's the moon? mpj

reply personally

--
-- --
-- I'm using a bst to kill bugs today. 32 kills so far. That is an
authentic task.

During sorting, the most important technique is pre-selection, the
neceassayrry method for sorters who last more than 2 weeks at ups. Sara was
the best before I walked into the building. King Rooster.

n s ? foot / hand

e w ? hand \ foot

No survivors for n, e> 0. La cooka rach tja.
--
-- --
--
Wade Ward

"In any given barnyard, there can be only one rooster."
Wade Ward
"I put my pants on like any other 6: between four and a dozen failures."
{~._.~} The Naked Picture Poster from Down Under
`( Y )`
 
W

Wade Ward

john,

i need the moon and keoth or ashley judd; with a herat-shaped ass. That
looks ... crass butt UK sichbdjhdfmcjcf
lpf No survivors for n, e> 0. La cooka rach tja.
you have 24 x 10 hours

mpj

--
-- --
-- I'm using a bst to kill bugs today. 32 kills so far. That is an
authentic task.

During sorting, the most important technique is pre-selection, the
neceassayrry method for sorters who last more than 2 weeks at ups. Sara was
the best before I walked into the building. King Rooster.

n s ? foot / hand

e w ? hand \ foot

No survivors for n, e> 0. La cooka rach tja.
--
-- --
--
Wade Ward

"In any given barnyard, there can be only one rooster."
Wade Ward
"I put my pants on like any other 6: between four and a dozen failures."
{~._.~} The Naked Picture Poster from Down Under
`( Y )`
 
W

Wade Ward

conjecture: there are 2^n

pieces of metal on my living room florr

When enrico fermi counted the nakgpdjdndu , my guess is thai i it w as as
avbecwecevwnsdcwedevendfedfe. even chi tja

3 s

--
-- --
-- I'm using a bst to kill bugs today. 32 kills so far. That is an
authentic task.

During sorting, the most important technique is pre-selection, the
neceassayrry method for sorters who last more than 2 weeks at ups. Sara was
the best before I walked into the building. King Rooster.

n s ? foot / hand

e w ? hand \ foot

No survivors for n, e> 0. La cooka rach tja.
--
-- --
--
Wade Ward

"In any given barnyard, there can be only one rooster."
Wade Ward
"I put my pants on like any other 6: between four and a dozen failures."
{~._.~} The Naked Picture Poster from Down Under
`( Y )`
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top