Re: [eigen] Does c++ use of "norm" bother anyone else?

[ Thread Index | Date Index | More Archives ]

2009/6/18 Markus Moll <markus.moll@xxxxxxxxxxxxxxxx>
> Hi
> On Thursday 18 June 2009 11:44:47 Tim Hutt wrote:
> > >>   norm( complex<float>(3,4) ) == 25
> >
> > Wow that's really bad. I've never heard of this norm being used in
> > mathematics. 'Norm' on its own virtually always means the L2 norm.
> Quite often it just means "any norm" (given that in finite dimensions, all
> norms are equivalent). But in math it certainly means that it satisfies all
> properties of a norm, which L2-squared certainly does not (not scaling
> properly, triangle inequality violated).

Indeed, std::complex norm() isn't a "norm" in this sense. But it still
is called "norm" in other mathematical contexts -- it's not just the
c++ people who were on crack, it's the whole mathematics tradition :)

(Optional part: the other sense of "norm" -- skip if not interested:
let K/k be a Galois extension, let x in K, then the norm of x with
respect to this extension is the product of the sigma(x) for all sigma
in the Galois group of K/k. So for complex numbers, they are a Galois
extension of the real numbers, of degree 2, the Galois group Gal(C/R)
has 2 elements, the identity and complex conjugation, so the norm of a
complex number x is the product x * conj(x)  which is what
std::complex calls norm(). More references:

> So in my opinion, it is a good idea to correct this mistake in C++ and not
> support norm(), or maybe support it if a certain macro is defined (something

as I explain, it's not per se a mistake or a defect. But it still is
very misleading to have both. I don't have a strong opinion, it
depends whether our priority is to have a drop-in replacement for
std::complex, or to start from scratch our ideal complex class.

Actually I think that norm() isn't a method in std::complex, it's only
a global function in std:: , right ? Then I think that it's safe to
implement std::norm also for Eigen::Complex, as it's documented there
what it does. A user using it probably wants it to work as with
std::complex -- as the custom Eigen::Complex API would be implemented
as methods in Eigen::Complex, not as global functions in std.


Mail converted by MHonArc 2.6.19+