[Dune] Dune on Windows MinGW

Carsten Gräser graeser at math.fu-berlin.de
Wed May 4 12:27:41 CEST 2011


Am 04.05.2011 11:33, schrieb Jö Fahlke:
> 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 ); }
>> };
I also like this approach.

> 
> 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()?)

Indeed such functions are really expensive. However the compiler can optimize
such calls with compile time known arguments. At least my gcc-4.4 does this
even with -O0.

Best,
Carsten

> 
> 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ö.
> 
> 
> 
> 
> _______________________________________________
> Dune mailing list
> Dune at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune


-- 
----------------------------------------------------------------------
Carsten Gräser           | phone: +49-30 / 838-75349
Freie Universität Berlin | fax  : +49-30 / 838-54977
Institut für Mathematik  | email: graeser at math.fu-berlin.de
Arnimallee 6             |
14195 Berlin, Germany    | URL  : http://page.mi.fu-berlin.de/graeser
----------------------------------------------------------------------




More information about the Dune mailing list