Thank you, Ian and Holger, for your explanations and suggestions. I
checked dotprD - it gives closer results.
I didnt suspected what dot product function could be that sensitive to
the order of calculations.
--
Sincerely,
Rustam Muginov
On Nov 7, 2005, at 9:17 PM, Ian Ollmann wrote:
Sometimes the relative error is rather high, like 11% or so.
That does sound like way too much.
This can happen when accumulating mixtures of positive and negative
numbers. Certain subtractions of very similar numbers may cause a loss
of nearly all your precision. (The precision was technically lost in
earlier roundings.) All and all, I'd say it's probably more efficient
to use double precision accumulators than it is to spend time sorting
inputs, however. The precision (and range!) of the product is
completely covered by a double and more of the additions will be
infinitely precise.
Note that double precision can still suffer from the same sorts of
catastrophic cancellation problems. However, it tends to happen much
less often. There do remain cases, particularly with complex
arithmetic, where this sort of problem can happen frequently.
You should probably use a double precision dot product as your
reference for correctness.