My Project
Math.hpp
Go to the documentation of this file.
1 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set et ts=4 sw=4 sts=4:
3 /*
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 2 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 
19  Consult the COPYING file in the top-level source directory of this
20  module for the precise wording of the license and the list of
21  copyright holders.
22 */
32 #ifndef OPM_LOCAL_AD_MATH_HPP
33 #define OPM_LOCAL_AD_MATH_HPP
34 
35 #include "Evaluation.hpp"
36 
38 
39 namespace Opm {
40 namespace DenseAd {
41 // forward declaration of the Evaluation template class
42 template <class ValueT, int numVars, unsigned staticSize>
43 class Evaluation;
44 
45 // provide some algebraic functions
46 template <class ValueType, int numVars, unsigned staticSize>
47 Evaluation<ValueType, numVars, staticSize> abs(const Evaluation<ValueType, numVars, staticSize>& x)
48 { return (x > 0.0)?x:-x; }
49 
50 template <class ValueType, int numVars, unsigned staticSize>
51 Evaluation<ValueType, numVars, staticSize> min(const Evaluation<ValueType, numVars, staticSize>& x1,
52  const Evaluation<ValueType, numVars, staticSize>& x2)
53 { return (x1 < x2)?x1:x2; }
54 
55 template <class Arg1ValueType, class ValueType, int numVars, unsigned staticSize>
56 Evaluation<ValueType, numVars, staticSize> min(const Arg1ValueType& x1,
57  const Evaluation<ValueType, numVars, staticSize>& x2)
58 {
59  if (x1 < x2) {
60  Evaluation<ValueType, numVars, staticSize> ret(x2);
61  ret = x1;
62  return ret;
63  }
64  else
65  return x2;
66 }
67 
68 template <class ValueType, int numVars, unsigned staticSize, class Arg2ValueType>
69 Evaluation<ValueType, numVars, staticSize> min(const Evaluation<ValueType, numVars, staticSize>& x1,
70  const Arg2ValueType& x2)
71 { return min(x2, x1); }
72 
73 template <class ValueType, int numVars, unsigned staticSize>
74 Evaluation<ValueType, numVars, staticSize> max(const Evaluation<ValueType, numVars, staticSize>& x1,
75  const Evaluation<ValueType, numVars, staticSize>& x2)
76 { return (x1 > x2)?x1:x2; }
77 
78 template <class Arg1ValueType, class ValueType, int numVars, unsigned staticSize>
79 Evaluation<ValueType, numVars, staticSize> max(const Arg1ValueType& x1,
80  const Evaluation<ValueType, numVars, staticSize>& x2)
81 {
82  if (x1 > x2) {
83  Evaluation<ValueType, numVars, staticSize> ret(x2);
84  ret = x1;
85  return ret;
86  }
87  else
88  return x2;
89 }
90 
91 template <class ValueType, int numVars, unsigned staticSize, class Arg2ValueType>
92 Evaluation<ValueType, numVars, staticSize> max(const Evaluation<ValueType, numVars, staticSize>& x1,
93  const Arg2ValueType& x2)
94 { return max(x2, x1); }
95 
96 template <class ValueType, int numVars, unsigned staticSize>
97 Evaluation<ValueType, numVars, staticSize> tan(const Evaluation<ValueType, numVars, staticSize>& x)
98 {
99  typedef MathToolbox<ValueType> ValueTypeToolbox;
100 
101  Evaluation<ValueType, numVars, staticSize> result(x);
102 
103  const ValueType& tmp = ValueTypeToolbox::tan(x.value());
104  result.setValue(tmp);
105 
106  // derivatives use the chain rule
107  const ValueType& df_dx = 1 + tmp*tmp;
108  for (int curVarIdx = 0; curVarIdx < result.size(); ++curVarIdx)
109  result.setDerivative(curVarIdx, df_dx*x.derivative(curVarIdx));
110 
111  return result;
112 }
113 
114 template <class ValueType, int numVars, unsigned staticSize>
115 Evaluation<ValueType, numVars, staticSize> atan(const Evaluation<ValueType, numVars, staticSize>& x)
116 {
117  typedef MathToolbox<ValueType> ValueTypeToolbox;
118 
119  Evaluation<ValueType, numVars, staticSize> result(x);
120 
121  result.setValue(ValueTypeToolbox::atan(x.value()));
122 
123  // derivatives use the chain rule
124  const ValueType& df_dx = 1/(1 + x.value()*x.value());
125  for (int curVarIdx = 0; curVarIdx < result.size(); ++curVarIdx)
126  result.setDerivative(curVarIdx, df_dx*x.derivative(curVarIdx));
127 
128  return result;
129 }
130 
131 template <class ValueType, int numVars, unsigned staticSize>
132 Evaluation<ValueType, numVars, staticSize> atan2(const Evaluation<ValueType, numVars, staticSize>& x,
133  const Evaluation<ValueType, numVars, staticSize>& y)
134 {
135  typedef MathToolbox<ValueType> ValueTypeToolbox;
136 
137  Evaluation<ValueType, numVars, staticSize> result(x);
138 
139  result.setValue(ValueTypeToolbox::atan2(x.value(), y.value()));
140 
141  // derivatives use the chain rule
142  const ValueType& alpha = 1/(1 + (x.value()*x.value())/(y.value()*y.value()));
143  for (int curVarIdx = 0; curVarIdx < result.size(); ++curVarIdx) {
144  result.setDerivative(curVarIdx,
145  alpha/(y.value()*y.value())
146  *(x.derivative(curVarIdx)*y.value() - x.value()*y.derivative(curVarIdx)));
147  }
148 
149  return result;
150 }
151 
152 template <class ValueType, int numVars, unsigned staticSize>
153 Evaluation<ValueType, numVars, staticSize> atan2(const Evaluation<ValueType, numVars, staticSize>& x,
154  const ValueType& y)
155 {
156  typedef MathToolbox<ValueType> ValueTypeToolbox;
157 
158  Evaluation<ValueType, numVars, staticSize> result(x);
159 
160  result.setValue(ValueTypeToolbox::atan2(x.value(), y));
161 
162  // derivatives use the chain rule
163  const ValueType& alpha = 1/(1 + (x.value()*x.value())/(y*y));
164  for (int curVarIdx = 0; curVarIdx < result.size(); ++curVarIdx) {
165  result.setDerivative(curVarIdx,
166  alpha/(y*y)
167  *(x.derivative(curVarIdx)*y));
168  }
169 
170  return result;
171 }
172 
173 template <class ValueType, int numVars, unsigned staticSize>
174 Evaluation<ValueType, numVars, staticSize> atan2(const ValueType& x,
175  const Evaluation<ValueType, numVars, staticSize>& y)
176 {
177  typedef MathToolbox<ValueType> ValueTypeToolbox;
178 
179  Evaluation<ValueType, numVars, staticSize> result(y);
180 
181  result.setValue(ValueTypeToolbox::atan2(x, y.value()));
182 
183  // derivatives use the chain rule
184  const ValueType& alpha = 1/(1 + (x.value()*x.value())/(y.value()*y.value()));
185  for (int curVarIdx = 0; curVarIdx < result.size(); ++curVarIdx) {
186  result.setDerivative(curVarIdx,
187  alpha/(y.value()*y.value())
188  *x*y.derivative(curVarIdx));
189  }
190 
191  return result;
192 }
193 
194 template <class ValueType, int numVars, unsigned staticSize>
195 Evaluation<ValueType, numVars, staticSize> sin(const Evaluation<ValueType, numVars, staticSize>& x)
196 {
197  typedef MathToolbox<ValueType> ValueTypeToolbox;
198 
199  Evaluation<ValueType, numVars, staticSize> result(x);
200 
201  result.setValue(ValueTypeToolbox::sin(x.value()));
202 
203  // derivatives use the chain rule
204  const ValueType& df_dx = ValueTypeToolbox::cos(x.value());
205  for (int curVarIdx = 0; curVarIdx < result.size(); ++curVarIdx)
206  result.setDerivative(curVarIdx, df_dx*x.derivative(curVarIdx));
207 
208  return result;
209 }
210 
211 template <class ValueType, int numVars, unsigned staticSize>
212 Evaluation<ValueType, numVars, staticSize> asin(const Evaluation<ValueType, numVars, staticSize>& x)
213 {
214  typedef MathToolbox<ValueType> ValueTypeToolbox;
215 
216  Evaluation<ValueType, numVars, staticSize> result(x);
217 
218  result.setValue(ValueTypeToolbox::asin(x.value()));
219 
220  // derivatives use the chain rule
221  const ValueType& df_dx = 1.0/ValueTypeToolbox::sqrt(1 - x.value()*x.value());
222  for (int curVarIdx = 0; curVarIdx < result.size(); ++curVarIdx)
223  result.setDerivative(curVarIdx, df_dx*x.derivative(curVarIdx));
224 
225  return result;
226 }
227 
228 template <class ValueType, int numVars, unsigned staticSize>
229 Evaluation<ValueType, numVars, staticSize> cos(const Evaluation<ValueType, numVars, staticSize>& x)
230 {
231  typedef MathToolbox<ValueType> ValueTypeToolbox;
232 
233  Evaluation<ValueType, numVars, staticSize> result(x);
234 
235  result.setValue(ValueTypeToolbox::cos(x.value()));
236 
237  // derivatives use the chain rule
238  const ValueType& df_dx = -ValueTypeToolbox::sin(x.value());
239  for (int curVarIdx = 0; curVarIdx < result.size(); ++curVarIdx)
240  result.setDerivative(curVarIdx, df_dx*x.derivative(curVarIdx));
241 
242  return result;
243 }
244 
245 template <class ValueType, int numVars, unsigned staticSize>
246 Evaluation<ValueType, numVars, staticSize> acos(const Evaluation<ValueType, numVars, staticSize>& x)
247 {
248  typedef MathToolbox<ValueType> ValueTypeToolbox;
249 
250  Evaluation<ValueType, numVars, staticSize> result(x);
251 
252  result.setValue(ValueTypeToolbox::acos(x.value()));
253 
254  // derivatives use the chain rule
255  const ValueType& df_dx = - 1.0/ValueTypeToolbox::sqrt(1 - x.value()*x.value());
256  for (int curVarIdx = 0; curVarIdx < result.size(); ++curVarIdx)
257  result.setDerivative(curVarIdx, df_dx*x.derivative(curVarIdx));
258 
259  return result;
260 }
261 
262 template <class ValueType, int numVars, unsigned staticSize>
263 Evaluation<ValueType, numVars, staticSize> sqrt(const Evaluation<ValueType, numVars, staticSize>& x)
264 {
265  typedef MathToolbox<ValueType> ValueTypeToolbox;
266 
267  Evaluation<ValueType, numVars, staticSize> result(x);
268 
269  const ValueType& sqrt_x = ValueTypeToolbox::sqrt(x.value());
270  result.setValue(sqrt_x);
271 
272  // derivatives use the chain rule
273  ValueType df_dx = 0.5/sqrt_x;
274  for (int curVarIdx = 0; curVarIdx < result.size(); ++curVarIdx) {
275  result.setDerivative(curVarIdx, df_dx*x.derivative(curVarIdx));
276  }
277 
278  return result;
279 }
280 
281 template <class ValueType, int numVars, unsigned staticSize>
282 Evaluation<ValueType, numVars, staticSize> exp(const Evaluation<ValueType, numVars, staticSize>& x)
283 {
284  typedef MathToolbox<ValueType> ValueTypeToolbox;
285  Evaluation<ValueType, numVars, staticSize> result(x);
286 
287  const ValueType& exp_x = ValueTypeToolbox::exp(x.value());
288  result.setValue(exp_x);
289 
290  // derivatives use the chain rule
291  const ValueType& df_dx = exp_x;
292  for (int curVarIdx = 0; curVarIdx < result.size(); ++curVarIdx)
293  result.setDerivative(curVarIdx, df_dx*x.derivative(curVarIdx));
294 
295  return result;
296 }
297 
298 // exponentiation of arbitrary base with a fixed constant
299 template <class ValueType, int numVars, unsigned staticSize, class ExpType>
300 Evaluation<ValueType, numVars, staticSize> pow(const Evaluation<ValueType, numVars, staticSize>& base,
301  const ExpType& exp)
302 {
303  typedef MathToolbox<ValueType> ValueTypeToolbox;
304  Evaluation<ValueType, numVars, staticSize> result(base);
305 
306  const ValueType& pow_x = ValueTypeToolbox::pow(base.value(), exp);
307  result.setValue(pow_x);
308 
309  if (base == 0.0) {
310  // we special case the base 0 case because 0.0 is in the valid range of the
311  // base but the generic code leads to NaNs.
312  result = 0.0;
313  }
314  else {
315  // derivatives use the chain rule
316  const ValueType& df_dx = pow_x/base.value()*exp;
317  for (int curVarIdx = 0; curVarIdx < result.size(); ++curVarIdx)
318  result.setDerivative(curVarIdx, df_dx*base.derivative(curVarIdx));
319  }
320 
321  return result;
322 }
323 
324 // exponentiation of constant base with an arbitrary exponent
325 template <class BaseType, class ValueType, int numVars, unsigned staticSize>
326 Evaluation<ValueType, numVars, staticSize> pow(const BaseType& base,
327  const Evaluation<ValueType, numVars, staticSize>& exp)
328 {
329  typedef MathToolbox<ValueType> ValueTypeToolbox;
330 
331  Evaluation<ValueType, numVars, staticSize> result(exp);
332 
333  if (base == 0.0) {
334  // we special case the base 0 case because 0.0 is in the valid range of the
335  // base but the generic code leads to NaNs.
336  result = 0.0;
337  }
338  else {
339  const ValueType& lnBase = ValueTypeToolbox::log(base);
340  result.setValue(ValueTypeToolbox::exp(lnBase*exp.value()));
341 
342  // derivatives use the chain rule
343  const ValueType& df_dx = lnBase*result.value();
344  for (int curVarIdx = 0; curVarIdx < result.size(); ++curVarIdx)
345  result.setDerivative(curVarIdx, df_dx*exp.derivative(curVarIdx));
346  }
347 
348  return result;
349 }
350 
351 // this is the most expensive power function. Computationally it is pretty expensive, so
352 // one of the above two variants above should be preferred if possible.
353 template <class ValueType, int numVars, unsigned staticSize>
354 Evaluation<ValueType, numVars, staticSize> pow(const Evaluation<ValueType, numVars, staticSize>& base,
355  const Evaluation<ValueType, numVars, staticSize>& exp)
356 {
357  typedef MathToolbox<ValueType> ValueTypeToolbox;
358 
359  Evaluation<ValueType, numVars, staticSize> result(base);
360 
361  if (base == 0.0) {
362  // we special case the base 0 case because 0.0 is in the valid range of the
363  // base but the generic code leads to NaNs.
364  result = 0.0;
365  }
366  else {
367  ValueType valuePow = ValueTypeToolbox::pow(base.value(), exp.value());
368  result.setValue(valuePow);
369 
370  // use the chain rule for the derivatives. since both, the base and the exponent can
371  // potentially depend on the variable set, calculating these is quite elaborate...
372  const ValueType& f = base.value();
373  const ValueType& g = exp.value();
374  const ValueType& logF = ValueTypeToolbox::log(f);
375  for (int curVarIdx = 0; curVarIdx < result.size(); ++curVarIdx) {
376  const ValueType& fPrime = base.derivative(curVarIdx);
377  const ValueType& gPrime = exp.derivative(curVarIdx);
378  result.setDerivative(curVarIdx, (g*fPrime/f + logF*gPrime) * valuePow);
379  }
380  }
381 
382  return result;
383 }
384 
385 template <class ValueType, int numVars, unsigned staticSize>
386 Evaluation<ValueType, numVars, staticSize> log(const Evaluation<ValueType, numVars, staticSize>& x)
387 {
388  typedef MathToolbox<ValueType> ValueTypeToolbox;
389 
390  Evaluation<ValueType, numVars, staticSize> result(x);
391 
392  result.setValue(ValueTypeToolbox::log(x.value()));
393 
394  // derivatives use the chain rule
395  const ValueType& df_dx = 1/x.value();
396  for (int curVarIdx = 0; curVarIdx < result.size(); ++curVarIdx)
397  result.setDerivative(curVarIdx, df_dx*x.derivative(curVarIdx));
398 
399  return result;
400 }
401 
402 
403 template <class ValueType, int numVars, unsigned staticSize>
404 Evaluation<ValueType, numVars, staticSize> log10(const Evaluation<ValueType, numVars, staticSize>& x)
405 {
406  typedef MathToolbox<ValueType> ValueTypeToolbox;
407 
408  Evaluation<ValueType, numVars, staticSize> result(x);
409 
410  result.setValue(ValueTypeToolbox::log10(x.value()));
411 
412  // derivatives use the chain rule
413  const ValueType& df_dx = 1/x.value() * ValueTypeToolbox::log10(ValueTypeToolbox::exp(1.0));
414  for (int curVarIdx = 0; curVarIdx < result.size(); ++curVarIdx)
415  result.setDerivative(curVarIdx, df_dx*x.derivative(curVarIdx));
416 
417  return result;
418 }
419 
420 } // namespace DenseAd
421 
422 // a kind of traits class for the automatic differentiation case. (The toolbox for the
423 // scalar case is provided by the MathToolbox.hpp header file.)
424 template <class ValueT, int numVars, unsigned staticSize>
425 struct MathToolbox<DenseAd::Evaluation<ValueT, numVars, staticSize> >
426 {
427 private:
428 public:
429  typedef ValueT ValueType;
431  typedef typename InnerToolbox::Scalar Scalar;
433 
434  static ValueType value(const Evaluation& eval)
435  { return eval.value(); }
436 
437  static decltype(InnerToolbox::scalarValue(0.0)) scalarValue(const Evaluation& eval)
438  { return InnerToolbox::scalarValue(eval.value()); }
439 
440  static Evaluation createBlank(const Evaluation& x)
441  { return Evaluation::createBlank(x); }
442 
443  static Evaluation createConstantZero(const Evaluation& x)
444  { return Evaluation::createConstantZero(x); }
445 
446  static Evaluation createConstantOne(const Evaluation& x)
447  { return Evaluation::createConstantOne(x); }
448 
449  static Evaluation createConstant(ValueType value)
450  { return Evaluation::createConstant(value); }
451 
452  static Evaluation createConstant(unsigned numDeriv, const ValueType value)
453  { return Evaluation::createConstant(numDeriv, value); }
454 
455  static Evaluation createConstant(const Evaluation& x, const ValueType value)
456  { return Evaluation::createConstant(x, value); }
457 
458  static Evaluation createVariable(ValueType value, int varIdx)
459  { return Evaluation::createVariable(value, varIdx); }
460 
461  template <class LhsEval>
462  static typename std::enable_if<std::is_same<Evaluation, LhsEval>::value,
463  LhsEval>::type
464  decay(const Evaluation& eval)
465  { return eval; }
466 
467  template <class LhsEval>
468  static typename std::enable_if<std::is_same<Evaluation, LhsEval>::value,
469  LhsEval>::type
470  decay(const Evaluation&& eval)
471  { return eval; }
472 
473  template <class LhsEval>
474  static typename std::enable_if<std::is_floating_point<LhsEval>::value,
475  LhsEval>::type
476  decay(const Evaluation& eval)
477  { return eval.value(); }
478 
479  // comparison
480  static bool isSame(const Evaluation& a, const Evaluation& b, Scalar tolerance)
481  {
482  typedef MathToolbox<ValueType> ValueTypeToolbox;
483 
484  // make sure that the value of the evaluation is identical
485  if (!ValueTypeToolbox::isSame(a.value(), b.value(), tolerance))
486  return false;
487 
488  // make sure that the derivatives are identical
489  for (int curVarIdx = 0; curVarIdx < numVars; ++curVarIdx)
490  if (!ValueTypeToolbox::isSame(a.derivative(curVarIdx), b.derivative(curVarIdx), tolerance))
491  return false;
492 
493  return true;
494  }
495 
496  // arithmetic functions
497  template <class Arg1Eval, class Arg2Eval>
498  static Evaluation max(const Arg1Eval& arg1, const Arg2Eval& arg2)
499  { return DenseAd::max(arg1, arg2); }
500 
501  template <class Arg1Eval, class Arg2Eval>
502  static Evaluation min(const Arg1Eval& arg1, const Arg2Eval& arg2)
503  { return DenseAd::min(arg1, arg2); }
504 
505  static Evaluation abs(const Evaluation& arg)
506  { return DenseAd::abs(arg); }
507 
508  static Evaluation tan(const Evaluation& arg)
509  { return DenseAd::tan(arg); }
510 
511  static Evaluation atan(const Evaluation& arg)
512  { return DenseAd::atan(arg); }
513 
514  static Evaluation atan2(const Evaluation& arg1, const Evaluation& arg2)
515  { return DenseAd::atan2(arg1, arg2); }
516 
517  template <class Eval2>
518  static Evaluation atan2(const Evaluation& arg1, const Eval2& arg2)
519  { return DenseAd::atan2(arg1, arg2); }
520 
521  template <class Eval1>
522  static Evaluation atan2(const Eval1& arg1, const Evaluation& arg2)
523  { return DenseAd::atan2(arg1, arg2); }
524 
525  static Evaluation sin(const Evaluation& arg)
526  { return DenseAd::sin(arg); }
527 
528  static Evaluation asin(const Evaluation& arg)
529  { return DenseAd::asin(arg); }
530 
531  static Evaluation cos(const Evaluation& arg)
532  { return DenseAd::cos(arg); }
533 
534  static Evaluation acos(const Evaluation& arg)
535  { return DenseAd::acos(arg); }
536 
537  static Evaluation sqrt(const Evaluation& arg)
538  { return DenseAd::sqrt(arg); }
539 
540  static Evaluation exp(const Evaluation& arg)
541  { return DenseAd::exp(arg); }
542 
543  static Evaluation log(const Evaluation& arg)
544  { return DenseAd::log(arg); }
545 
546  static Evaluation log10(const Evaluation& arg)
547  { return DenseAd::log10(arg); }
548 
549  template <class RhsValueType>
550  static Evaluation pow(const Evaluation& arg1, const RhsValueType& arg2)
551  { return DenseAd::pow(arg1, arg2); }
552 
553  template <class RhsValueType>
554  static Evaluation pow(const RhsValueType& arg1, const Evaluation& arg2)
555  { return DenseAd::pow(arg1, arg2); }
556 
557  static Evaluation pow(const Evaluation& arg1, const Evaluation& arg2)
558  { return DenseAd::pow(arg1, arg2); }
559 
560  static bool isfinite(const Evaluation& arg)
561  {
562  if (!InnerToolbox::isfinite(arg.value()))
563  return false;
564 
565  for (int i = 0; i < numVars; ++i)
566  if (!InnerToolbox::isfinite(arg.derivative(i)))
567  return false;
568 
569  return true;
570  }
571 
572  static bool isnan(const Evaluation& arg)
573  {
574  if (InnerToolbox::isnan(arg.value()))
575  return true;
576 
577  for (int i = 0; i < numVars; ++i)
578  if (InnerToolbox::isnan(arg.derivative(i)))
579  return true;
580 
581  return false;
582  }
583 };
584 
585 }
586 
587 #endif
Representation of an evaluation of a function and its derivatives w.r.t.
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...
Represents a function evaluation and its derivatives w.r.t.
Definition: Evaluation.hpp:59
Definition: MathToolbox.hpp:52
static LhsEval decay(Scalar value)
Given a function evaluation, constrain it to its value (if necessary).
Definition: MathToolbox.hpp:175
static bool isSame(Scalar a, Scalar b, Scalar tolerance)
Returns true if two values are identical up to a specified tolerance.
Definition: MathToolbox.hpp:186
static Scalar min(Scalar arg1, Scalar arg2)
The minimum of two arguments.
Definition: MathToolbox.hpp:203
static Scalar createBlank(Scalar)
Given a scalar value, return a "compatible" object.
Definition: MathToolbox.hpp:103
static Scalar value(Scalar value)
Return the value of the function at a given evaluation point.
Definition: MathToolbox.hpp:85
ScalarT Scalar
The type used to represent "primitive" scalar values.
Definition: MathToolbox.hpp:54
static Scalar atan2(Scalar arg1, Scalar arg2)
The arcus tangens of a value.
Definition: MathToolbox.hpp:219
static Scalar cos(Scalar arg)
The cosine of a value.
Definition: MathToolbox.hpp:231
static Scalar tan(Scalar arg)
The tangens of a value.
Definition: MathToolbox.hpp:211
static bool isfinite(Scalar arg)
Return true iff the argument's value and all its derivatives are finite values.
Definition: MathToolbox.hpp:259
static Scalar exp(Scalar arg)
The natural exponentiation of a value.
Definition: MathToolbox.hpp:243
static Scalar acos(Scalar arg)
The arcus cosine of a value.
Definition: MathToolbox.hpp:235
static Scalar sqrt(Scalar arg)
The square root of a value.
Definition: MathToolbox.hpp:239
static Scalar sin(Scalar arg)
The sine of a value.
Definition: MathToolbox.hpp:223
static Scalar pow(Scalar base, Scalar exp)
Exponentiation to an arbitrary base.
Definition: MathToolbox.hpp:255
ScalarT ValueType
The type used to represent values.
Definition: MathToolbox.hpp:68
static Scalar abs(Scalar arg)
The absolute value.
Definition: MathToolbox.hpp:207
MathToolbox< Scalar > InnerToolbox
The toolbox for the type of value objects.
Definition: MathToolbox.hpp:77
static Scalar log10(Scalar arg)
The 10 logarithm of a value.
Definition: MathToolbox.hpp:247
static Scalar createVariable(Scalar, unsigned)
Given a scalar value, return an evaluation of a linear function.
Definition: MathToolbox.hpp:149
static Scalar log(Scalar arg)
The natural logarithm of a value.
Definition: MathToolbox.hpp:251
static Scalar createConstant(Scalar value)
Given a scalar value, return an evaluation of a constant function.
Definition: MathToolbox.hpp:113
static Scalar atan(Scalar arg)
The arcus tangens of a value.
Definition: MathToolbox.hpp:215
static Scalar scalarValue(Scalar value)
Return the primitive scalar value of a value object.
Definition: MathToolbox.hpp:94
static Scalar asin(Scalar arg)
The arcus sine of a value.
Definition: MathToolbox.hpp:227
static Scalar max(Scalar arg1, Scalar arg2)
The maximum of two arguments.
Definition: MathToolbox.hpp:199
static bool isnan(Scalar arg)
Return true iff the argument's value or any of its derivatives are NaN values.
Definition: MathToolbox.hpp:263