22#ifndef RIZER_PROPERTY_TABLE_H
23#define RIZER_PROPERTY_TABLE_H
38 : m_T(std::move(T)), m_v(std::move(values))
40 if (m_T.size() != m_v.size() || m_T.size() < 2) {
41 throw std::invalid_argument(
42 "PropertyTable: T and values must have equal length >= 2");
53 bool empty()
const {
return m_T.empty(); }
57 double eval(
double T)
const {
61 if (T <= m_T.front()) {
64 if (T >= m_T.back()) {
69 auto it = std::upper_bound(m_T.begin(), m_T.end(), T);
70 size_t hi =
static_cast<size_t>(it - m_T.begin());
72 double w = (T - m_T[lo]) / (m_T[hi] - m_T[lo]);
73 return m_v[lo] + w * (m_v[hi] - m_v[lo]);
77 std::vector<double> m_T;
78 std::vector<double> m_v;
static PropertyTable constant(double value)
A two-point constant table returning value for any T.
double eval(double T) const
Linearly interpolated value at T; clamped to the table endpoints.
bool empty() const
True for a default-constructed (empty) table; eval() returns 0.0.
PropertyTable(std::vector< double > T, std::vector< double > values)
Construct from parallel T (strictly increasing, [K]) and value arrays.