Boost logo

Boost :

Subject: Re: [boost] Determining interest: Pure imaginary number library
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2012-02-29 17:57:25


Le 29/02/12 13:36, Matthieu Schaller a écrit :
> Dear all,
>
> A few months ago I proposed to add an imaginary number class to boost
> in order to extend the std::complex class and improve performance when
> computations involving pure imaginary numbers are involved. Some of
> you showed some interest and proposed some possible improvements, the
> main one being to actually replace the std::complex class by a
> boost::complex and boost::imaginary pair of classes in order for all
> operations to be truly symmetric and closer to the mathematical notation.
>
> I have applied these modifications and the code now corresponds to an
> extended version of Thorsten Ottosen's n1869 proposal
> (http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1869.html)
>
> The sources and documentation are available here :
> http://code.google.com/p/cpp-imaginary-numbers/
> They can be retrieved via the SVN repository or downloaded directly as
> an archive.
>
> The archive contains the complex.hpp header, a performance test, an
> accuracy test and two examples showing the benefits of the imaginary
> numbers in "downscaled" real life situations. I have tentatively
> embedded everything in the boost::math namespace in order to look for
> potential naming conflicts between my code and the existing boost ones.
>
> I would be happy to hear any comment from your side and still hope
> that this work is of some interest to you.
>
Hi,

glad to see you have an almost complete library.

I don't like the comparison between reals and imaginary just because
they share a value.

/// Returns true if x does not equal y
template<typename T>
inline bool operator!=(const imaginary<T>& x, const T& y)
{
     return x.imag() != T(0.) || y != T(0.);
}

I think that I found a copy/paste issue in

template<typename T>
inline complex<T> conj(const complex<T>& x)
{
     return imaginary<T>(x.real(), -x.imag());
}

The line should be
     return complex<T>(x.real(), -x.imag());

I would be great if you can ensure that every function has been tested
at least once ;-)

I guess you could request the library to be added on the review schedule.

Best,
Vicente


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