Boost logo

Boost :

From: Joerg Walter (jhr.walter_at_[hidden])
Date: 2002-04-08 14:15:32


Hi Kresimir,

you wrote:

> > We were working on the same problem ;-( and you solved it faster :-). I
> > adopted your changes (slightly modified), tested with MSVC and ICC also
and
> > checked them in. Thanks.
>
> You're welcome.
>
> But I must admit that I dislike implementations of `norm_1()'
> and `norm_inf()' in `math.h'. They are, of course, mathematically
> correct, but aren't they unnecessarily inefficient for floats
> and doubles? For large vectors and matrices there can be
> thousands of useless additions of zeros and comparisons
> of nonnegative numbers with zero. I doubt that optimizer,
> even very smart ones, can eliminate them.

The basic idea here was to seperate the needed primitives
(real()/imag()/conj()/abs()/sqrt()) from the norm functions. The next change
I currently anticipate concerns the norm functions: especially norm_2
(euclidean norm) has to be guarded against overflow. Thereafter we should
optimize.

> (BTW, what does comment `Oops, should have known that!'
> mean?)

The first implementation was plain wrong ;-)

> >>PS. I added `#include <algorithm>' and `#include <iterator>' to
> >>`traits.h' because g++ complains that `std::max()' and iterator
> >>tags are unknown.
>
> Still missing (although now, with your definition of `norm_inf()',
> `algorithm' should be included in `math.h' -- but I hope that
> you will change that ;o).

Ok.

> (And AFAICS there is no need for inclusion of `exception.h'
> in `math.h'.)

Ok.

Best regards

Joerg


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