oulan bator said:
and last interogation: which the best algorithm to perform complex
multiplication and division using usual floating point operation only ?
(this was my initial question)
The word "best" has no definition in that sentence. Best for what? For
some kinds of calculations, it's best to represent floating point
numbers in polar coordinates, for example; and for others, in cartesian
coordinates. Obviously, the implementations will differ greatly
depending on the underlying representation.
Assuming cartesian coordinates (since they are fairly normal), complex
number arithmetic is just an algebraic problem. You end up with:
(a + ib) * (c + id) = (ac - bd) + i(bc + ad)
(a + ib) / (c + id) = ((ac + bd) + i(bc - ad)) / (c^2 + d^2)
Even division involves only 11 floating point operations. It's a bit
too straight-forward to use the word "algorithm" as you do above.
Incidentally, if the underlying processor has the capability to perform
these calculations in fewer instructions, then it is possible that the
JIT will recognize this during optimization and generate the more
efficient code. It depends on the compiler, of course.
As for object instantiation, *if* this becomes a problem then you can
tweak the design... for example by adding operate-and-replace operations
that place the results of a calculation directly into one of the
operands and avoid any object instantiation. However, keep in mind that
short-lived object instantiation in a garbage collected language is
cheap. This may not be a concern.
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation