64 {
return size() + 1; }
82 for (
const auto& v: data_)
83 Valgrind::CheckDefined(v);
100 template <
class RhsValueType>
113 template <
class RhsValueType>
117 assert(0 <= varPos && varPos <
size());
122 data_[varPos +
dstart_()] = 1.0;
128 void clearDerivatives()
161 template <
class RhsValueType>
162 static Evaluation createVariable(
const RhsValueType& value,
int varPos)
169 template <
class RhsValueType>
170 static Evaluation createVariable(
int nVars,
const RhsValueType& value,
int varPos)
173 throw std::logic_error(
"This statically-sized evaluation can only represent objects"
174 " with 9 derivatives");
181 template <
class RhsValueType>
192 template <
class RhsValueType>
193 static Evaluation createConstant(
int nVars,
const RhsValueType& value)
196 throw std::logic_error(
"This statically-sized evaluation can only represent objects"
197 " with 9 derivatives");
203 template <
class RhsValueType>
204 static Evaluation createConstant(
const RhsValueType& value)
211 template <
class RhsValueType>
220 assert(
size() == other.size());
222 data_[1] = other.data_[1];
223 data_[2] = other.data_[2];
224 data_[3] = other.data_[3];
225 data_[4] = other.data_[4];
226 data_[5] = other.data_[5];
227 data_[6] = other.data_[6];
228 data_[7] = other.data_[7];
229 data_[8] = other.data_[8];
230 data_[9] = other.data_[9];
237 assert(
size() == other.size());
239 data_[0] += other.data_[0];
240 data_[1] += other.data_[1];
241 data_[2] += other.data_[2];
242 data_[3] += other.data_[3];
243 data_[4] += other.data_[4];
244 data_[5] += other.data_[5];
245 data_[6] += other.data_[6];
246 data_[7] += other.data_[7];
247 data_[8] += other.data_[8];
248 data_[9] += other.data_[9];
254 template <
class RhsValueType>
255 Evaluation& operator+=(
const RhsValueType& other)
266 assert(
size() == other.size());
268 data_[0] -= other.data_[0];
269 data_[1] -= other.data_[1];
270 data_[2] -= other.data_[2];
271 data_[3] -= other.data_[3];
272 data_[4] -= other.data_[4];
273 data_[5] -= other.data_[5];
274 data_[6] -= other.data_[6];
275 data_[7] -= other.data_[7];
276 data_[8] -= other.data_[8];
277 data_[9] -= other.data_[9];
283 template <
class RhsValueType>
284 Evaluation& operator-=(
const RhsValueType& other)
295 assert(
size() == other.size());
306 data_[1] = data_[1] * v + other.data_[1] * u;
307 data_[2] = data_[2] * v + other.data_[2] * u;
308 data_[3] = data_[3] * v + other.data_[3] * u;
309 data_[4] = data_[4] * v + other.data_[4] * u;
310 data_[5] = data_[5] * v + other.data_[5] * u;
311 data_[6] = data_[6] * v + other.data_[6] * u;
312 data_[7] = data_[7] * v + other.data_[7] * u;
313 data_[8] = data_[8] * v + other.data_[8] * u;
314 data_[9] = data_[9] * v + other.data_[9] * u;
320 template <
class RhsValueType>
321 Evaluation& operator*=(
const RhsValueType& other)
340 assert(
size() == other.size());
346 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
347 data_[2] = (v*data_[2] - u*other.data_[2])/(v*v);
348 data_[3] = (v*data_[3] - u*other.data_[3])/(v*v);
349 data_[4] = (v*data_[4] - u*other.data_[4])/(v*v);
350 data_[5] = (v*data_[5] - u*other.data_[5])/(v*v);
351 data_[6] = (v*data_[6] - u*other.data_[6])/(v*v);
352 data_[7] = (v*data_[7] - u*other.data_[7])/(v*v);
353 data_[8] = (v*data_[8] - u*other.data_[8])/(v*v);
354 data_[9] = (v*data_[9] - u*other.data_[9])/(v*v);
361 template <
class RhsValueType>
362 Evaluation& operator/=(
const RhsValueType& other)
383 assert(
size() == other.size());
393 template <
class RhsValueType>
394 Evaluation operator+(
const RhsValueType& other)
const
406 assert(
size() == other.size());
416 template <
class RhsValueType>
417 Evaluation operator-(
const RhsValueType& other)
const
432 result.data_[0] = - data_[0];
433 result.data_[1] = - data_[1];
434 result.data_[2] = - data_[2];
435 result.data_[3] = - data_[3];
436 result.data_[4] = - data_[4];
437 result.data_[5] = - data_[5];
438 result.data_[6] = - data_[6];
439 result.data_[7] = - data_[7];
440 result.data_[8] = - data_[8];
441 result.data_[9] = - data_[9];
448 assert(
size() == other.size());
457 template <
class RhsValueType>
458 Evaluation operator*(
const RhsValueType& other)
const
469 assert(
size() == other.size());
478 template <
class RhsValueType>
479 Evaluation operator/(
const RhsValueType& other)
const
488 template <
class RhsValueType>
489 Evaluation& operator=(
const RhsValueType& other)
500 template <
class RhsValueType>
501 bool operator==(
const RhsValueType& other)
const
502 {
return value() == other; }
504 bool operator==(
const Evaluation& other)
const
506 assert(
size() == other.size());
508 for (
int idx = 0; idx <
length_(); ++idx) {
509 if (data_[idx] != other.data_[idx]) {
516 bool operator!=(
const Evaluation& other)
const
517 {
return !operator==(other); }
519 template <
class RhsValueType>
520 bool operator!=(
const RhsValueType& other)
const
521 {
return !operator==(other); }
523 template <
class RhsValueType>
524 bool operator>(RhsValueType other)
const
525 {
return value() > other; }
529 assert(
size() == other.size());
531 return value() > other.value();
534 template <
class RhsValueType>
535 bool operator<(RhsValueType other)
const
536 {
return value() < other; }
540 assert(
size() == other.size());
542 return value() < other.value();
545 template <
class RhsValueType>
546 bool operator>=(RhsValueType other)
const
547 {
return value() >= other; }
549 bool operator>=(
const Evaluation& other)
const
551 assert(
size() == other.size());
553 return value() >= other.value();
556 template <
class RhsValueType>
557 bool operator<=(RhsValueType other)
const
558 {
return value() <= other; }
560 bool operator<=(
const Evaluation& other)
const
562 assert(
size() == other.size());
564 return value() <= other.value();
572 template <
class RhsValueType>
573 void setValue(
const RhsValueType& val)
577 const ValueType& derivative(
int varIdx)
const
579 assert(0 <= varIdx && varIdx <
size());
581 return data_[
dstart_() + varIdx];
585 void setDerivative(
int varIdx,
const ValueType& derVal)
587 assert(0 <= varIdx && varIdx <
size());
589 data_[
dstart_() + varIdx] = derVal;
592 template<
class Serializer>
593 void serializeOp(Serializer& serializer)
599 std::array<ValueT, 10> data_;