30 template<
int PolySize>
37 for (
int i = 0; i < PolySize; ++i)
44 template<
int PolySize>
51 logActive_(poly.logActive_),
52 logCoeff_(poly.logCoeff_)
56 template<
int PolySize>
63 for (
int i=0; i<PolySize; i++)
65 this->v_[i] = coeffs[i];
70 template<
int PolySize>
77 if (coeffs.
size() != PolySize)
80 <<
"Size mismatch: Needed " << PolySize
81 <<
" but given " << coeffs.
size()
85 for (
int i = 0; i < PolySize; ++i)
87 this->v_[i] = coeffs[i];
92 template<
int PolySize>
101 template<
int PolySize>
113 <<
"Expected polynomial name " << name <<
" but read " << isName
120 if (this->size() == 0)
123 <<
"Polynomial coefficients for entry " << isName
131 template<
int PolySize>
138 template<
int PolySize>
145 template<
int PolySize>
148 scalar val = this->v_[0];
152 for (
label i=1; i<PolySize; ++i)
155 val += this->v_[i]*powX;
160 val += logCoeff_*
log(x);
167 template<
int PolySize>
175 deriv += this->v_[1];
178 for (
label i=2; i<PolySize; ++i)
181 deriv += i*this->v_[i]*powX;
187 deriv += logCoeff_/
x;
194 template<
int PolySize>
205 scalar integ = this->v_[0]*(powX2 - powX1);
206 for (
label i=1; i<PolySize; ++i)
210 integ += this->v_[i]/(i + 1)*(powX2 - powX1);
215 integ += logCoeff_*((x2*
log(x2) - x2) - (x1*
log(x1) - x1));
222 template<
int PolySize>
228 newCoeffs[0] = intConstant;
231 newCoeffs[i+1] = this->v_[i]/(i + 1);
238 template<
int PolySize>
244 if (this->v_[0] > VSMALL)
246 newCoeffs.logActive_ =
true;
247 newCoeffs.logCoeff_ = this->v_[0];
250 newCoeffs[0] = intConstant;
251 for (
label i=1; i<PolySize; ++i)
253 newCoeffs[i] = this->v_[i]/i;
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
bool logActive() const
Return true if the log term is active.
dimensionedScalar log(const dimensionedScalar &ds)
errorManipArg< error, int > exit(error &err, const int errNo=1)
#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)...
scalar integral(const scalar x1, const scalar x2) const
Return integral between two values.
Polynomial()
Construct null, with all coefficients = 0.0.
A class for handling words, derived from string.
scalar value(const scalar x) const
Return polynomial value.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
word name(const complex &)
Return a string representation of a complex.
Polynomial templated on size (order):
scalar logCoeff() const
Return the log coefficient.
polyType integralMinus1(const scalar intConstant=0.0) const
Return integral coefficients when lowest order is -1.
label size() const
Return the number of elements in the UList.
scalar derivative(const scalar x) const
Return derivative of the polynomial at the given x.