Boost logo

Boost :

From: Gabriel Dos Reis (Gabriel.Dos-Reis_at_[hidden])
Date: 2001-11-02 23:24:08


Kevin Lynch <krlynch_at_[hidden]> writes:

| nbecker_at_[hidden] wrote:
| >
| > In the current gcc, norm of complex is defined in terms of abs. I
| > believe the definition should be changed to:
| >
| > norm(z) = sqr(real(z)) + sqr (imag (z))
| >
| > My reasons are:
| >
| > 1. More efficient
| > 2. Works for complex<int> (important in DSP)
| > 3. Possibly more accurate
| >
| > I have started a discussion on gcc_at_[hidden] on this subject. I'm
| > wondering if any of you have an opinion.
| >
|
| The implementation you are talking about looks like this, I believe:
|
| template<typename T> inline T norm(const complex<T>& _x){
| T _t = abs(_x);
| return _t * _t;
| }
|
| Frankly, I don't see much point in this change ... norm isn't used that
| often, so efficiency isn't really a concern (It's also not clear to me
| that the resulting code will be any less efficient). I also don't think
| there is really any issue with accuracy; for the cases where both real
| and imag parts are either small or large, there is no accuracy loss, and
| for the other cases, the accuracy difference would be so small as to be
| negligible.

Actually, on the GCC list it was given evidence that the above
implementation is more accurate that the naive approach on the limit
boundaries so nbecker's third point is a non-issue.

[...]

| So, to summarize, while your first and third points may be technically
| correct, I don't see them as worth an implementation change, and your
| second point has too many problems to consider.

I made a change to allow his second point, as part of a QoI. However
I disagree with his third point, therefore his first point is not an
issue.

-- Gaby


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk