[Dune] Dune on Windows MinGW

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


Ok, I just added a first implementation of such a class to dune-common.
Improvements are, of course, welcome. I also think that naming can still be
discussed.

The idea of the file math.hh is to have a "replacement" for the include of
<cmath>, which is included by math.hh. Any objections, suggestions, etc.?

Best,

Martin

On 05/04/2011 12:34 PM, Martin Nolte wrote:
> There is a key difference between static variables and methods: space for the
> static variables has to be declared at exactly one point. In the case of types
> like GMPField< precision >, we would have to know all useful template
> arguments in advance. This is not so with static inline functions that are
> instantiated if and only if they are used.
> 
> To store the expressions in static variables is, of course, still possible
> with the static method approach. For GMPField< precision > I would simply use
> a singleton class.
> 
> Best,
> 
> Martin
> 
> 
> On 05/04/2011 11:33 AM, Jö Fahlke wrote:
>> 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ö.
>>
>>
>>
>>
>> _______________________________________________
>> Dune mailing list
>> Dune at dune-project.org
>> http://lists.dune-project.org/mailman/listinfo/dune
> 

-- 
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