[Dune] Dune on Windows MinGW

Bård Skaflestad Bard.Skaflestad at sintef.no
Wed May 4 09:59:16 CEST 2011


Hi Martin,

I like the idea of a special purpose container of important constants a
lot.  I've been doing something similar in a few of my own projects
although *much* less refined than what you're suggesting below.  The
ability to include arbitrary precision definitions is particularly
tempting.

Obviously I have no vote in determining what does or does not get into
Dune, but I wholeheartedly support the idea.


Best,

Bård

On Wed, 2011-05-04 at 09:46 +0200, Martin Nolte wrote:
> Hi Bård,
> 
> this is an interesting Detail. Maybe we should consider adding something
> similar to numeric_limits to Dune, i.e., a specialized class containing
> important mathematical constants. It could look somewhat like
> 
> template<>
> struct MathematicalConstants< double >
> {
>   static double e () { return exp( 1 ); }
>   static double pi () { return 3.14...; }
>   static double ln2 () { return log( 2 ); }
> };
> 
> This would be especially interesting in the context of multiprecision floating
> point types (like GMPField), where those numbers might be interesting, too,
> but can only be computed. For such types, this structure might want to
> implement the singleton pattern.
> 
> Best,
> 
> Martin
> 
> 
> On 05/03/2011 08:40 PM, Bård Skaflestad wrote:
> > Andreas, Bernd, All
> > 
> > Sorry to barge in on the discussion, but I'd like to make a little comment concerning the 'M_PI' issue.  Including <cmath> may help on MinGW, but in reality portable code must not reference the preprocessor symbol 'M_PI' without a (more or less manual) separate definition.  Any given implementation may, and many do--particularly on Linux, define 'M_PI' as a (double precision) approximation to \pi as an extension, but no implementation is obliged to provide this symbol.  In fact, when compiling in "maximally standards conforming" mode, an implementation must *not* provide the 'M_PI' symbol.
> > 
> > In short, any code that references 'M_PI' without explicitly defining the symbol itself is non-portable.
> > 
> > 
> > Sincerely,
> 






More information about the Dune mailing list