diff options
author | 2019-10-31 21:53:50 +0100 | |
---|---|---|
committer | 2019-10-31 21:53:50 +0100 | |
commit | c6b281685d16c02b83b1b0c89acae392ecf851ff (patch) | |
tree | 2cd979f919b39e1feeffbde0b22462db59a6492a /src/lib/netlist/prg/nltool.cpp | |
parent | 6c075e602cf83b379b8fa2c981694134b679a538 (diff) |
netlist: Compile with float/double floating point. [Couriersud]
Added ability to compile using float instead of double. Specifically the
the solver as well as the infrastructure now can have their own floating
point type. Currently this is only an academic exercise since
numerically demanding circuits like kidniki only work with double/double
support. Using float here is pushing numerical stability over the
limits.
The long term design goal is too have the matrix type (double/float)
being a parameter.
Diffstat (limited to 'src/lib/netlist/prg/nltool.cpp')
-rw-r--r-- | src/lib/netlist/prg/nltool.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/lib/netlist/prg/nltool.cpp b/src/lib/netlist/prg/nltool.cpp index 5f25ac20219..20a37d24ff1 100644 --- a/src/lib/netlist/prg/nltool.cpp +++ b/src/lib/netlist/prg/nltool.cpp @@ -311,11 +311,14 @@ struct input_t : m_value(0.0) { std::array<char, 400> buf; // NOLINT(cppcoreguidelines-pro-type-member-init) - nl_fptype t(0); + double t(0); + double val(0); + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) - int e = std::sscanf(line.c_str(), "%lf,%[^,],%lf", &t, buf.data(), &m_value); + int e = std::sscanf(line.c_str(), "%lf,%[^,],%lf", &t, buf.data(), &val); if (e != 3) throw netlist::nl_exception(plib::pfmt("error {1} scanning line {2}\n")(e)(line)); + m_value = static_cast<nl_fptype>(val); m_time = netlist::netlist_time::from_double(t); m_param = setup.find_param(pstring(buf.data()), true); } |