30 template<
int PolySize>
37 for (
int i = 0; i < PolySize; ++i)
44 template<
int PolySize>
51 for (
int i=0; i<PolySize; i++)
53 this->v_[i] = coeffs[i];
58 template<
int PolySize>
65 if (coeffs.
size() != PolySize)
68 <<
"Size mismatch: Needed " << PolySize
69 <<
" but given " << coeffs.
size()
73 for (
int i = 0; i < PolySize; ++i)
75 this->v_[i] = coeffs[i];
80 template<
int PolySize>
89 template<
int PolySize>
101 <<
"Expected polynomial name " << name <<
" but read " << isName
108 if (this->size() == 0)
111 <<
"Polynomial coefficients for entry " << isName
119 template<
int PolySize>
126 template<
int PolySize>
133 template<
int PolySize>
136 scalar val = this->v_[0];
139 for (
label i=1; i<PolySize; ++i)
142 val += this->v_[i]*powX;
147 val += logCoeff_*
log(x);
154 template<
int PolySize>
161 deriv += this->v_[1];
164 for (
label i=2; i<PolySize; ++i)
167 deriv += i*this->v_[i]*powX;
173 deriv += logCoeff_/
x;
180 template<
int PolySize>
190 scalar integ = this->v_[0]*(powX2 - powX1);
191 for (
label i=1; i<PolySize; ++i)
195 integ += this->v_[i]/(i + 1)*(powX2 - powX1);
200 integ += logCoeff_*((x2*
log(x2) - x2) - (x1*
log(x1) - x1));
207 template<
int PolySize>
213 newCoeffs[0] = intConstant;
216 newCoeffs[i+1] = this->v_[i]/(i + 1);
223 template<
int PolySize>
229 if (this->v_[0] > vSmall)
231 newCoeffs.logActive_ =
true;
232 newCoeffs.logCoeff_ = this->v_[0];
235 newCoeffs[0] = intConstant;
236 for (
label i=1; i<PolySize; ++i)
238 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.