Skip to content
Snippets Groups Projects
Commit bae3091e authored by Tobias Leibner's avatar Tobias Leibner
Browse files

[math/test.main] fix for compilation with gcc 7

- see https://gcc.gnu.org/gcc-6/porting_to.html#overloaded-abs
parent d59c23ac
No related branches found
No related tags found
No related merge requests found
// This file is part of the dune-xt-common project:
// https://github.com/dune-community/dune-xt-common
// Copyright 2009-2018 dune-xt-common developers and contributors. All rights reserved.
// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
// or GPL-2.0+ (http://opensource.org/licenses/gpl-license)
// with "runtime exception" (http://www.dune-project.org/license.html)
// Authors:
// Andreas Buhr (2014)
// Felix Schindler (2012 - 2018)
// Rene Milk (2010 - 2018)
// Sven Kaulmann (2013)
// Tobias Leibner (2014, 2017)
#ifndef DUNE_XT_COMMON_COORDINATES_HH
#define DUNE_XT_COMMON_COORDINATES_HH
#include <dune/xt/common/disable_warnings.hh>
#include <boost/geometry.hpp>
#include <dune/xt/common/reenable_warnings.hh>
#include <dune/xt/common/fvector.hh>
namespace Dune {
namespace XT {
namespace Common {
/** Converts from (x, y, z) to (theta, phi) on the unit sphere s.t.
* (x, y, z) = (sin(theta) cos(phi), sin(theta) sin(phi), cos(theta))
* with 0 \leq \theta \leq \pi and 0 \leq \varphi < 2\pi. **/
template <class DomainFieldType>
class CoordinateConverter
{
typedef typename boost::geometry::model::point<DomainFieldType, 3, typename boost::geometry::cs::cartesian>
BoostCartesianCoordType;
typedef typename boost::geometry::model::
point<DomainFieldType, 2, typename boost::geometry::cs::spherical<boost::geometry::radian>>
BoostSphericalCoordType;
public:
typedef FieldVector<DomainFieldType, 3> CartesianCoordType;
typedef FieldVector<DomainFieldType, 2> SphericalCoordType;
static SphericalCoordType to_spherical(const CartesianCoordType& x)
{
BoostCartesianCoordType x_boost(x[0], x[1], x[2]);
BoostSphericalCoordType x_spherical_boost;
boost::geometry::transform(x_boost, x_spherical_boost);
return SphericalCoordType{boost::geometry::get<1>(x_spherical_boost), boost::geometry::get<0>(x_spherical_boost)};
}
static CartesianCoordType to_cartesian(const SphericalCoordType& x_spherical)
{
BoostSphericalCoordType x_spherical_boost(x_spherical[1], x_spherical[0]);
BoostCartesianCoordType x_boost;
boost::geometry::transform(x_spherical_boost, x_boost);
return CartesianCoordType{
boost::geometry::get<0>(x_boost), boost::geometry::get<1>(x_boost), boost::geometry::get<2>(x_boost)};
}
};
} // namespace Common
} // namespace XT
} // namespace Dune
#endif // DUNE_XT_COMMON_COORDINATES_HH
...@@ -33,5 +33,10 @@ long unsigned int abs(const long unsigned int& value) ...@@ -33,5 +33,10 @@ long unsigned int abs(const long unsigned int& value)
return value; return value;
} }
unsigned char abs(unsigned char value)
{
return value;
}
} // namespace std } // namespace std
...@@ -39,7 +39,6 @@ ...@@ -39,7 +39,6 @@
#include <dune/common/promotiontraits.hh> #include <dune/common/promotiontraits.hh>
#include <dune/xt/common/type_traits.hh> #include <dune/xt/common/type_traits.hh>
#include <dune/xt/common/vector.hh>
namespace Dune { namespace Dune {
namespace XT { namespace XT {
...@@ -298,41 +297,6 @@ inline double binomial_coefficient(const double n, const size_t k) ...@@ -298,41 +297,6 @@ inline double binomial_coefficient(const double n, const size_t k)
} }
/** Converts from (x, y, z) to (theta, phi) on the unit sphere s.t.
* (x, y, z) = (sin(theta) cos(phi), sin(theta) sin(phi), cos(theta))
* with 0 \leq \theta \leq \pi and 0 \leq \varphi < 2\pi. **/
template <class DomainFieldType>
class CoordinateConverter
{
typedef typename boost::geometry::model::point<DomainFieldType, 3, typename boost::geometry::cs::cartesian>
BoostCartesianCoordType;
typedef typename boost::geometry::model::
point<DomainFieldType, 2, typename boost::geometry::cs::spherical<boost::geometry::radian>>
BoostSphericalCoordType;
public:
typedef FieldVector<DomainFieldType, 3> CartesianCoordType;
typedef FieldVector<DomainFieldType, 2> SphericalCoordType;
static SphericalCoordType to_spherical(const CartesianCoordType& x)
{
BoostCartesianCoordType x_boost(x[0], x[1], x[2]);
BoostSphericalCoordType x_spherical_boost;
boost::geometry::transform(x_boost, x_spherical_boost);
return SphericalCoordType{boost::geometry::get<1>(x_spherical_boost), boost::geometry::get<0>(x_spherical_boost)};
}
static CartesianCoordType to_cartesian(const SphericalCoordType& x_spherical)
{
BoostSphericalCoordType x_spherical_boost(x_spherical[1], x_spherical[0]);
BoostCartesianCoordType x_boost;
boost::geometry::transform(x_spherical_boost, x_boost);
return CartesianCoordType{
boost::geometry::get<0>(x_boost), boost::geometry::get<1>(x_boost), boost::geometry::get<2>(x_boost)};
}
};
template <class T> template <class T>
T max(const T& left, const T& right) T max(const T& left, const T& right)
{ {
...@@ -381,6 +345,7 @@ abs(value) ...@@ -381,6 +345,7 @@ abs(value)
* we want to use in our FloatCmp. * we want to use in our FloatCmp.
*/ */
long unsigned int abs(const long unsigned int& value); long unsigned int abs(const long unsigned int& value);
unsigned char abs(unsigned char value);
template <int k> template <int k>
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <boost/numeric/conversion/cast.hpp> #include <boost/numeric/conversion/cast.hpp>
#include <dune/xt/common/math.hh>
#include <dune/common/fvector.hh> #include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh> #include <dune/common/fmatrix.hh>
#include <dune/common/parallel/mpihelper.hh> #include <dune/common/parallel/mpihelper.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