Boost logo

Boost :

From: helmut.zeisel_at_[hidden]
Date: 2001-06-29 02:23:36


--- In boost_at_y..., Daryle Walker <darylew_at_m...> wrote:

>
> Are we starting it now? I guess the structure could be:
>
> - BOOST_ROOT
> - boost
> - math
> quaternion.hpp
> octonion.hpp
> advanced_trignometric.hpp (atanh, sinc_pi, sinhc_pi)
> rational.hpp
> - libs
> - math
> - doc
> quaternion.html
> octonion.html
> advanced_trignometric.html
> rational.html
> index.html
> + src
> + test
>

How would you handle functions that might have slightly different
implementations depending on the domain?

Look at pow(T x,I n):
it is defined for every integer n if T is
a group (e.g. x is float),
it is defined only for non-negative n if T is a monoid
(e.g. x is int),
and it is defined only for n>0 of T is a semigroup.

Similar things apply to binomial coefficients:

binom(m,n)=binom(m,m-n) if both m and n are integral,
but binom(x,n) != binom(x,x-n) (the latter is not defined)
if x is float.

One solution might be to have a

group::pow,
monoid::pow,
and semigroup::pow.

This might be easier to implement than
to have clever template specialisation techniques
the derive the respective algorithm from the template types.

Helmut


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