33 template<
int PolySize>
42 template<
int PolySize>
49 if (coeffs.size() != PolySize)
52 <<
"Size mismatch: Needed " << PolySize
53 <<
" but given " << label(coeffs.size())
57 auto iter = coeffs.begin();
58 for (
int i=0; i<PolySize; ++i)
66 template<
int PolySize>
69 VectorSpace<Polynomial<PolySize>, scalar, PolySize>(),
73 for (
int i=0; i<PolySize; ++i)
75 this->v_[i] = coeffs[i];
80 template<
int PolySize>
83 VectorSpace<Polynomial<PolySize>, scalar, PolySize>(),
87 if (coeffs.size() != PolySize)
90 <<
"Size mismatch: Needed " << PolySize
91 <<
" but given " << coeffs.size()
95 for (
int i = 0; i < PolySize; ++i)
97 this->v_[i] = coeffs[i];
102 template<
int PolySize>
111 template<
int PolySize>
118 const word isName(is);
123 <<
"Expected polynomial name " <<
name <<
" but read " << isName
130 VectorSpace<Polynomial<PolySize>, scalar, PolySize>&
137 template<
int PolySize>
144 template<
int PolySize>
151 template<
int PolySize>
154 scalar val = this->v_[0];
158 for (label i=1; i<PolySize; ++i)
160 val += this->v_[i]*powX;
166 val += logCoeff_*
log(
x);
173 template<
int PolySize>
181 deriv += this->v_[1];
184 for (label i=2; i<PolySize; ++i)
186 deriv += i*this->v_[i]*powX;
193 deriv += logCoeff_/
x;
200 template<
int PolySize>
211 scalar integ = this->v_[0]*(powX2 - powX1);
212 for (label i=1; i<PolySize; ++i)
216 integ += this->v_[i]/(i + 1)*(powX2 - powX1);
221 integ += logCoeff_*((x2*
log(x2) - x2) - (x1*
log(x1) - x1));
228 template<
int PolySize>
232 intPolyType newCoeffs;
234 newCoeffs[0] = intConstant;
237 newCoeffs[i+1] = this->v_[i]/(i + 1);
244 template<
int PolySize>
250 if (this->v_[0] > VSMALL)
252 newCoeffs.logActive_ =
true;
253 newCoeffs.logCoeff_ = this->v_[0];
256 newCoeffs[0] = intConstant;
257 for (label i=1; i<PolySize; ++i)
259 newCoeffs[i] = this->v_[i]/i;
bool logActive() const noexcept
Return true if the log term is active.
dimensionedScalar log(const dimensionedScalar &ds)
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
constexpr char nl
The newline '\n' character (0x0a)
scalar integral(const scalar x1, const scalar x2) const
Return integral between two values.
Polynomial()
Default construct, with all coefficients = 0.
#define forAll(list, i)
Loop across all elements in list.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
A class for handling words, derived from Foam::string.
scalar value(const scalar x) const
Return polynomial value.
scalar logCoeff() const noexcept
Return the log coefficient.
Polynomial templated on size (order):
polyType integralMinus1(const scalar intConstant=0.0) const
Return integral coefficients when lowest order is -1.
scalar derivative(const scalar x) const
Return derivative of the polynomial at the given x.
static constexpr const zero Zero
Global zero (0)