[Dune] Dune on Windows MinGW

Martin Nolte nolte at mathematik.uni-freiburg.de
Wed May 4 09:46:15 CEST 2011


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,

-- 
Martin Nolte <nolte at mathematik.uni-freiburg.de>

Universität Freiburg                                   phone: +49-761-203-5630
Abteilung für angewandte Mathematik                    fax:   +49-761-203-5632
Hermann-Herder-Straße 10
79104 Freiburg, Germany




More information about the Dune mailing list