[boost] Re: [math constants] a new approach (perhaps)
by Thorsten Ottosen other posts by this author
Mar 1 2004 1:12PM messages near this date
[boost] Re: [math constants] a new approach (perhaps)
|
[boost] Re: [math constants] a new approach (perhaps)
> With no offense intended, but that's a very simple version which doesn't
> work in many situations. The problems of your solution are:
>
> - Doesn't work well for UDTs (try std::complex, some conversions are
> ambiguous then)
What rule of the language prohibit this conversion? My vc71 compiler can do
it, como and g++
cannot.
> - Doesn't scale for new types (you need to know all of them in the
> single header that defines the constant)
You could add the overloads with eg a macro in your own header. What should
hinder this?
> - Doesn't work for more complex expressions (pi*pi*t instead of T(pi)*pi*t)
true, but what precision does pi*pi have? IMO, it's good to have that
information in the code.
> - Doesn't work for function calls (srqt(pi)*t instead of sqrt(T(pi))*t)
again it a matter of being explicit about which overloaded version you want
to call;
therefore one would always add T().
> - Doesn't solve the naming dilemma (how to spell the constant "pi*pi"?)
is pi_square that bad?
> - Doesn't work well with unit libraries AFAICS (again not scaling well)
how?
> I really suggest you look at my code at
> <http://groups.yahoo.com/group/boost/files/MathConstants/>, which solves
> all of the above points. Feel free to ask questions.
Is there any documentation?
> From your example file:
std::cout << pi.get< float > () << std::endl;
which is float( pi ) spelt more elaborate.
std::cout << pi + pi - pi * pi / pi + d << std::endl;
how often does such an expression occur in practice? Afterall, a single pi
would do.
std::cout << sqrt( sqrt( two + pi ) ) + d << std::endl;
will everything left of d be a constant? If so, what would the point be?
Thanks
Thorsten
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Thread:
Thorsten Ottosen
Thorsten Ottosen
Daniel Frey
Thorsten Ottosen
Daniel Frey
Thorsten Ottosen
Daniel Frey
Thorsten Ottosen
Guillaume Melquiond
Daniel Frey
Bronek Kozicki
Bronek Kozicki
Bronek Kozicki
Daniel Frey
Bronek Kozicki
Daniel Frey
Daniel Frey
Bronek Kozicki
Daniel Frey
Daniel Frey
Bronek Kozicki
Daniel Frey
Bronek Kozicki
Bronek Kozicki
Daniel Frey
Paul A Bristow
Paul A Bristow
Paul A Bristow
Paul A Bristow
Phil Richards
Daniel Frey
Paul A Bristow
David Abrahams
Paul A Bristow
David Abrahams
|