Skip to content
Snippets Groups Projects
Commit a5e55e5c authored by Patrick Jaap's avatar Patrick Jaap
Browse files

Fix: Implement std::numeric_limits and Dune::MathematicalConstants for hyperdual numbers

This is simply done by forwarding to the `double` implementation.
This is safe since `hyperdual` numbers can be constructed from `double` numbers.
parent 32ab93a7
No related branches found
No related tags found
1 merge request!42Fix: Implement std::numeric_limits and Dune::MathematicalConstants for hyperdual numbers
Pipeline #29964 passed
...@@ -605,6 +605,15 @@ bool operator!= (hyperdual lhs, double rhs) ...@@ -605,6 +605,15 @@ bool operator!= (hyperdual lhs, double rhs)
} }
namespace std
{
// Register the type hyperdual for std::numeric_limits by forwarding to std::numeric_limits<double>
template<>
struct numeric_limits<hyperdual> : std::numeric_limits<double>
{};
}
// Dune related definitions with hyperdual numbers // Dune related definitions with hyperdual numbers
namespace Dune namespace Dune
{ {
...@@ -628,6 +637,15 @@ namespace Dune ...@@ -628,6 +637,15 @@ namespace Dune
{ {
using PromotedType = hyperdual; using PromotedType = hyperdual;
}; };
/* Generate constants like "pi", "e", etc. directly from double values
* since calls like "pi = acos(-1)" are not differentiable
*/
template <>
struct MathematicalConstants<hyperdual>
: MathematicalConstants<double>
{};
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment