Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sacado_cmath.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Sacado Package
4 //
5 // Copyright 2006 NTESS and the Sacado contributors.
6 // SPDX-License-Identifier: LGPL-2.1-or-later
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef SACADO_CMATH_HPP
11 #define SACADO_CMATH_HPP
12 
13 #include <cmath> // for most math functions
14 #include "Sacado_ConfigDefs.h"
15 
16 namespace Sacado {
17 
18  // Replacement for ternary operator, for scalar types that don't implement
19  // logical operations that return bool, e.g., a simd scalar type that returns
20  // a simd bool. Sacado overloaded operators use this internally when ever
21  // the ternary operator would be used. It can also be used by client code.
22  template <typename Cond, typename T>
24  T if_then_else(const Cond cond, const T& a, const T& b) {
25  return cond ? a : b;
26  }
27 
28  // Special version of sqrt(x) that avoids the NaN if x==0 in the derivative.
29  // The default implementation just calls the standard sqrt(x).
30  template <typename T>
32  T safe_sqrt(const T& x) {
33  using std::sqrt;
34  return sqrt(x);
35  }
36 
37 }
38 
39 #endif // SACADO_CMATH_HPP
#define T
Definition: Sacado_rad.hpp:553
SACADO_INLINE_FUNCTION T if_then_else(const Cond cond, const T &a, const T &b)
sqrt(expr.val())
SACADO_INLINE_FUNCTION T safe_sqrt(const T &x)
#define SACADO_INLINE_FUNCTION