summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/plib/pmath.h
diff options
context:
space:
mode:
author couriersud <couriersud@gmx.org>2020-04-26 17:48:38 +0200
committer couriersud <couriersud@gmx.org>2020-04-28 21:08:02 +0200
commit420f4909bef170af33e99c881f9e6e807bea8aaf (patch)
tree920910bac5c2dc744eb637633dc0e3daba1657a3 /src/lib/netlist/plib/pmath.h
parent4c38dd6f929eca2affa88b1f8ffb95c0fe81879f (diff)
netlist: Fix clang-tidy warnings. (nw)
Diffstat (limited to 'src/lib/netlist/plib/pmath.h')
-rw-r--r--src/lib/netlist/plib/pmath.h36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/lib/netlist/plib/pmath.h b/src/lib/netlist/plib/pmath.h
index 819d51159a4..1271707a228 100644
--- a/src/lib/netlist/plib/pmath.h
+++ b/src/lib/netlist/plib/pmath.h
@@ -32,42 +32,45 @@ namespace plib
template <typename T>
struct constants
{
- static inline constexpr T zero() noexcept { return static_cast<T>(0); }
- static inline constexpr T half() noexcept { return static_cast<T>(0.5); }
- static inline constexpr T one() noexcept { return static_cast<T>(1); }
- static inline constexpr T two() noexcept { return static_cast<T>(2); }
- static inline constexpr T three() noexcept { return static_cast<T>(3); }
- static inline constexpr T four() noexcept { return static_cast<T>(4); }
- static inline constexpr T sqrt2() noexcept { return static_cast<T>(1.414213562373095048801688724209L); }
- static inline constexpr T pi() noexcept { return static_cast<T>(3.14159265358979323846264338327950L); }
+ static inline constexpr T zero() noexcept { return static_cast<T>(0); } // NOLINT
+ static inline constexpr T half() noexcept { return static_cast<T>(0.5); } // NOLINT
+ static inline constexpr T one() noexcept { return static_cast<T>(1); } // NOLINT
+ static inline constexpr T two() noexcept { return static_cast<T>(2); } // NOLINT
+ static inline constexpr T three() noexcept { return static_cast<T>(3); } // NOLINT
+ static inline constexpr T four() noexcept { return static_cast<T>(4); } // NOLINT
+ static inline constexpr T hundred()noexcept { return static_cast<T>(100); } // NOLINT
+ static inline constexpr T sqrt2() noexcept { return static_cast<T>(1.414213562373095048801688724209L); } // NOLINT
+ static inline constexpr T pi() noexcept { return static_cast<T>(3.14159265358979323846264338327950L); } // NOLINT
+ static inline constexpr T one_thirds() noexcept { return fraction(one(), three()); }
+ static inline constexpr T two_thirds() noexcept { return fraction(two(), three()); }
/// \brief Electric constant of vacuum
///
- static inline constexpr T eps_0() noexcept { return static_cast<T>(8.854187817e-12); }
+ static inline constexpr T eps_0() noexcept { return static_cast<T>(8.854187817e-12); } // NOLINT
// \brief Relative permittivity of Silicon dioxide
///
- static inline constexpr T eps_SiO2() noexcept { return static_cast<T>(3.9); }
+ static inline constexpr T eps_SiO2() noexcept { return static_cast<T>(3.9); } // NOLINT
/// \brief Relative permittivity of Silicon
///
- static inline constexpr T eps_Si() noexcept { return static_cast<T>(11.7); }
+ static inline constexpr T eps_Si() noexcept { return static_cast<T>(11.7); } // NOLINT
/// \brief Boltzmann constant
///
- static inline constexpr T k_b() noexcept { return static_cast<T>(1.38064852e-23); }
+ static inline constexpr T k_b() noexcept { return static_cast<T>(1.38064852e-23); } // NOLINT
/// \brief room temperature (gives VT = 0.02585 at T=300)
///
- static inline constexpr T T0() noexcept { return static_cast<T>(300); }
+ static inline constexpr T T0() noexcept { return static_cast<T>(300); } // NOLINT
/// \brief Elementary charge
///
- static inline constexpr T Q_e() noexcept { return static_cast<T>(1.6021765314e-19); }
+ static inline constexpr T Q_e() noexcept { return static_cast<T>(1.6021765314e-19); } // NOLINT
/// \brief Intrinsic carrier concentration in 1/m^3 of Silicon
///
- static inline constexpr T NiSi() noexcept { return static_cast<T>(1.45e16); }
+ static inline constexpr T NiSi() noexcept { return static_cast<T>(1.45e16); } // NOLINT
/// \brief clearly identify magic numbers in code
///
@@ -77,6 +80,9 @@ namespace plib
///
template <typename V>
static inline constexpr T magic(V &&v) noexcept { return static_cast<T>(v); }
+
+ template <typename V>
+ static inline constexpr T fraction(V &&v1, V &&v2) noexcept { return static_cast<T>(v1 / v2); }
};
/// \brief typesafe reciprocal function