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()
157 template <
class RhsValueType>
158 static Evaluation createVariable(
const RhsValueType& value,
int varPos)
165 template <
class RhsValueType>
166 static Evaluation createVariable(
int nVars,
const RhsValueType& value,
int varPos)
169 throw std::logic_error(
"This statically-sized evaluation can only represent objects"
170 " with 5 derivatives");
177 template <
class RhsValueType>
188 template <
class RhsValueType>
189 static Evaluation createConstant(
int nVars,
const RhsValueType& value)
192 throw std::logic_error(
"This statically-sized evaluation can only represent objects"
193 " with 5 derivatives");
199 template <
class RhsValueType>
200 static Evaluation createConstant(
const RhsValueType& value)
207 template <
class RhsValueType>
216 assert(
size() == other.size());
218 data_[1] = other.data_[1];
219 data_[2] = other.data_[2];
220 data_[3] = other.data_[3];
221 data_[4] = other.data_[4];
222 data_[5] = other.data_[5];
229 assert(
size() == other.size());
231 data_[0] += other.data_[0];
232 data_[1] += other.data_[1];
233 data_[2] += other.data_[2];
234 data_[3] += other.data_[3];
235 data_[4] += other.data_[4];
236 data_[5] += other.data_[5];
242 template <
class RhsValueType>
243 Evaluation& operator+=(
const RhsValueType& other)
254 assert(
size() == other.size());
256 data_[0] -= other.data_[0];
257 data_[1] -= other.data_[1];
258 data_[2] -= other.data_[2];
259 data_[3] -= other.data_[3];
260 data_[4] -= other.data_[4];
261 data_[5] -= other.data_[5];
267 template <
class RhsValueType>
268 Evaluation& operator-=(
const RhsValueType& other)
279 assert(
size() == other.size());
290 data_[1] = data_[1] * v + other.data_[1] * u;
291 data_[2] = data_[2] * v + other.data_[2] * u;
292 data_[3] = data_[3] * v + other.data_[3] * u;
293 data_[4] = data_[4] * v + other.data_[4] * u;
294 data_[5] = data_[5] * v + other.data_[5] * u;
300 template <
class RhsValueType>
301 Evaluation& operator*=(
const RhsValueType& other)
316 assert(
size() == other.size());
322 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
323 data_[2] = (v*data_[2] - u*other.data_[2])/(v*v);
324 data_[3] = (v*data_[3] - u*other.data_[3])/(v*v);
325 data_[4] = (v*data_[4] - u*other.data_[4])/(v*v);
326 data_[5] = (v*data_[5] - u*other.data_[5])/(v*v);
333 template <
class RhsValueType>
334 Evaluation& operator/=(
const RhsValueType& other)
351 assert(
size() == other.size());
361 template <
class RhsValueType>
362 Evaluation operator+(
const RhsValueType& other)
const
374 assert(
size() == other.size());
384 template <
class RhsValueType>
385 Evaluation operator-(
const RhsValueType& other)
const
400 result.data_[0] = - data_[0];
401 result.data_[1] = - data_[1];
402 result.data_[2] = - data_[2];
403 result.data_[3] = - data_[3];
404 result.data_[4] = - data_[4];
405 result.data_[5] = - data_[5];
412 assert(
size() == other.size());
421 template <
class RhsValueType>
422 Evaluation operator*(
const RhsValueType& other)
const
433 assert(
size() == other.size());
442 template <
class RhsValueType>
443 Evaluation operator/(
const RhsValueType& other)
const
452 template <
class RhsValueType>
453 Evaluation& operator=(
const RhsValueType& other)
464 template <
class RhsValueType>
465 bool operator==(
const RhsValueType& other)
const
466 {
return value() == other; }
468 bool operator==(
const Evaluation& other)
const
470 assert(
size() == other.size());
472 for (
int idx = 0; idx <
length_(); ++idx) {
473 if (data_[idx] != other.data_[idx]) {
480 bool operator!=(
const Evaluation& other)
const
481 {
return !operator==(other); }
483 template <
class RhsValueType>
484 bool operator!=(
const RhsValueType& other)
const
485 {
return !operator==(other); }
487 template <
class RhsValueType>
488 bool operator>(RhsValueType other)
const
489 {
return value() > other; }
493 assert(
size() == other.size());
495 return value() > other.value();
498 template <
class RhsValueType>
499 bool operator<(RhsValueType other)
const
500 {
return value() < other; }
504 assert(
size() == other.size());
506 return value() < other.value();
509 template <
class RhsValueType>
510 bool operator>=(RhsValueType other)
const
511 {
return value() >= other; }
513 bool operator>=(
const Evaluation& other)
const
515 assert(
size() == other.size());
517 return value() >= other.value();
520 template <
class RhsValueType>
521 bool operator<=(RhsValueType other)
const
522 {
return value() <= other; }
524 bool operator<=(
const Evaluation& other)
const
526 assert(
size() == other.size());
528 return value() <= other.value();
536 template <
class RhsValueType>
537 void setValue(
const RhsValueType& val)
541 const ValueType& derivative(
int varIdx)
const
543 assert(0 <= varIdx && varIdx <
size());
545 return data_[
dstart_() + varIdx];
549 void setDerivative(
int varIdx,
const ValueType& derVal)
551 assert(0 <= varIdx && varIdx <
size());
553 data_[
dstart_() + varIdx] = derVal;
556 template<
class Serializer>
557 void serializeOp(Serializer& serializer)
563 std::array<ValueT, 6> data_;