Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2005-05-07 06:21:46

"Cromwell Enage" <sponage_at_[hidden]> wrote

> The following expressions are currently illegal:
> rational<int_<1>,int_<0> >
> rational_c<long,9,-5>

disallowing negative denominator seems a little harsh. 1 / -2 is a valid
mathematical expression.


> I've reimplemented rational<> so that it accepts any
> numeric constants M and N for which modulus<M,N> is a
> valid expression. That should improve its genericity.

FWIW some comments on rational...

1) rational should have a value_type for similarity with integral_c.
( eg plus <Numerator,Denominator>::type::value_type; )

2) Because gcd is not a primitive operation( because it can be expressed solely
in terms of others); Is there a need fo the 'impl and '::apply rigmarole. I
think not(Same for abs, is_negative etc.)Why is this amount of implementation
complexity necessary in gcd?.

3) However OTOH numerator<T> and denominator<T> need to be applicable to
integral_c too(Otherwise there is no advantage over use of member ::denomnator)
, but is a primitive operation; Therefore the 'impl rigmarole should be applied.
denominator <int_<X> >:: type == int_<1>, numerator <int_<X> >:: type ==
int_<X> or whatever. It should be possible to mix rational and integral
parameters pretty easily. FWIW Ive enclosed my rendition of denominator
(hopefully boostified) in this method .

Thanks for working on it though ... ;-)

Andy Little

Boost list run by bdawes at, gregod at, cpdaniel at, john at