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

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] Does c++ use of "norm" bother anyone else?*From*: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>*Date*: Thu, 18 Jun 2009 13:40:34 +0200*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=lZ+qb1C5TEVc6tCTCDoHx6ouSlFsGnNCR5wgsBOKQ0c=; b=K5hHYFviYeQ8u2exLEY6IIkMpjNfgdkNIeL28CqNHxSRdCvDJgLKf6/LAgTUCsA2I1 IpFMs1EFaQq6XEP5xnz2kl7oTfhC4qczZQ0hTAx3EZuk7AUHR8TPfS9FiUMSMNFAtCod M6Zxv+DWmLVO2RKAGb3+thttHh0y6BH0/eBeA=*Domainkey-signature*: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=Ll+rtqLIg/VZEADOS03Jym4AJbOxLq80xgDqYfM5P9l/PP7ClMedOZWOv5+oZ4PMsj CXaN+yGeclbyagXusvkIsnkCryI4s40lwJKjfIHKlTTfikAthBUkpQL+8vcIaMsbcQ8K 2bEAXwrKQdNyt/b3V62Il+cPQGSZIkbA3lAZY=

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: http://en.wikipedia.org/wiki/Field_norm#Example ) > 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 > like EIGEN_COMPLEX_PROVIDE_DEFECTIVE_NORM). 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. Benoit

**Follow-Ups**:**Re: [eigen] Does c++ use of "norm" bother anyone else?***From:*Markus Moll

**References**:**[eigen] Does c++ use of "norm" bother anyone else?***From:*Mark Borgerding

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

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

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

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] Does c++ use of "norm" bother anyone else?** - Next by Date:
**Re: [eigen] Does c++ use of "norm" bother anyone else?** - Previous by thread:
**Re: [eigen] Does c++ use of "norm" bother anyone else?** - Next by thread:
**Re: [eigen] Does c++ use of "norm" bother anyone else?**

Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |