Skip to content
Snippets Groups Projects
Commit e25630f3 authored by Martin Nolte's avatar Martin Nolte
Browse files

if we move gmp.m4 to dune-common, we should also move gmpfield.hh

[[Imported from SVN: r5853]]
parent 54a38fcb
No related branches found
No related tags found
No related merge requests found
......@@ -22,7 +22,8 @@ commoninclude_HEADERS = alignment.hh array.hh \
bartonnackmanifcheck.hh binaryfunctions.hh lru.hh fassign.hh \
static_assert.hh smallobject.hh version.hh \
float_cmp.cc float_cmp.hh nullptr.hh \
forloop.hh function.hh interfaces.hh
forloop.hh function.hh interfaces.hh \
gmpfield.hh
if EXPRESSIONTEMPLATES
commoninclude_HEADERS += exprtmpl.hh exprtmpl/scalar.inc exprtmpl/exprexpr.inc
......
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_GMPFIELD_HH
#define DUNE_GMPFIELD_HH
#include <iostream>
#if HAVE_GMP
#include <gmpxx.h>
namespace Dune
{
template< unsigned int precision >
class GMPField
: public mpf_class
{
typedef mpf_class Base;
public:
GMPField ()
: Base(0,precision)
{}
template< class T >
GMPField ( const T &v )
: Base( v,precision )
{}
/*
GMPField &operator=(const GMPField &other)
{
Base(*this) = Base(other);
return *this;
}
*/
};
template< unsigned int precision >
inline GMPField< precision >
operator+ ( const GMPField< precision > &a, const GMPField< precision > &b )
{
typedef mpf_class F;
return ((const F &)a + (const F &)b);
}
template< unsigned int precision >
inline GMPField< precision >
operator- ( const GMPField< precision > &a, const GMPField< precision > &b )
{
typedef mpf_class F;
return ((const F &)a - (const F &)b);
}
template< unsigned int precision >
inline GMPField< precision >
operator- ( const GMPField< precision > &a )
{
typedef mpf_class F;
return -((const F &)a);
}
template< unsigned int precision >
inline GMPField< precision >
operator* ( const GMPField< precision > &a, const GMPField< precision > &b )
{
typedef mpf_class F;
return ((const F &)a * (const F &)b);
}
template< unsigned int precision >
inline GMPField< precision >
operator/ ( const GMPField< precision > &a, const GMPField< precision > &b )
{
typedef mpf_class F;
return ((const F &)a / (const F &)b);
}
template< unsigned int precision >
inline std::ostream &
operator<< ( std::ostream &out, const GMPField< precision > &value )
{
return out << value.get_d();
}
}
#endif // HAVE_GMP
#endif // #ifndef DUNE_MULTIPRECISION_HH
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment