diff options
Diffstat (limited to 'src/lib/netlist/plib/pmath.h')
-rw-r--r-- | src/lib/netlist/plib/pmath.h | 36 |
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 |