Boost logo

Boost :

From: Cromwell Enage (sponage_at_[hidden])
Date: 2005-11-08 18:26:52


--- Peder Holt wrote:
> I have implemented the compile-time inverse_sine and
> inverse_tangent (the latter only for x<=1)

Are those arcsine and arctangent metafunctions?
There's an existing implementation of arctangent that
should work for all real numbers.

> but have a bit of a problem with arcus_cosine, which
> is defined as pi/2-inverse_sine.

A problem, indeed.

> So far, all implementations of math metafunctions
> should work with both double_ and your mixed_number
> etc. types, but once we introduce a constant, the
> result type is given, unless there is some clever
way
> of defining the constant several times for all the
> different input types.

Looks like we'll need a pi<> metafunction that takes
in a numeric tag such as double_tag and an integral
constant defining a series limit. Since your double
has a fixed precision, pi<double_tag> can return a
simple typedef and ignore the series limit, while the
primary definition of pi<> has to return the result of
the series. We're not making a "constants library" in
the usual sense, so maybe we can get away with it.

If all interested parties agree with this plan, the
next question is, where should we put pi<>? So far, I
have two candidates:

* boost::mpl::math, since zero<> also resides there
* boost::mpl::math::constants

> Also, I have managed to squeeze more performance out
> of the compiler by replacing integral operations in
> the metafunctions with BOOST_STATIC_CONSTANT.

Yeah, I've discovered this with big_integral, too.
Only backward-compatibility concerns have held me back
from employing this technique elsewhere. (I don't
have a Class B compiler on-hand though, so I don't
know if my fears are unjustified.)

[snip code]

> I think it should be possible to only use 4
> arithmetic meta-operation per term, typically
> (a+b*x*next)/c where a,b and c are calculated using
> BOOST_STATIC_CONSTANT

I'll #ifdef 0 out the code to be replaced.

                              Cromwell D. Enage

        
                
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com


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