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()
158 template <
class RhsValueType>
159 static Evaluation createVariable(
const RhsValueType& value,
int varPos)
166 template <
class RhsValueType>
167 static Evaluation createVariable(
int nVars,
const RhsValueType& value,
int varPos)
170 throw std::logic_error(
"This statically-sized evaluation can only represent objects"
171 " with 6 derivatives");
178 template <
class RhsValueType>
189 template <
class RhsValueType>
190 static Evaluation createConstant(
int nVars,
const RhsValueType& value)
193 throw std::logic_error(
"This statically-sized evaluation can only represent objects"
194 " with 6 derivatives");
200 template <
class RhsValueType>
201 static Evaluation createConstant(
const RhsValueType& value)
208 template <
class RhsValueType>
217 assert(
size() == other.size());
219 data_[1] = other.data_[1];
220 data_[2] = other.data_[2];
221 data_[3] = other.data_[3];
222 data_[4] = other.data_[4];
223 data_[5] = other.data_[5];
224 data_[6] = other.data_[6];
231 assert(
size() == other.size());
233 data_[0] += other.data_[0];
234 data_[1] += other.data_[1];
235 data_[2] += other.data_[2];
236 data_[3] += other.data_[3];
237 data_[4] += other.data_[4];
238 data_[5] += other.data_[5];
239 data_[6] += other.data_[6];
245 template <
class RhsValueType>
246 Evaluation& operator+=(
const RhsValueType& other)
257 assert(
size() == other.size());
259 data_[0] -= other.data_[0];
260 data_[1] -= other.data_[1];
261 data_[2] -= other.data_[2];
262 data_[3] -= other.data_[3];
263 data_[4] -= other.data_[4];
264 data_[5] -= other.data_[5];
265 data_[6] -= other.data_[6];
271 template <
class RhsValueType>
272 Evaluation& operator-=(
const RhsValueType& other)
283 assert(
size() == other.size());
294 data_[1] = data_[1] * v + other.data_[1] * u;
295 data_[2] = data_[2] * v + other.data_[2] * u;
296 data_[3] = data_[3] * v + other.data_[3] * u;
297 data_[4] = data_[4] * v + other.data_[4] * u;
298 data_[5] = data_[5] * v + other.data_[5] * u;
299 data_[6] = data_[6] * v + other.data_[6] * u;
305 template <
class RhsValueType>
306 Evaluation& operator*=(
const RhsValueType& other)
322 assert(
size() == other.size());
328 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
329 data_[2] = (v*data_[2] - u*other.data_[2])/(v*v);
330 data_[3] = (v*data_[3] - u*other.data_[3])/(v*v);
331 data_[4] = (v*data_[4] - u*other.data_[4])/(v*v);
332 data_[5] = (v*data_[5] - u*other.data_[5])/(v*v);
333 data_[6] = (v*data_[6] - u*other.data_[6])/(v*v);
340 template <
class RhsValueType>
341 Evaluation& operator/=(
const RhsValueType& other)
359 assert(
size() == other.size());
369 template <
class RhsValueType>
370 Evaluation operator+(
const RhsValueType& other)
const
382 assert(
size() == other.size());
392 template <
class RhsValueType>
393 Evaluation operator-(
const RhsValueType& other)
const
408 result.data_[0] = - data_[0];
409 result.data_[1] = - data_[1];
410 result.data_[2] = - data_[2];
411 result.data_[3] = - data_[3];
412 result.data_[4] = - data_[4];
413 result.data_[5] = - data_[5];
414 result.data_[6] = - data_[6];
421 assert(
size() == other.size());
430 template <
class RhsValueType>
431 Evaluation operator*(
const RhsValueType& other)
const
442 assert(
size() == other.size());
451 template <
class RhsValueType>
452 Evaluation operator/(
const RhsValueType& other)
const
461 template <
class RhsValueType>
462 Evaluation& operator=(
const RhsValueType& other)
473 template <
class RhsValueType>
474 bool operator==(
const RhsValueType& other)
const
475 {
return value() == other; }
477 bool operator==(
const Evaluation& other)
const
479 assert(
size() == other.size());
481 for (
int idx = 0; idx <
length_(); ++idx) {
482 if (data_[idx] != other.data_[idx]) {
489 bool operator!=(
const Evaluation& other)
const
490 {
return !operator==(other); }
492 template <
class RhsValueType>
493 bool operator!=(
const RhsValueType& other)
const
494 {
return !operator==(other); }
496 template <
class RhsValueType>
497 bool operator>(RhsValueType other)
const
498 {
return value() > other; }
502 assert(
size() == other.size());
504 return value() > other.value();
507 template <
class RhsValueType>
508 bool operator<(RhsValueType other)
const
509 {
return value() < other; }
513 assert(
size() == other.size());
515 return value() < other.value();
518 template <
class RhsValueType>
519 bool operator>=(RhsValueType other)
const
520 {
return value() >= other; }
522 bool operator>=(
const Evaluation& other)
const
524 assert(
size() == other.size());
526 return value() >= other.value();
529 template <
class RhsValueType>
530 bool operator<=(RhsValueType other)
const
531 {
return value() <= other; }
533 bool operator<=(
const Evaluation& other)
const
535 assert(
size() == other.size());
537 return value() <= other.value();
545 template <
class RhsValueType>
546 void setValue(
const RhsValueType& val)
550 const ValueType& derivative(
int varIdx)
const
552 assert(0 <= varIdx && varIdx <
size());
554 return data_[
dstart_() + varIdx];
558 void setDerivative(
int varIdx,
const ValueType& derVal)
560 assert(0 <= varIdx && varIdx <
size());
562 data_[
dstart_() + varIdx] = derVal;
565 template<
class Serializer>
566 void serializeOp(Serializer& serializer)
572 std::array<ValueT, 7> data_;