
Somewhere in the E.U., le 22/11/2004 Bonjour In article <6.1.0.6.2.20041120224709.026b7c40@pop-server.austin.rr.com>, Mickey Moore <mgmoore@austin.rr.com> wrote:
I wanted to gauge whether there might be interest in a class for complex numbers with data stored in polar form. For some applications, polar
I am unsure of any widespread interest in such a thing.
complex numbers have significant advantages over Cartesian complex (e.g., std::complex) in efficiency and numerical accuracy. (I spent some time
Yes.
Googling and, somewhat to my surprise, didn't find any freely available versions of this.)
I have a fairly well developed class that implements this; "boosting" it to be worthy of consideration would probably be straight-forward but non-trivial. My version of this is of course templated on the contained numeric type. It is also uses a policy-based design that determines whether or not the polar angle phi is always maintained in principal form or not and what constitutes principal form (default: no, -pi < phi <= pi).
Thanks, Mickey Moore
---------------------------------------- Mitchell G. (Mickey) Moore, Ph.D. mgmoore@austin.rr.com
The main problems I foresee are in the commingling of the two different classes. It is interesting to see a complex number (among other ways) either as its two canonical coordinates, or in a polar representation, but sometimes we just want to switch between the two for a given instance. So I fear a substantial amount of typical run time will be spent doing conversions. There is another, perhaps deeper, problem to consider, with the representation of complex numbers (and others), as evidenced by a thread on comp.std.c++ a couple of years back: layout guaranties. People wanted, in essence, to be able to break encapsulation when it suited them (for efficiency in time-critical code). The discussion also encompassed thoughts about the polar representation (which, as you remarked, also has advantages). As far as I know, there has been no tangible result to that thread. In short, I am not sure a library for complex numbers in polar form would be worthwile, but I certainly think that if you could make the above situation progress (as in: write a formal proposal), it would be a great win for us all. Bon courage Hubert Holin