Robotics Library  0.7.0
Polynomial.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2009, Markus Rickert, Andre Gaschler
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and/or other materials provided with the distribution.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 // POSSIBILITY OF SUCH DAMAGE.
25 //
26 
27 #ifndef RL_MATH_POLYNOMIAL_H
28 #define RL_MATH_POLYNOMIAL_H
29 
30 #define EIGEN_MATRIXBASE_PLUGIN <rl/math/MatrixBaseAddons.h>
31 #define EIGEN_QUATERNIONBASE_PLUGIN <rl/math/QuaternionBaseAddons.h>
32 #define EIGEN_TRANSFORM_PLUGIN <rl/math/TransformAddons.h>
33 
34 #include <cassert>
35 #include <stdexcept>
36 #include <vector>
37 
38 #ifdef HAVE_EIGEN_UNSUPPORTED
39 #include <unsupported/Eigen/Polynomials>
40 #else // HAVE_EIGEN_UNSUPPORTED
41 #include <Eigen/Eigenvalues>
42 #endif // HAVE_EIGEN_UNSUPPORTED
43 
44 #include "Function.h"
45 #include "Matrix.h"
46 #include "TypeTraits.h"
47 #include "Vector.h"
48 
49 namespace rl
50 {
51  namespace math
52  {
59  template<typename T>
60  class Polynomial : public Function<T>
61  {
62  public:
63  Polynomial(const ::std::size_t& degree) :
64  Function<T>(),
65  c(degree + 1)
66  {
67  }
68 
69  virtual ~Polynomial()
70  {
71  }
72 
73  static Polynomial CubicFirst(const T& y0, const T& y1, const T& yd0, const T& yd1, const Real& x1 = 1)
74  {
75  Polynomial f(3);
76 
77  f.c[0] = y0;
78  f.c[1] = yd0;
79  f.c[2] = -(2 * x1 * yd0 + 3 * y0 - 3 * y1 + x1 * yd1) / ::std::pow(x1, 2);
80  f.c[3] = (2 * y0 + x1 * yd0 - 2 * y1 + x1 * yd1) / ::std::pow(x1, 3);
81  f.x1 = x1;
82 
83  return f;
84  }
85 
86  static Polynomial CubicSecond(const T& y0, const T& y1, const T& ydd0, const T& ydd1, const Real& x1 = 1)
87  {
88  Polynomial f(3);
89 
90  f.c[0] = y0;
91  f.c[1] = -(2 * ::std::pow(x1, 2) * ydd0 + ::std::pow(x1, 2) * ydd1 + 6 * y0 - 6 * y1) / x1 / 6;
92  f.c[2] = ydd0 / 2;
93  f.c[3] = -(ydd0 - ydd1) / x1 / 6;
94  f.x1 = x1;
95 
96  return f;
97  }
98 
99  static Polynomial Linear(const T& y0, const T& y1, const Real& x1 = 1)
100  {
101  Polynomial f(1);
102 
103  f.c[0] = y0;
104  f.c[1] = (y1 - y0) / x1;
105  f.x1 = x1;
106 
107  return f;
108  }
109 
110  static Polynomial Quadratic(const T& y0, const T& y1, const T& yd0, const Real& x1 = 1)
111  {
112  Polynomial f(2);
113 
114  f.c[0] = y0;
115  f.c[1] = yd0;
116  f.c[2] = -(x1 * yd0 + y0 - y1) / ::std::pow(x1, 2);
117  f.x1 = x1;
118 
119  return f;
120  }
121 
122  static Polynomial QuarticFirstSecond(const T& y0, const T& y1, const T& yd0, const T& yd1, const T& ydd0, const Real& x1 = 1)
123  {
124  Polynomial f(4);
125 
126  f.c[0] = y0;
127  f.c[1] = yd0;
128  f.c[2] = ydd0 / 2;
129  f.c[3] = -(::std::pow(x1, 2) * ydd0 + 3 * x1 * yd0 + x1 * yd1 + 4 * y0 - 4 * y1) / ::std::pow(x1, 3);
130  f.c[4] = 0.5f * (::std::pow(x1, 2) * ydd0 + 4 * x1 * yd0 + 2 * x1 * yd1 + 6 * y0 - 6 * y1) / ::std::pow(x1, 4);
131  f.x1 = x1;
132 
133  return f;
134  }
135 
136  static Polynomial QuinticFirstSecond(const T& y0, const T& y1, const T& yd0, const T& yd1, const T& ydd0, const T& ydd1, const Real& x1 = 1)
137  {
138  Polynomial f(5);
139 
140  f.c[0] = y0;
141  f.c[1] = yd0;
142  f.c[2] = ydd0 / 2;
143  f.c[3] = -(3 * ::std::pow(x1, 2) * ydd0 + 12 * x1 * yd0 - ::std::pow(x1, 2) * ydd1 + 20 * y0 + 8 * x1 * yd1 - 20 * y1) / (2 * ::std::pow(x1, 3));
144  f.c[4] = (16 * x1 * yd0 - 2 * ::std::pow(x1, 2) * ydd1 + 30 * y0 + 14 * x1 * yd1 - 30 * y1 + 3 * ::std::pow(x1, 2) * ydd0) / (2 * ::std::pow(x1, 4));
145  f.c[5] = -(12 * y0 + 6 * x1 * yd0 + 6 * x1 * yd1 - 12 * y1 + ::std::pow(x1, 2) * ydd0 - ::std::pow(x1, 2) * ydd1) / (2 * ::std::pow(x1, 5));
146  f.x1 = x1;
147 
148  return f;
149  }
150 
151  static Polynomial SepticFirstSecondThird(const T& y0, const T& y1, const T& yd0, const T& yd1, const T& ydd0, const T& ydd1, const T& yddd0, const T& yddd1, const Real& x1 = 1)
152  {
153  Polynomial f(7);
154 
155  f.c[0] = y0;
156  f.c[1] = yd0;
157  f.c[2] = ydd0 / 2;
158  f.c[3] = yddd0 / 6;
159  f.c[4] = -(::std::pow(x1, 3) * (yddd1 + 4 * yddd0) + ::std::pow(x1, 2) * (30 * ydd0 - 15 * ydd1) + x1 * (90 * yd1 + 120 * yd0) - 210 * y1 + 210 * y0 ) / (6 * ::std::pow(x1, 4));
160  f.c[5] = (::std::pow(x1, 3) * (yddd1 + 2 * yddd0) + ::std::pow(x1, 2) * (20 * ydd0 - 14 * ydd1) + x1 * (78 * yd1 + 90 * yd0) - 168 * y1 + 168 * y0) / (2 * ::std::pow(x1, 5));
161  f.c[6] = -(::std::pow(x1, 3) * (3 * yddd1 + 4 * yddd0) + ::std::pow(x1, 2) * (45 * ydd0 - 39 * ydd1) + x1 * (204 * yd1 + 216 * yd0) - 420 * y1 + 420 * y0) / (6 * ::std::pow(x1, 6));
162  f.c[7] = (::std::pow(x1, 3) * (yddd1 + yddd0) + ::std::pow(x1, 2) * (12 * ydd0 - 12 * ydd1) + x1 * (60 * yd1 + 60 * yd0) - 120 * y1 + 120 * y0) / (6 * ::std::pow(x1, 7));
163  f.x1 = x1;
164 
165  return f;
166  }
167 
168  static Polynomial SexticFirstSecondThird(const T& y0, const T& y1, const T& yd0, const T& yd1, const T& ydd0, const T& ydd1, const T& yddd0, const Real& x1 = 1)
169  {
170  Polynomial f(6);
171 
172  f.c[0] = y0;
173  f.c[1] = yd0;
174  f.c[2] = ydd0 / 2;
175  f.c[3] = yddd0 / 6;
176  f.c[4] = -(::std::pow(x1, 3) * yddd0 + ::std::pow(x1, 2) * (6 * ydd0 - ydd1) + x1 * (10 * yd1 + 20 * yd0) - 30 * y1 + 30 * y0 ) / (2 * ::std::pow(x1, 4));
177  f.c[5] = (::std::pow(x1, 3) * yddd0 + ::std::pow(x1, 2) * (8 * ydd0 - 2 * ydd1) + x1 * (18 * yd1 + 30 * yd0) - 48 * y1 + 48 * y0) / (2 * ::std::pow(x1, 5));
178  f.c[6] = -(::std::pow(x1, 3) * yddd0 + ::std::pow(x1, 2) * (9 * ydd0 - 3 * ydd1) + x1 * (24 * yd1 + 36 * yd0) - 60 * y1 + 60 * y0) / (6 * ::std::pow(x1, 6));
179  f.x1 = x1;
180 
181  return f;
182  }
183 
184  Polynomial* clone() const
185  {
186  return new Polynomial(*this);
187  }
188 
189  T& coefficient(const ::std::size_t& i)
190  {
191  return this->c[i];
192  }
193 
194  const T& coefficient(const ::std::size_t& i) const
195  {
196  return this->c[i];
197  }
198 
199  ::std::size_t degree() const
200  {
201  return this->c.size() - 1;
202  }
203 
205  {
206  Polynomial f(this->degree() > 0 ? this->degree() - 1 : 0);
207  f.x0 = this->x0;
208  f.x1 = this->x1;
209 
210  if (0 == this->degree())
211  {
212  f.c[0] = TypeTraits<T>::Zero(TypeTraits<T>::size(this->c[0]));
213  }
214  else
215  {
216  for (::std::size_t i = 0; i < this->degree(); ++i)
217  {
218  f.c[i] = static_cast<Real>(i + 1) * this->c[i + 1];
219  }
220  }
221 
222  return f;
223  }
224 
235  {
236  Polynomial derivative = this->derivative();
237 
238  T maximum = TypeTraits<T>::abs((*this)(this->x0));
239  T y1 = TypeTraits<T>::abs((*this)(this->x1));
240 
241  for (::std::ptrdiff_t row = 0; row < maximum.size(); ++row)
242  {
243  maximum[row] = ::std::max(maximum[row], y1[row]);
244  ::std::vector<Real> coefficients(derivative.degree() + 1);
245 
246  for (::std::size_t i = 0; i < derivative.degree() + 1; ++i)
247  {
248  coefficients[i] = derivative.coefficient(i)[row];
249  }
250 
251  ::std::vector<Real> extrema = this->realRoots(coefficients);
252 
253  for (::std::vector<Real>::const_iterator x = extrema.begin(); x < extrema.end(); ++x)
254  {
255  if (this->x0 < *x && *x < this->x1)
256  {
257  Real y = ::std::abs((*this)(*x)[row]);
258 
259  if (y > maximum[row])
260  {
261  maximum[row] = y;
262  }
263  }
264  }
265  }
266 
267  return maximum;
268  }
269 
271  {
272  Polynomial f(this->degree() + 1);
273  f.x0 = this->x0;
274  f.x1 = this->x1;
275 
276  f.c[0] = TypeTraits<T>::Zero(TypeTraits<T>::size(this->c[0]));
277 
278  for (::std::size_t i = 0; i < this->degree() + 1; ++i)
279  {
280  f.c[i + 1] = this->c[i] / static_cast<Real>(i + 1);
281  }
282 
283  return f;
284  }
285 
286  T operator()(const Real& x, const ::std::size_t& derivative = 0) const
287  {
288  if (derivative > 0)
289  {
290  Polynomial f = this->derivative();
291 
292  for (::std::size_t i = 1; i < derivative; ++i)
293  {
294  f = f.derivative();
295  }
296 
297  return f(x);
298  }
299  else
300  {
301  assert(x > this->lower() - FUNCTION_BOUNDARY);
302  assert(x < this->upper() + FUNCTION_BOUNDARY);
303 
304  T y = this->c[this->degree()];
305 
306  for (::std::size_t i = 1; i < this->degree() + 1; ++i)
307  {
308  y *= x;
309  y += this->c[this->degree() - i];
310  }
311 
312  return y;
313  }
314  }
315 
316  friend Polynomial operator+(const T& lhs, const Polynomial& rhs)
317  {
318  return Polynomial(rhs) += lhs;
319  }
320 
321  friend Polynomial operator+(const Polynomial& lhs, const T& rhs)
322  {
323  return Polynomial(lhs) += rhs;
324  }
325 
326  Polynomial operator+(const Polynomial& rhs) const
327  {
328  return Polynomial(*this) += rhs;
329  }
330 
331  Polynomial& operator+=(const T& rhs)
332  {
333  if (this->c.size() < 1)
334  {
335  this->c.resize(1);
336  this->c[0] = rhs;
337  }
338  else
339  {
340  this->c[0] += rhs;
341  }
342 
343  return *this;
344  }
345 
347  {
348  ::std::size_t min = ::std::min(this->c.size(), rhs.c.size());
349 
350  for (::std::size_t i = 0; i < min; ++i)
351  {
352  this->c[i] += rhs.c[i];
353  }
354 
355  this->c.resize(::std::max(this->c.size(), rhs.c.size()));
356 
357  for (::std::size_t i = min; i < rhs.c.size(); ++i)
358  {
359  this->c[i] = rhs.c[i];
360  }
361 
362  return *this;
363  }
364 
366  {
367  return *this * -1;
368  }
369 
370  friend Polynomial operator-(const T& lhs, const Polynomial& rhs)
371  {
372  return Polynomial(rhs) -= lhs;
373  }
374 
375  friend Polynomial operator-(const Polynomial& lhs, const T& rhs)
376  {
377  return Polynomial(lhs) -= rhs;
378  }
379 
380  Polynomial operator-(const Polynomial& rhs) const
381  {
382  return Polynomial(*this) -= rhs;
383  }
384 
385  Polynomial& operator-=(const T& rhs)
386  {
387  if (this->c.size() < 1)
388  {
389  this->c.resize(1);
390  this->c[0] = -rhs;
391  }
392  else
393  {
394  this->c[0] -= rhs;
395  }
396 
397  return *this;
398  }
399 
401  {
402  ::std::size_t min = ::std::min(this->c.size(), rhs.c.size());
403 
404  for (::std::size_t i = 0; i < min; ++i)
405  {
406  this->c[i] -= rhs.c[i];
407  }
408 
409  this->c.resize(::std::max(this->c.size(), rhs.c.size()));
410 
411  for (::std::size_t i = min; i < rhs.c.size(); ++i)
412  {
413  this->c[i] = rhs.c[i];
414  }
415 
416  return *this;
417  }
418 
419  friend Polynomial operator*(const Real& lhs, const Polynomial& rhs)
420  {
421  return Polynomial(rhs) *= lhs;
422  }
423 
424  friend Polynomial operator*(const Polynomial& lhs, const Real& rhs)
425  {
426  return Polynomial(lhs) *= rhs;
427  }
428 
430  {
431  for (::std::size_t i = 0; i < this->c.size(); ++i)
432  {
433  this->c[i] *= rhs;
434  }
435 
436  return *this;
437  }
438 
439  friend Polynomial operator/(const Real& lhs, const Polynomial& rhs)
440  {
441  return Polynomial(rhs) /= lhs;
442  }
443 
444  friend Polynomial operator/(const Polynomial& lhs, const Real& rhs)
445  {
446  return Polynomial(lhs) /= rhs;
447  }
448 
450  {
451  return *this *= 1 / rhs;
452  }
453 
459  static ::std::vector<Real> realRoots(const ::std::vector<Real>& c)
460  {
461  ::std::size_t degree = c.empty() ? 0 : c.size() - 1;
462 
463  for (::std::size_t i = 0; i < c.size(); ++i)
464  {
465  if (::std::abs(c[c.size() - 1 - i]) <= ::std::numeric_limits<Real>::epsilon())
466  {
467  degree = degree > 0 ? degree - 1 : degree;
468  }
469  else
470  {
471  break;
472  }
473  }
474 
475  if (degree < 1)
476  {
477  return ::std::vector<Real>(0);
478  }
479  else if (1 == degree)
480  {
481  ::std::vector<Real> roots(1);
482  roots[0] = -c[0] / c[1];
483  return roots;
484  }
485  else if (2 == degree)
486  {
487  Real det = c[1] * c[1] - 4 * c[0] * c[2];
488 
489  if (det > 0)
490  {
491  Real sqrtDet = ::std::sqrt(det);
492  ::std::vector<Real> roots(2);
493  roots[0] = (-c[1] + sqrtDet) / (2 * c[2]);
494  roots[1] = (-c[1] - sqrtDet) / (2 * c[2]);
495  return roots;
496  }
497  else if (::std::abs(det) <= ::std::numeric_limits<Real>::epsilon())
498  {
499  ::std::vector<Real> roots(1);
500  roots[0] = -c[1] / (2 * c[2]);
501  return roots;
502  }
503  else
504  {
505  return ::std::vector<Real>(0);
506  }
507  }
508  else if (3 == degree)
509  {
510  Real p = (3 * c[3] * c[1] - ::std::pow(c[2], 2)) / (3 * ::std::pow(c[3], 2));
511  Real q = (2 * ::std::pow(c[2], 3) - 9 * c[3] * c[2] * c[1] + 27 * ::std::pow(c[3], 2) * c[0]) / (27 * ::std::pow(c[3], 3));
512 
513  Real back = c[2] / (3 * c[3]);
514 
515  if (::std::abs(p) <= ::std::numeric_limits<Real>::epsilon() && ::std::abs(q) <= ::std::numeric_limits<Real>::epsilon())
516  {
517  ::std::vector<Real> roots(1);
518  roots[0] = 0 - back;
519  return roots;
520  }
521  else if (::std::abs(p) <= ::std::numeric_limits<Real>::epsilon() && ::std::abs(q) > ::std::numeric_limits<Real>::epsilon())
522  {
523  ::std::vector<Real> roots(1);
524  roots[0] = cbrt(-q) - back;
525  return roots;
526  }
527  else if (::std::abs(p) > ::std::numeric_limits<Real>::epsilon() && ::std::abs(q) <= ::std::numeric_limits<Real>::epsilon())
528  {
529  Real sqrtP = ::std::sqrt(-p);
530  ::std::vector<Real> roots(3);
531  roots[0] = 0 - back;
532  roots[1] = sqrtP - back;
533  roots[2] = -sqrtP - back;
534  return roots;
535  }
536  else if (::std::abs(4 * ::std::pow(p, 3) + 27 * ::std::pow(q, 2)) <= ::std::numeric_limits<Real>::epsilon() && ::std::abs(p) > ::std::numeric_limits<Real>::epsilon())
537  {
538  ::std::vector<Real> roots(2);
539  roots[0] = -(3 * q) / (2 * p) - back;
540  roots[1] = (3 * q) / p - back;
541  return roots;
542  }
543  else
544  {
545  Real det = ::std::pow(q, 2) / 4 + ::std::pow(p, 3) / 27;
546 
547  if (det < 0)
548  {
549  Real tmp1 = 2 * ::std::sqrt(-p / 3);
550  Real tmp2 = ::std::acos((3 * q) / (2 * p) * ::std::sqrt(-3 / p)) / 3;
551  ::std::vector<Real> roots(3);
552  roots[0] = tmp1 * ::std::cos(tmp2) - back;
553  roots[1] = tmp1 * ::std::cos(tmp2 - 2 * M_PI / 3) - back;
554  roots[2] = tmp1 * ::std::cos(tmp2 - 4 * M_PI / 3) - back;
555  return roots;
556  }
557  else
558  {
559  Real sqrtDet = ::std::sqrt(det);
560  Real u = cbrt(-q / 2 + sqrtDet);
561  Real v = cbrt(-q / 2 - sqrtDet);
562  ::std::vector<Real> roots(1);
563  roots[0] = u + v - back;
564  return roots;
565  }
566  }
567  }
568  else
569  {
570 #ifdef HAVE_EIGEN_UNSUPPORTED
571  ::std::vector<Real> roots;
572  ::Eigen::PolynomialSolver<Real, ::Eigen::Dynamic> solver(Vector::Map(c.data(), degree));
573  solver.realRoots(roots);
574  return roots;
575 #else
576  Matrix companion(degree, degree);
577  companion.topLeftCorner(1, degree).setZero();
578  companion.bottomLeftCorner(degree - 1, degree).setIdentity();
579  companion.rightCols(1) = -1 / c[degree] * Vector::Map(c.data(), degree);
580 
581  ::Eigen::EigenSolver<Matrix> solver(companion);
582 
583  ::std::vector<Real> roots;
584 
585  for (::std::ptrdiff_t i = 0; i < solver.eigenvalues().size(); ++i)
586  {
587  if (::std::abs(solver.eigenvalues()[i].imag()) < ::Eigen::NumTraits<Real>::dummy_precision())
588  {
589  roots.push_back(solver.eigenvalues()[i].real());
590  }
591  }
592 
593  return roots;
594 #endif
595  }
596  }
597 
605  Polynomial scaledX(const Real& factor) const
606  {
607  assert(this->lower() == 0);
608 
609  Polynomial scaled(this->degree());
610  scaled.upper() = this->upper() * factor;
611 
612  for (::std::size_t i = 0; i < this->degree() + 1; ++i)
613  {
614  scaled.coefficient(i) = ::std::pow(factor, -static_cast<int>(i)) * this->coefficient(i);
615  }
616 
617  return scaled;
618  }
619 
627  Polynomial translatedX(const Real& translation) const
628  {
629  Polynomial translated(this->degree());
630  translated.lower() = this->lower() - translation;
631  translated.upper() = this->upper() - translation;
632 
633  for (::std::size_t n = 0; n < this->degree() + 1; ++n)
634  {
636  }
637 
638  for (::std::size_t n = 0; n < this->degree() + 1; ++n)
639  {
640  T c = this->coefficient(n);
641  ::std::size_t b = 1;
642 
643  for (::std::size_t k = 0; k <= n; ++k)
644  {
645  // b is the binomial coefficient n over k
646  translated.coefficient(k) += b * ::std::pow(translation, static_cast<int>(n - k)) * c;
647 
648  // compute next binomial coefficient, integer division is ok because b is divisible
649  b = b * (n - k) / (k + 1);
650  }
651  }
652 
653  return translated;
654  }
655 
656  protected:
657  ::std::vector<T> c;
658 
659  private:
660 
661  };
662  }
663 }
664 
665 #endif // RL_MATH_POLYNOMIAL_H
rl::math::Polynomial::getAbsoluteMaximum
T getAbsoluteMaximum() const
Returns the array of the maximum function values of each dimension within the definition range,...
Definition: Polynomial.h:234
rl::math::Matrix
::Eigen::Matrix< Real, ::Eigen::Dynamic, ::Eigen::Dynamic > Matrix
Definition: Matrix.h:42
pow
Quaternion< Scalar > pow(const Scalar &t) const
Definition: QuaternionBaseAddons.h:128
rl::math::Polynomial::Polynomial
Polynomial(const ::std::size_t &degree)
Definition: Polynomial.h:63
rl::math::Polynomial::operator-
friend Polynomial operator-(const T &lhs, const Polynomial &rhs)
Definition: Polynomial.h:370
rl::math::Function
A mathematical mapping from Real -> ArrayX.
Definition: Function.h:45
rl::math::Function::x1
Real x1
Definition: Function.h:104
rl::math::Polynomial::operator/=
Polynomial & operator/=(const Real &rhs)
Definition: Polynomial.h:449
rl::math::Polynomial::CubicFirst
static Polynomial CubicFirst(const T &y0, const T &y1, const T &yd0, const T &yd1, const Real &x1=1)
Definition: Polynomial.h:73
rl::math::Polynomial::SepticFirstSecondThird
static Polynomial SepticFirstSecondThird(const T &y0, const T &y1, const T &yd0, const T &yd1, const T &ydd0, const T &ydd1, const T &yddd0, const T &yddd1, const Real &x1=1)
Definition: Polynomial.h:151
rl::math::Polynomial::operator-
friend Polynomial operator-(const Polynomial &lhs, const T &rhs)
Definition: Polynomial.h:375
rl::math::Polynomial::SexticFirstSecondThird
static Polynomial SexticFirstSecondThird(const T &y0, const T &y1, const T &yd0, const T &yd1, const T &ydd0, const T &ydd1, const T &yddd0, const Real &x1=1)
Definition: Polynomial.h:168
rl::math::TypeTraits::Zero
static T Zero(const ::std::size_t &i)
Definition: TypeTraits.h:50
rl::math::Polynomial::operator-=
Polynomial & operator-=(const Polynomial &rhs)
Definition: Polynomial.h:400
rl::math::Polynomial::QuinticFirstSecond
static Polynomial QuinticFirstSecond(const T &y0, const T &y1, const T &yd0, const T &yd1, const T &ydd0, const T &ydd1, const Real &x1=1)
Definition: Polynomial.h:136
rl::math::Polynomial::degree
::std::size_t degree() const
Definition: Polynomial.h:199
rl::math::Polynomial::operator+=
Polynomial & operator+=(const T &rhs)
Definition: Polynomial.h:331
rl::math::Polynomial::operator+=
Polynomial & operator+=(const Polynomial &rhs)
Definition: Polynomial.h:346
rl::math::Polynomial::Quadratic
static Polynomial Quadratic(const T &y0, const T &y1, const T &yd0, const Real &x1=1)
Definition: Polynomial.h:110
rl::math::Polynomial::operator*=
Polynomial & operator*=(const Real &rhs)
Definition: Polynomial.h:429
rl::math::cbrt
T cbrt(const T &arg)
Definition: Real.h:45
rl::math::Polynomial
A vector-valued polynomial function from Real -> T.
Definition: Polynomial.h:61
Vector.h
rl::math::Polynomial::integral
Polynomial integral() const
Definition: Polynomial.h:270
rl::math::Polynomial::~Polynomial
virtual ~Polynomial()
Definition: Polynomial.h:69
rl::math::Polynomial::Linear
static Polynomial Linear(const T &y0, const T &y1, const Real &x1=1)
Definition: Polynomial.h:99
rl::math::Polynomial::operator-
Polynomial operator-(const Polynomial &rhs) const
Definition: Polynomial.h:380
rl::math::Polynomial::realRoots
static ::std::vector< Real > realRoots(const ::std::vector< Real > &c)
Calculates the real roots (or, zeros) for given polynomial coefficients.
Definition: Polynomial.h:459
rl::math::Polynomial::scaledX
Polynomial scaledX(const Real &factor) const
Stretches the x-axis of a polynomial by a given factor.
Definition: Polynomial.h:605
rl::math::Function::upper
Real & upper()
Definition: Function.h:74
rl::math::Polynomial::derivative
Polynomial derivative() const
Definition: Polynomial.h:204
rl::math::Polynomial::operator-
Polynomial operator-() const
Definition: Polynomial.h:365
rl::math::Polynomial::CubicSecond
static Polynomial CubicSecond(const T &y0, const T &y1, const T &ydd0, const T &ydd1, const Real &x1=1)
Definition: Polynomial.h:86
TypeTraits.h
rl::math::Polynomial::translatedX
Polynomial translatedX(const Real &translation) const
Translates a polynomial along the x-axis by a given parameter translation.
Definition: Polynomial.h:627
rl::math::Polynomial::operator*
friend Polynomial operator*(const Polynomial &lhs, const Real &rhs)
Definition: Polynomial.h:424
rl::math::Polynomial::operator()
T operator()(const Real &x, const ::std::size_t &derivative=0) const
Evaluates the function or a derivative thereof for a given value x.
Definition: Polynomial.h:286
rl::math::TypeTraits::abs
static T abs(const T &t)
Definition: TypeTraits.h:55
rl::math::Function::x0
Real x0
Definition: Function.h:102
rl::math::Polynomial::clone
Polynomial * clone() const
Definition: Polynomial.h:184
Matrix.h
rl::math::Polynomial::operator+
friend Polynomial operator+(const T &lhs, const Polynomial &rhs)
Definition: Polynomial.h:316
rl::math::Polynomial::operator+
friend Polynomial operator+(const Polynomial &lhs, const T &rhs)
Definition: Polynomial.h:321
rl::math::Polynomial::c
::std::vector< T > c
Definition: Polynomial.h:657
rl::math::TypeTraits
Definition: TypeTraits.h:43
rl::math::Polynomial::QuarticFirstSecond
static Polynomial QuarticFirstSecond(const T &y0, const T &y1, const T &yd0, const T &yd1, const T &ydd0, const Real &x1=1)
Definition: Polynomial.h:122
rl::math::Polynomial::operator/
friend Polynomial operator/(const Polynomial &lhs, const Real &rhs)
Definition: Polynomial.h:444
rl::math::Polynomial::coefficient
const T & coefficient(const ::std::size_t &i) const
Definition: Polynomial.h:194
rl::math::FUNCTION_BOUNDARY
static const Real FUNCTION_BOUNDARY
Definition: Function.h:110
rl::math::Polynomial::coefficient
T & coefficient(const ::std::size_t &i)
Definition: Polynomial.h:189
rl::math::Polynomial::operator-=
Polynomial & operator-=(const T &rhs)
Definition: Polynomial.h:385
rl::math::Polynomial::operator+
Polynomial operator+(const Polynomial &rhs) const
Definition: Polynomial.h:326
rl::math::Function::lower
Real & lower()
Definition: Function.h:64
rl::math::Polynomial::operator/
friend Polynomial operator/(const Real &lhs, const Polynomial &rhs)
Definition: Polynomial.h:439
rl::math::Real
double Real
Definition: Real.h:42
Function.h
rl::math::Polynomial::operator*
friend Polynomial operator*(const Real &lhs, const Polynomial &rhs)
Definition: Polynomial.h:419
rl
Robotics Library.
Definition: AnalogInput.cpp:30