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

Merge branch 'fix/hyperdual' into 'master'

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

See merge request !42
parents 32ab93a7 a5e55e5c
Branches
No related tags found
1 merge request!42Fix: Implement std::numeric_limits and Dune::MathematicalConstants for hyperdual numbers
Pipeline #29973 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