← Back to team overview

dolfin team mailing list archive

Re: Use of real/double

 

On Thu, Oct 02, 2008 at 03:55:04PM +0200, Anders Logg wrote:
> On Thu, Oct 02, 2008 at 02:19:27PM +0100, Garth N. Wells wrote:
> > 
> > 
> > Anders Logg wrote:
> > > We are currently using "real" (almost) everywhere in the code instead
> > > of "double". real is a typedef for double defined in dolfin/common/types.h:
> > > 
> > >   typedef double real;
> > > 
> > > The reason for this typedef has been to prepare for changing from
> > > double to another (higher) precision representation at some point in
> > > the future.
> > > 
> > > We (Benjamin Kehlet) have now tried to do this using GMP
> > > (http://gmplib.org), but this fails for many reasons. For example,
> > > standard math functions (abs, pow, exp) only work with double. Another
> > > more obvious reason is dependencies on external libraries like PETSc,
> > > UFC, libxml2, GTS etc where double is hard-coded.
> > > 
> > > Our conclusion is that there is little reason to keep the typedef in
> > > DOLFIN since it is just an alias for double and it can not easily be
> > > changed to anything else. I suggest we remove it and replace "real"
> > > with "double" everywhere. Any objections to this?
> > > 
> > > The reason we are experimenting with GMP is that we want to use the
> > > ODE solvers to solve ODEs with very high precision. For this reason,
> > > we are planning to
> > > 
> > > 1. Put back typedef real (after first removing it) and only use it
> > > under dolfin/ode/. If DOLFIN is built without GMP, it will just be a
> > > typedef for double. Otherwise, it will be a GMP type.
> > > 
> > > 2. Change the ODE solver interface from
> > > 
> > >   void f(const uBLASVector& u, real t, uBLASVector& y);
> > > 
> > > to
> > > 
> > >   void f(const real* u, real t, real* y);
> > > 
> > > uBLAS will be used internally (with some additional copying of data
> > > from real to double).
> > > 
> > > Any objections to this?
> > > 
> > 
> > Sounds fine to me.
> 
> ok, I'll make the change. It will be a nightmare...
> 
> > While you're at it, would it be useful to change the typedef for uint 
> > from unsigned integer to std::size_t?
> > 
> > Garth
>
> Sounds good.

On second thought, not so good. We use "unsigned int" in many of the
demos and UFC uses "unsigned int". I ran into a lot of trouble trying
to replace it.

-- 
Anders

Attachment: signature.asc
Description: Digital signature


References