[Lemon-devel] Math constants in C++

Alpár Jüttner alpar at cs.elte.hu
Mon Feb 4 10:53:47 CET 2008


> Why do we have lemon::dim2?

The only reason is to enable us to also have 3 dimensional points in to
future. In fact, lemon::dim2::Point used to be called lemon::xy and the
3dim version would have been called lemon::xyz. These names worked well,
they do not conform to our conventions. Then another idea was to call
them  Xy, but it looked very stupid. Thus came the namespace dim2 (and
possibly dim3 in the future).

>  I think if we have lemon::dim2 for Point, 
> BoundingBox, etc., then we should have lemon::math for constants.

If we want to provide any alternative declaration for PI in the future,
then of course we should. :)

Regards,
Alpar


> Alpár Jüttner írta:
> > Hi,
> > 
> >>  >       * Is that OK to declare all these constants as 'const long
> >>  >         double'?
> >> Does it cause warnings, e.g. in 'double x = 2 * PI;'?
> > 
> > Could you investigate the answer for this?
> > 
> >>  >       * Do we need to provide all of the original math.h constants for
> >>  >         'compatibility'?
> >>
> >> I don't think so, I suggest only the ones that are used in LEMON or that
> >> are really important for another reason. (E.g. E is important even if it
> >> is not used in LEMON yet.)
> > 
> > In fact E _is_ used in lemon. (That is why I faced with this whole
> > problem.)
> > The constants in math.h are PI, E and SQRT2, LN2, , LN10, LOG2E, LOG10E,
> > (which seem to be reasonably important) and the reciprocal of some of
> > them (hopefully we don't need them because of optimization).
> > 
> >> What about a separate namespace, e.g. lemon::math (or lemon::constants)?
> >> I think lemon::math::PI, lemon::math::E would be very good.
> > 
> > Yes, they look good. But are they better in any aspect then lemon:PI and
> > lemon:E?
> > 
> >> What about prefix 'C_'?
> > 
> > The only reason why namespaces exist in C++ is to avoid all these kind
> > of prefixes.
> > 
> > Regars,
> > Alpar
> > 
> > _______________________________________________
> > Lemon-devel mailing list
> > Lemon-devel at lemon.cs.elte.hu
> > http://lemon.cs.elte.hu/mailman/listinfo/lemon-devel
> 
> _______________________________________________
> Lemon-devel mailing list
> Lemon-devel at lemon.cs.elte.hu
> http://lemon.cs.elte.hu/mailman/listinfo/lemon-devel




More information about the Lemon-devel mailing list