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()
162 template <
class RhsValueType>
163 static Evaluation createVariable(
const RhsValueType& value,
int varPos)
170 template <
class RhsValueType>
171 static Evaluation createVariable(
int nVars,
const RhsValueType& value,
int varPos)
174 throw std::logic_error(
"This statically-sized evaluation can only represent objects"
175 " with 10 derivatives");
182 template <
class RhsValueType>
193 template <
class RhsValueType>
194 static Evaluation createConstant(
int nVars,
const RhsValueType& value)
197 throw std::logic_error(
"This statically-sized evaluation can only represent objects"
198 " with 10 derivatives");
204 template <
class RhsValueType>
205 static Evaluation createConstant(
const RhsValueType& value)
212 template <
class RhsValueType>
221 assert(
size() == other.size());
223 data_[1] = other.data_[1];
224 data_[2] = other.data_[2];
225 data_[3] = other.data_[3];
226 data_[4] = other.data_[4];
227 data_[5] = other.data_[5];
228 data_[6] = other.data_[6];
229 data_[7] = other.data_[7];
230 data_[8] = other.data_[8];
231 data_[9] = other.data_[9];
232 data_[10] = other.data_[10];
239 assert(
size() == other.size());
241 data_[0] += other.data_[0];
242 data_[1] += other.data_[1];
243 data_[2] += other.data_[2];
244 data_[3] += other.data_[3];
245 data_[4] += other.data_[4];
246 data_[5] += other.data_[5];
247 data_[6] += other.data_[6];
248 data_[7] += other.data_[7];
249 data_[8] += other.data_[8];
250 data_[9] += other.data_[9];
251 data_[10] += other.data_[10];
257 template <
class RhsValueType>
258 Evaluation& operator+=(
const RhsValueType& other)
269 assert(
size() == other.size());
271 data_[0] -= other.data_[0];
272 data_[1] -= other.data_[1];
273 data_[2] -= other.data_[2];
274 data_[3] -= other.data_[3];
275 data_[4] -= other.data_[4];
276 data_[5] -= other.data_[5];
277 data_[6] -= other.data_[6];
278 data_[7] -= other.data_[7];
279 data_[8] -= other.data_[8];
280 data_[9] -= other.data_[9];
281 data_[10] -= other.data_[10];
287 template <
class RhsValueType>
288 Evaluation& operator-=(
const RhsValueType& other)
299 assert(
size() == other.size());
310 data_[1] = data_[1] * v + other.data_[1] * u;
311 data_[2] = data_[2] * v + other.data_[2] * u;
312 data_[3] = data_[3] * v + other.data_[3] * u;
313 data_[4] = data_[4] * v + other.data_[4] * u;
314 data_[5] = data_[5] * v + other.data_[5] * u;
315 data_[6] = data_[6] * v + other.data_[6] * u;
316 data_[7] = data_[7] * v + other.data_[7] * u;
317 data_[8] = data_[8] * v + other.data_[8] * u;
318 data_[9] = data_[9] * v + other.data_[9] * u;
319 data_[10] = data_[10] * v + other.data_[10] * u;
325 template <
class RhsValueType>
326 Evaluation& operator*=(
const RhsValueType& other)
346 assert(
size() == other.size());
352 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
353 data_[2] = (v*data_[2] - u*other.data_[2])/(v*v);
354 data_[3] = (v*data_[3] - u*other.data_[3])/(v*v);
355 data_[4] = (v*data_[4] - u*other.data_[4])/(v*v);
356 data_[5] = (v*data_[5] - u*other.data_[5])/(v*v);
357 data_[6] = (v*data_[6] - u*other.data_[6])/(v*v);
358 data_[7] = (v*data_[7] - u*other.data_[7])/(v*v);
359 data_[8] = (v*data_[8] - u*other.data_[8])/(v*v);
360 data_[9] = (v*data_[9] - u*other.data_[9])/(v*v);
361 data_[10] = (v*data_[10] - u*other.data_[10])/(v*v);
368 template <
class RhsValueType>
369 Evaluation& operator/=(
const RhsValueType& other)
391 assert(
size() == other.size());
401 template <
class RhsValueType>
402 Evaluation operator+(
const RhsValueType& other)
const
414 assert(
size() == other.size());
424 template <
class RhsValueType>
425 Evaluation operator-(
const RhsValueType& other)
const
440 result.data_[0] = - data_[0];
441 result.data_[1] = - data_[1];
442 result.data_[2] = - data_[2];
443 result.data_[3] = - data_[3];
444 result.data_[4] = - data_[4];
445 result.data_[5] = - data_[5];
446 result.data_[6] = - data_[6];
447 result.data_[7] = - data_[7];
448 result.data_[8] = - data_[8];
449 result.data_[9] = - data_[9];
450 result.data_[10] = - data_[10];
457 assert(
size() == other.size());
466 template <
class RhsValueType>
467 Evaluation operator*(
const RhsValueType& other)
const
478 assert(
size() == other.size());
487 template <
class RhsValueType>
488 Evaluation operator/(
const RhsValueType& other)
const
497 template <
class RhsValueType>
498 Evaluation& operator=(
const RhsValueType& other)
509 template <
class RhsValueType>
510 bool operator==(
const RhsValueType& other)
const
511 {
return value() == other; }
513 bool operator==(
const Evaluation& other)
const
515 assert(
size() == other.size());
517 for (
int idx = 0; idx <
length_(); ++idx) {
518 if (data_[idx] != other.data_[idx]) {
525 bool operator!=(
const Evaluation& other)
const
526 {
return !operator==(other); }
528 template <
class RhsValueType>
529 bool operator!=(
const RhsValueType& other)
const
530 {
return !operator==(other); }
532 template <
class RhsValueType>
533 bool operator>(RhsValueType other)
const
534 {
return value() > other; }
538 assert(
size() == other.size());
540 return value() > other.value();
543 template <
class RhsValueType>
544 bool operator<(RhsValueType other)
const
545 {
return value() < other; }
549 assert(
size() == other.size());
551 return value() < other.value();
554 template <
class RhsValueType>
555 bool operator>=(RhsValueType other)
const
556 {
return value() >= other; }
558 bool operator>=(
const Evaluation& other)
const
560 assert(
size() == other.size());
562 return value() >= other.value();
565 template <
class RhsValueType>
566 bool operator<=(RhsValueType other)
const
567 {
return value() <= other; }
569 bool operator<=(
const Evaluation& other)
const
571 assert(
size() == other.size());
573 return value() <= other.value();
581 template <
class RhsValueType>
582 void setValue(
const RhsValueType& val)
586 const ValueType& derivative(
int varIdx)
const
588 assert(0 <= varIdx && varIdx <
size());
590 return data_[
dstart_() + varIdx];
594 void setDerivative(
int varIdx,
const ValueType& derVal)
596 assert(0 <= varIdx && varIdx <
size());
598 data_[
dstart_() + varIdx] = derVal;
601 template<
class Serializer>
602 void serializeOp(Serializer& serializer)
608 std::array<ValueT, 11> data_;