Go to the documentation of this file.
41 const scalar
coeff[] = { 0.11, 0.45, -0.94, 1.58, -2.58, 0.08, 3.15, -4.78 };
42 const char*
polyDef =
"(0.11 0.45 -0.94 1.58 -2.58 0.08 3.15 -4.78)";
78 scalar value =
coeff[0];
92 scalar value =
coeff[0];
97 value +=
coeff[i] * powX;
107 int main(
int argc,
char *argv[])
110 const label nIters = 1000;
123 Info<<
"poly = " << poly <<
nl
124 <<
"intPoly = " << intPoly <<
nl
127 Info<<
"2*poly = " << 2*poly <<
nl
128 <<
"poly+poly = " << poly + poly <<
nl
129 <<
"3*poly = " << 3*poly <<
nl
130 <<
"poly+poly+poly = " << poly + poly + poly <<
nl
131 <<
"3*poly - 2*poly = " << 3*poly - 2*poly <<
nl
135 Info<<
"polyf = " << polyfunc <<
nl
136 <<
"intPoly = " << poly.integral(0.0) <<
nl
139 Info<<
"2*polyf = " << 2*polyfunc <<
nl
140 <<
"polyf+polyf = " << polyfunc + polyfunc <<
nl
141 <<
"3*polyf = " << 3*polyfunc <<
nl
142 <<
"polyf+polyf+polyf = " << polyfunc + polyfunc + polyfunc <<
nl
143 <<
"3*polyf - 2*polyf = " << 3*polyfunc - 2*polyfunc <<
nl
148 Info<<
"poly, polyCopy = " << poly <<
", " << polyCopy <<
nl <<
endl;
150 Info<<
"2.5*poly = " << polyCopy <<
nl <<
endl;
153 for (
int i=0; i<10; i++)
160 scalar pxTest = poly.value(
x);
161 scalar ipxTest = intPoly.
value(
x);
164 Info<<
" px, pxTest = " << px <<
", " << pxTest <<
endl;
165 Info<<
" ipx, ipxTest = " << ipx <<
", " << ipxTest <<
endl;
167 if (
mag(px - pxTest) > SMALL)
169 Info<<
" *** WARNING: px != pxTest: " << px - pxTest <<
endl;
172 if (
mag(ipx - ipxTest) > SMALL)
174 Info<<
" *** WARNING: ipx != ipxTest: " << ipx - ipxTest <<
endl;
184 Info<<
"start timing loops" <<
nl
185 <<
"~~~~~~~~~~~~~~~~~~" <<
endl;
189 for (
int loop = 0; loop <
n; ++loop)
192 for (
label iter = 0; iter < nIters; ++iter)
198 <<
" in " <<
timer.cpuTimeIncrement() <<
" s\n";
200 for (
int loop = 0; loop <
n; ++loop)
203 for (
label iter = 0; iter < nIters; ++iter)
209 <<
" in " <<
timer.cpuTimeIncrement() <<
" s\n";
212 for (
int loop = 0; loop <
n; ++loop)
215 for (
label iter = 0; iter < nIters; ++iter)
221 <<
" in " <<
timer.cpuTimeIncrement() <<
" s\n";
224 for (
int loop = 0; loop <
n; ++loop)
227 for (
label iter = 0; iter < nIters; ++iter)
233 <<
" in " <<
timer.cpuTimeIncrement() <<
" s\n";
235 for (
int loop = 0; loop <
n; ++loop)
238 for (
label iter = 0; iter < nIters; ++iter)
244 <<
" in " <<
timer.cpuTimeIncrement() <<
" s\n";
Starts timing CPU usage and return elapsed time from start.
Simple random number generator.
scalar polyValue(const scalar x)
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type & value() const
Return const reference to value.
dimensioned< scalar > mag(const dimensioned< Type > &)
dimensionedScalar pow4(const dimensionedScalar &ds)
dimensionedScalar pow6(const dimensionedScalar &ds)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
dimensionedScalar pow3(const dimensionedScalar &ds)
scalar polyValue2(const scalar x)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
int main(int argc, char *argv[])
scalar value(const scalar x) const
Return polynomial value.
scalar scalar01()
Scalar [0..1] (so including 0,1)
dimensionedScalar pow5(const dimensionedScalar &ds)
Input from memory buffer stream.
scalar value(const scalar x) const
Return polynomial value.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
scalar intPolyValue(const scalar x)
Implements a timeout mechanism via sigalarm.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
Polynomial function representation.
scalar polyValue1(const scalar x)