Create Polynomial with coefficients; Expose coefficients

It is possible to create an openmc::Polynominal from the
coefficient vector, rather than reading from a dataset.
An accessor function, Polynominal::coeffs(), was added
that returns the underlying coefficient vector.

These are needed / useful for creating Polynomial instances
with manipulated data.
This commit is contained in:
Andrew Johnson 2019-09-09 17:01:01 -05:00
parent 9036e79c10
commit 998a41fff3
No known key found for this signature in database
GPG key ID: 253418E91B7F6FEB

View file

@ -54,10 +54,17 @@ public:
//! \param[in] dset Dataset containing coefficients
explicit Polynomial(hid_t dset);
//! Construct polynomial using coefficients
//! \param[in] c Coefficients in order of increasing order
Polynomial(std::vector<double> c) : coef_{c} {};
//! Evaluate the polynomials
//! \param[in] x independent variable
//! \return Polynomial evaluated at x
double operator()(double x) const override;
// Accessor
const std::vector<double>&coeffs() const { return coef_; }
private:
std::vector<double> coef_; //!< Polynomial coefficients
};