summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib
diff options
context:
space:
mode:
authorGravatarGravatar couriersud <couriersud@gmx.org>2019-11-01 01:50:11 +0100
committerGravatarGravatar couriersud <couriersud@gmx.org>2019-11-01 01:50:33 +0100
commita9d7e55ac21d193db00d416597d999b3da2d9f4f (patch)
treee26a18d9480cb939a747125f41047d5ec5e38d00 /src/lib
parent58c420eeb73edc997d0e6ac3cc28389979a824fe (diff)
netlist: convert constexpr constants into constexpr inline funcs. (nw)
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/netlist/analog/nld_generic_models.h14
-rw-r--r--src/lib/netlist/nl_config.h16
-rw-r--r--src/lib/netlist/solver/nld_matrix_solver.h5
3 files changed, 18 insertions, 17 deletions
diff --git a/src/lib/netlist/analog/nld_generic_models.h b/src/lib/netlist/analog/nld_generic_models.h
index 9f81d71a44c..f33168594fb 100644
--- a/src/lib/netlist/analog/nld_generic_models.h
+++ b/src/lib/netlist/analog/nld_generic_models.h
@@ -158,12 +158,12 @@ namespace analog
//printf("%s: %g %g\n", m_name.c_str(), nVd, (nl_fptype) m_Vd);
if (nVd > m_Vcrit)
{
- const nl_fptype d = std::min(+fp_constants<nl_fptype>::DIODE_MAXDIFF, nVd - m_Vd);
+ const nl_fptype d = std::min(+fp_constants<nl_fptype>::DIODE_MAXDIFF(), nVd - m_Vd);
const nl_fptype a = std::abs(d) * m_VtInv;
m_Vd = m_Vd + (d < 0 ? -1.0 : 1.0) * std::log1p(a) * m_Vt;
}
else
- m_Vd = std::max(-fp_constants<nl_fptype>::DIODE_MAXDIFF, nVd);
+ m_Vd = std::max(-fp_constants<nl_fptype>::DIODE_MAXDIFF(), nVd);
//m_Vd = nVd;
if (m_Vd < m_Vmin)
@@ -189,7 +189,7 @@ namespace analog
else /* log stepping should already be done in mosfet */
{
m_Vd = nVd;
- IseVDVt = std::exp(std::min(+fp_constants<nl_fptype>::DIODE_MAXVOLT, m_logIs + m_Vd * m_VtInv));
+ IseVDVt = std::exp(std::min(+fp_constants<nl_fptype>::DIODE_MAXVOLT(), m_logIs + m_Vd * m_VtInv));
m_Id = IseVDVt - m_Is;
m_G = IseVDVt * m_VtInv + m_gmin;
}
@@ -213,10 +213,10 @@ namespace analog
}
- nl_fptype I() const { return m_Id; }
- nl_fptype G() const { return m_G; }
- nl_fptype Ieq() const { return (m_Id - m_Vd * m_G); }
- nl_fptype Vd() const { return m_Vd; }
+ nl_fptype I() const noexcept { return m_Id; }
+ nl_fptype G() const noexcept { return m_G; }
+ nl_fptype Ieq() const noexcept { return (m_Id - m_Vd * m_G); }
+ nl_fptype Vd() const noexcept { return m_Vd; }
/* owning object must save those ... */
diff --git a/src/lib/netlist/nl_config.h b/src/lib/netlist/nl_config.h
index 45b3e50fc46..58479eae3ef 100644
--- a/src/lib/netlist/nl_config.h
+++ b/src/lib/netlist/nl_config.h
@@ -124,11 +124,11 @@ namespace netlist
template <>
struct fp_constants<double>
{
- static constexpr const double DIODE_MAXDIFF = 1e100;
- static constexpr const double DIODE_MAXVOLT = 300.0;
+ static inline constexpr const double DIODE_MAXDIFF() noexcept { return 1e100; }
+ static inline constexpr double DIODE_MAXVOLT() noexcept { return 300.0; }
- static constexpr const double TIMESTEP_MAXDIFF = 1e100;
- static constexpr const double TIMESTEP_MINDIV = 1e-60;
+ static inline constexpr double TIMESTEP_MAXDIFF() noexcept { return 1e100; }
+ static inline constexpr double TIMESTEP_MINDIV() noexcept { return 1e-60; }
};
/*! Specific constants for float floating point type
@@ -136,11 +136,11 @@ namespace netlist
template <>
struct fp_constants<float>
{
- static constexpr const float DIODE_MAXDIFF = 1e5;
- static constexpr const float DIODE_MAXVOLT = 30.0;
+ static inline constexpr float DIODE_MAXDIFF() noexcept { return 1e5; }
+ static inline constexpr float DIODE_MAXVOLT() noexcept { return 30.0; }
- static constexpr const float TIMESTEP_MAXDIFF = 1e30f;
- static constexpr const float TIMESTEP_MINDIV = 1e-8f;
+ static inline constexpr float TIMESTEP_MAXDIFF() noexcept { return 1e30f; }
+ static inline constexpr float TIMESTEP_MINDIV() noexcept { return 1e-8f; }
};
} // namespace netlist
diff --git a/src/lib/netlist/solver/nld_matrix_solver.h b/src/lib/netlist/solver/nld_matrix_solver.h
index d639218681c..3a14c896d70 100644
--- a/src/lib/netlist/solver/nld_matrix_solver.h
+++ b/src/lib/netlist/solver/nld_matrix_solver.h
@@ -429,7 +429,8 @@ namespace solver
//const nl_fptype DD_n = (n->Q_Analog() - t->m_last_V);
// avoid floating point exceptions
- const nl_fptype DD_n = std::max(-fp_constants<nl_fptype>::TIMESTEP_MAXDIFF, std::min(+fp_constants<nl_fptype>::TIMESTEP_MAXDIFF,(t.getV() - m_last_V[k])));
+ const nl_fptype DD_n = std::max(-fp_constants<nl_fptype>::TIMESTEP_MAXDIFF(),
+ std::min(+fp_constants<nl_fptype>::TIMESTEP_MAXDIFF(),(t.getV() - m_last_V[k])));
const nl_fptype hn = cur_ts;
//printf("%g %g %g %g\n", DD_n, hn, t.m_DD_n_m_1, t.m_h_n_m_1);
@@ -438,7 +439,7 @@ namespace solver
m_h_n_m_1[k] = hn;
m_DD_n_m_1[k] = DD_n;
- if (std::fabs(DD2) > fp_constants<nl_fptype>::TIMESTEP_MINDIV) // avoid div-by-zero
+ if (std::fabs(DD2) > fp_constants<nl_fptype>::TIMESTEP_MINDIV()) // avoid div-by-zero
new_net_timestep = std::sqrt(m_params.m_dynamic_lte / std::fabs(plib::constants<nl_fptype>::cast(0.5)*DD2));
else
new_net_timestep = m_params.m_max_timestep;