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()
164 template <
class RhsValueType>
165 static Evaluation createVariable(
const RhsValueType& value,
int varPos)
172 template <
class RhsValueType>
173 static Evaluation createVariable(
int nVars,
const RhsValueType& value,
int varPos)
176 throw std::logic_error(
"This statically-sized evaluation can only represent objects"
177 " with 12 derivatives");
184 template <
class RhsValueType>
195 template <
class RhsValueType>
196 static Evaluation createConstant(
int nVars,
const RhsValueType& value)
199 throw std::logic_error(
"This statically-sized evaluation can only represent objects"
200 " with 12 derivatives");
206 template <
class RhsValueType>
207 static Evaluation createConstant(
const RhsValueType& value)
214 template <
class RhsValueType>
223 assert(
size() == other.size());
225 data_[1] = other.data_[1];
226 data_[2] = other.data_[2];
227 data_[3] = other.data_[3];
228 data_[4] = other.data_[4];
229 data_[5] = other.data_[5];
230 data_[6] = other.data_[6];
231 data_[7] = other.data_[7];
232 data_[8] = other.data_[8];
233 data_[9] = other.data_[9];
234 data_[10] = other.data_[10];
235 data_[11] = other.data_[11];
236 data_[12] = other.data_[12];
243 assert(
size() == other.size());
245 data_[0] += other.data_[0];
246 data_[1] += other.data_[1];
247 data_[2] += other.data_[2];
248 data_[3] += other.data_[3];
249 data_[4] += other.data_[4];
250 data_[5] += other.data_[5];
251 data_[6] += other.data_[6];
252 data_[7] += other.data_[7];
253 data_[8] += other.data_[8];
254 data_[9] += other.data_[9];
255 data_[10] += other.data_[10];
256 data_[11] += other.data_[11];
257 data_[12] += other.data_[12];
263 template <
class RhsValueType>
264 Evaluation& operator+=(
const RhsValueType& other)
275 assert(
size() == other.size());
277 data_[0] -= other.data_[0];
278 data_[1] -= other.data_[1];
279 data_[2] -= other.data_[2];
280 data_[3] -= other.data_[3];
281 data_[4] -= other.data_[4];
282 data_[5] -= other.data_[5];
283 data_[6] -= other.data_[6];
284 data_[7] -= other.data_[7];
285 data_[8] -= other.data_[8];
286 data_[9] -= other.data_[9];
287 data_[10] -= other.data_[10];
288 data_[11] -= other.data_[11];
289 data_[12] -= other.data_[12];
295 template <
class RhsValueType>
296 Evaluation& operator-=(
const RhsValueType& other)
307 assert(
size() == other.size());
318 data_[1] = data_[1] * v + other.data_[1] * u;
319 data_[2] = data_[2] * v + other.data_[2] * u;
320 data_[3] = data_[3] * v + other.data_[3] * u;
321 data_[4] = data_[4] * v + other.data_[4] * u;
322 data_[5] = data_[5] * v + other.data_[5] * u;
323 data_[6] = data_[6] * v + other.data_[6] * u;
324 data_[7] = data_[7] * v + other.data_[7] * u;
325 data_[8] = data_[8] * v + other.data_[8] * u;
326 data_[9] = data_[9] * v + other.data_[9] * u;
327 data_[10] = data_[10] * v + other.data_[10] * u;
328 data_[11] = data_[11] * v + other.data_[11] * u;
329 data_[12] = data_[12] * v + other.data_[12] * u;
335 template <
class RhsValueType>
336 Evaluation& operator*=(
const RhsValueType& other)
358 assert(
size() == other.size());
364 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
365 data_[2] = (v*data_[2] - u*other.data_[2])/(v*v);
366 data_[3] = (v*data_[3] - u*other.data_[3])/(v*v);
367 data_[4] = (v*data_[4] - u*other.data_[4])/(v*v);
368 data_[5] = (v*data_[5] - u*other.data_[5])/(v*v);
369 data_[6] = (v*data_[6] - u*other.data_[6])/(v*v);
370 data_[7] = (v*data_[7] - u*other.data_[7])/(v*v);
371 data_[8] = (v*data_[8] - u*other.data_[8])/(v*v);
372 data_[9] = (v*data_[9] - u*other.data_[9])/(v*v);
373 data_[10] = (v*data_[10] - u*other.data_[10])/(v*v);
374 data_[11] = (v*data_[11] - u*other.data_[11])/(v*v);
375 data_[12] = (v*data_[12] - u*other.data_[12])/(v*v);
382 template <
class RhsValueType>
383 Evaluation& operator/=(
const RhsValueType& other)
407 assert(
size() == other.size());
417 template <
class RhsValueType>
418 Evaluation operator+(
const RhsValueType& other)
const
430 assert(
size() == other.size());
440 template <
class RhsValueType>
441 Evaluation operator-(
const RhsValueType& other)
const
456 result.data_[0] = - data_[0];
457 result.data_[1] = - data_[1];
458 result.data_[2] = - data_[2];
459 result.data_[3] = - data_[3];
460 result.data_[4] = - data_[4];
461 result.data_[5] = - data_[5];
462 result.data_[6] = - data_[6];
463 result.data_[7] = - data_[7];
464 result.data_[8] = - data_[8];
465 result.data_[9] = - data_[9];
466 result.data_[10] = - data_[10];
467 result.data_[11] = - data_[11];
468 result.data_[12] = - data_[12];
475 assert(
size() == other.size());
484 template <
class RhsValueType>
485 Evaluation operator*(
const RhsValueType& other)
const
496 assert(
size() == other.size());
505 template <
class RhsValueType>
506 Evaluation operator/(
const RhsValueType& other)
const
515 template <
class RhsValueType>
516 Evaluation& operator=(
const RhsValueType& other)
527 template <
class RhsValueType>
528 bool operator==(
const RhsValueType& other)
const
529 {
return value() == other; }
531 bool operator==(
const Evaluation& other)
const
533 assert(
size() == other.size());
535 for (
int idx = 0; idx <
length_(); ++idx) {
536 if (data_[idx] != other.data_[idx]) {
543 bool operator!=(
const Evaluation& other)
const
544 {
return !operator==(other); }
546 template <
class RhsValueType>
547 bool operator!=(
const RhsValueType& other)
const
548 {
return !operator==(other); }
550 template <
class RhsValueType>
551 bool operator>(RhsValueType other)
const
552 {
return value() > other; }
556 assert(
size() == other.size());
558 return value() > other.value();
561 template <
class RhsValueType>
562 bool operator<(RhsValueType other)
const
563 {
return value() < other; }
567 assert(
size() == other.size());
569 return value() < other.value();
572 template <
class RhsValueType>
573 bool operator>=(RhsValueType other)
const
574 {
return value() >= other; }
576 bool operator>=(
const Evaluation& other)
const
578 assert(
size() == other.size());
580 return value() >= other.value();
583 template <
class RhsValueType>
584 bool operator<=(RhsValueType other)
const
585 {
return value() <= other; }
587 bool operator<=(
const Evaluation& other)
const
589 assert(
size() == other.size());
591 return value() <= other.value();
599 template <
class RhsValueType>
600 void setValue(
const RhsValueType& val)
604 const ValueType& derivative(
int varIdx)
const
606 assert(0 <= varIdx && varIdx <
size());
608 return data_[
dstart_() + varIdx];
612 void setDerivative(
int varIdx,
const ValueType& derVal)
614 assert(0 <= varIdx && varIdx <
size());
616 data_[
dstart_() + varIdx] = derVal;
619 template<
class Serializer>
620 void serializeOp(Serializer& serializer)
626 std::array<ValueT, 13> data_;