[Dune] Dune on Windows MinGW

Jö Fahlke jorrit at jorrit.de
Wed May 4 11:33:29 CEST 2011


Am Wed,  4. May 2011, 09:46:15 +0200 schrieb Martin Nolte:
> 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 ); }
> };

The glibc info documentation recommends "acos(-1.0)" for pi.

I would suggest to use static member variables instead of functions, so the
mathematical functions don't have to be evaluated each time a constant is
needed.  I believe Christian discovered at one point that exp() could be quite
expensive, and that is probably true for the other mathematical functions as
well.  (Or was it pow()?)

Therefore I suggest something more akin to this:

  template<class T>
  struct MathematicalConstants {
    static const T e;
    static const T pi;
    static const T ln2;
    //...
  };
  template<class T> const T MathematicalConstants<T>::e = std::exp(T(1));
  template<class T> const T MathematicalConstants<T>::pi = std::acos(T(-1));
  template<class T> const T MathematicalConstants<T>::ln2 = std::log(T(2));

Of course, I'm all in favour of this idea.

Bye,
Jö.

-- 
Gute Nacht Deutschland.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 828 bytes
Desc: Digital signature
URL: <https://lists.dune-project.org/pipermail/dune/attachments/20110504/bc3057fa/attachment.sig>


More information about the Dune mailing list