ADORe
ADORe is a modular open source software library and toolkit for decision making, planning, control and simulation of automated vehicles
alfunction.h
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2017-2020 German Aerospace Center (DLR).
3  * Eclipse ADORe, Automated Driving Open Research https://eclipse.org/adore
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License 2.0 which is available at
7  * http://www.eclipse.org/legal/epl-2.0.
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  * Daniel Heß - initial API and implementation
13  ********************************************************************************/
14 
15 #pragma once
16 #include <adore/mad/adoremath.h>
18 #include <stdexcept>
19 #include <string>
20 
21 namespace adore
22 {
23  namespace mad
24  {
25 
29  class FunctionOutOfBoundsException : public std::runtime_error
30  {
31  public:
32  FunctionOutOfBoundsException() :runtime_error("A bounded function of type ALFunction was accessed out of its bounds.") {}
33  };
37  class FunctionNotImplemented : public std::runtime_error
38  {
39  public:
40  FunctionNotImplemented() :runtime_error("An function has been called on an ALFunction object, which is not implemented.") {}
41  };
45  class FunctionNotInitialized : public std::runtime_error
46  {
47  public:
48  FunctionNotInitialized() :runtime_error("An operation has been called on an ALFunction object, although the object is not properly initialized.") {}
49  };
53  class FunctionIndexingError : public std::runtime_error
54  {
55  public:
56  FunctionIndexingError() :runtime_error("A function was unable to index a value x.") {}
57  };
61  class FunctionUnboundedException :public std::runtime_error
62  {
63  public:
64  FunctionUnboundedException() :runtime_error("A function is not bounded in the queried interval") {}
65  };
66 
67 
68 
72  template<typename DT, typename CT>
73  class ALFunction
74  {
75  private:
78 
79  public:
83  virtual void setLimits(DT lo, DT hi) = 0;
87  virtual DT limitHi() const = 0;
91  virtual DT limitLo() const = 0;
95  virtual CT f(DT x) const = 0;
99  virtual ALFunction<DT, CT>* clone() = 0;
107  virtual void bound(const DT& xmin, const DT& xmax, CT& ymin, CT& ymax) = 0;
108  public:
109  virtual ~ALFunction(){}
111  const CT operator() (DT x) const { return f(x); }
112  // TODO this should be possible and would be better for correctness sake CT operator()(DT x) const { return f(x); }
113  bool isInDomain(DT x){return limitLo()<=x && x<=limitHi();}
117  CT f_bounded(DT x)
118  {
119  return f((std::max)(limitLo(),(std::min)(x,limitHi())));
120  }
126  virtual void f(DT* xvec, CT* yvec, unsigned int count) const //evaluate multi
127  {
128  for (unsigned int i = 0; i < count; i++)yvec[i] = f(xvec[i]);
129  }
133  void bound(CT& ymin, CT& ymax)
134  {
135  if (!cached_bounds_valid)
136  {
138  }
139  ymin = cached_ymin;
140  ymax = cached_ymax;
141  }
146  {
148  }
149  };
150 
159  template<typename T, int N>
160  void sample(ALFunction<T, adoreMatrix<T, N, 1>>* f, T* x, T* y, int dimension, unsigned int count)
161  {
162  adoreMatrix<T, N, 1> yi;
163  for (unsigned int i = 0; i < count; i++)
164  {
165  yi = (*f)(x[i]);
166  y[i] = yi(dimension);
167  }
168  }
169 
178  template<typename T, int N>
179  void sample(ALFunction<T, adoreMatrix<T, N, 1>>* f, const adoreMatrix<T,1,0>& x,adoreMatrix<T,N,0>& y,unsigned int K,int offset=0)
180  {
181  for (unsigned int i = 0; i < K; i++)
182  {
183  dlib::set_colm(y,i+offset) = (*f)(x(i));
184  }
185  }
186 
187 
195  template<typename T, int N>
196  void sample(ALFunction<T, adoreMatrix<T, N, 1>>* f, T* x, T* y, unsigned int count)//y must have size N*count
197  {
198  adoreMatrix<T, N, 1> yi;
199  for (unsigned int i = 0; i < count; i++)
200  {
201  yi = (*f)(x[i]);
202  for (unsigned int j = 0; j < N; j++)
203  {
204  y[i*N + j] = yi(j);
205  }
206  }
207  }
208 
212  template<typename T, int N>
213  class AScalarToN : public ALFunction<T, adoreMatrix<T, N, 1>>
214  {
215  public:
216  typedef T DT;
217  typedef adoreMatrix<T, N, 1> CT;
223  void toArray(DT* xvec, T* yvec, unsigned int count)
224  {
225  for (unsigned int i = 0; i < count; i++)
226  {
227  for (unsigned int j = 0; j < count; j++)
228  {
229  yvec[i*N + j] = fi(xvec[i], j);
230  }
231  }
232  }
233  //sapmle a range of x values and evaluate for one row of the vector only
234  void toArray(DT* xvec, T* yvec, unsigned int count, unsigned int row)
235  {
236  for (unsigned int i = 0; i < count; i++)
237  {
238  yvec[i] = fi(xvec[i], row);
239  }
240  }
244  virtual SUBFUN* dimension(int i) = 0;
248  virtual T fi(DT x, int dim) const = 0;
252  virtual void multiply(adoreMatrix<T, 0, 0> A, int rowi, int rowj) = 0;
256  virtual void add(adoreMatrix<T, 0, 1> b, int rowi, int rowj) = 0;
260  virtual void operator*=(adoreMatrix<T, N, N> A) { this->multiply(A, 1, N); }
261  virtual void operator+=(adoreMatrix<T, N, 1> b) { this->add(b, 1, N); }
262  virtual void operator-=(adoreMatrix<T, N, 1> b) { this->add(-b, 1, N); }
263  };
264 
273  template<typename T, int N>
274  void sample(AScalarToN<T,N>* f, const adoreMatrix<T,1,0>& x,adoreMatrix<T,N,0>& y,unsigned int K,int offset=0)
275  {
276  for (unsigned int i = 0; i < K; i++)
277  {
278  dlib::set_colm(y,i+offset) = (*f)(x(i));
279  }
280  }
281 
285  template<typename DT, typename CT>
286  class LConstFun :public ALFunction<DT, CT>
287  {
288  public:
291  LConstFun( const CT& value, DT xlo, DT xhi) :m_value(value) ,m_xlo(xlo),m_xhi(xhi){}
292  virtual CT f(DT x) const override { return m_value; }
293  virtual DT limitHi() const override { return m_xhi; }
294  virtual DT limitLo() const override { return m_xlo; }
295  virtual void invertDirection() {}
296  virtual void setLimits(DT lo, DT hi) {m_xlo = lo;m_xhi = hi;}
297  virtual ALFunction<DT, CT>* clone()override { return new LConstFun<DT, CT>(m_value,m_xlo,m_xhi); }
299  virtual void bound(const DT& xmin, const DT& xmax, CT& ymin, CT& ymax)override { ymin = m_value; ymax = m_value; }
300  };
301 
305  template<typename DT, typename CT>
306  class LLinearFunction : public ALFunction<DT, CT>
307  {
308  private:
311  public:
312  LLinearFunction(DT x0, DT x1, CT y0, CT dydx)
313  {
314  m_x0 = x0;
315  m_x1 = x1;
316  m_xLo = x0;
317  m_xHi = x1;
318  m_y0 = y0;
319  m_dydx = dydx;
320  }
321  LLinearFunction(DT x0, DT x1, CT y0, CT dydx, DT xLo, DT xHi)
322  {
323  m_x0 = x0;
324  m_x1 = x1;
325  m_xLo = xLo;
326  m_xHi = xHi;
327  m_y0 = y0;
328  m_dydx = dydx;
329  }
331  {
332  }
333  public://methods inherited from ALFunction interface
334  //function evaluation returns y of codomain type CT for a value x of domain type DT
335  virtual CT f(DT x) const override
336  {
337  return m_y0 + m_dydx*(x - m_x0);
338  }
339  virtual DT limitHi() const override
340  {
341  return m_xHi;
342  }
343  virtual DT limitLo() const override
344  {
345  return m_xLo;
346  }
347  //reduce or increase the limit of the function
348  virtual void setLimits(DT lo, DT hi) override
349  {
350  m_xLo = lo;
351  m_xHi = hi;
352  }
354  {
355  return new LConstFun<DT, CT>(m_dydx,m_xLo,m_xHi);
356  }
357  virtual void bound(const DT& xmin, const DT& xmax, CT& ymin, CT& ymax)override
358  {
359  CT y0 = f(xmin);
360  CT y1 = f(xmax);
361  ymin = (adore::mad::min)(y0, y1);
362  ymax = (adore::mad::max)(y0, y1);
363  }
364  virtual ALFunction<DT, CT>* clone() override
365  {
367  }
368  };
369 
373  template<typename DT, typename CT>
375  {
376  public:
379  //Objects *a and *b are henceforth managed by the FunctionCombination. Supply a clone as a and b if you want to retain control over the original objects.
381  {
382  this->a = a;
383  this->b = b;
384  }
386  {
387  delete a;
388  delete b;
389  }
390  virtual CT f(DT x) const override { return a->f(x) + b->f(x); }
391  virtual DT limitHi() const override { return (std::min)(a->limitHi(), b->limitHi()); }
392  virtual DT limitLo() const override { return (std::max)(a->limitLo(), b->limitLo()); }
393  virtual void setLimits(DT lo, DT hi)override { a->setLimits(lo, hi); b->setLimits(lo, hi); }
394  virtual ALFunction<DT, CT>* clone()override { return new FunctionCombination_Addition(a->clone(), b->clone()); }
395  virtual ALFunction<DT, CT>* create_derivative()override { return new FunctionCombination_Addition(a->create_derivative(), b->create_derivative()); }
396  virtual void bound(const DT& xmin, const DT& xmax, CT& ymin, CT& ymax)override
397  {
398  CT y0min, y0max, y1min, y1max;
399  a->bound(xmin, xmax, y0min, y0max);
400  b->bound(xmin, xmax, y1min, y1max);
401  ymin = y0min + y1min;
402  ymax = y0max + y1max;
403  }
404  };
405 
409  template<typename DT, typename CT, typename CTa, typename CTb>
411  {
412  public:
415  //Objects *a and *b are henceforth managed by the FunctionCombination. Supply a clone as a and b if you want to retain control over the original objects.
417  {
418  this->a = a;
419  this->b = b;
420  }
422  {
423  delete a;
424  delete b;
425  }
426  virtual CT f(DT x) const override { return a->f(x)*b->f(x); }
427  virtual DT limitHi() const override { return (std::min)(a->limitHi(), b->limitHi()); }
428  virtual DT limitLo() const override { return (std::max)(a->limitLo(), b->limitLo()); }
429  virtual void setLimits(DT lo, DT hi)override { a->setLimits(lo, hi); b->setLimits(lo, hi); }
432  {
435  a->create_derivative(),
436  b->clone()
437  ),
439  a->clone(),
441  )
442  );
443  }
444  virtual void bound(const DT& xmin, const DT& xmax, CT& ymin, CT& ymax)override
445  {
446  CTa y0min, y0max;
447  CTb y1min, y1max;
448  a->bound(xmin, xmax, y0min, y0max);
449  b->bound(xmin, xmax, y1min, y1max);
450  imultiply(y0min, y0max, y1min, y1max, ymin, ymax);
451  //auto y0_int = create_interval(y0min,y0max);
452  //auto y1_int = create_interval(y1min,y1max);
453  //imultiply(a,b,ymin,ymax);
454  //auto y_int = y0_int*y1_int;
455  //ymin = lower_bound(y_int);
456  //ymax = upper_bound(y_int);
457  }
458  };
459 
463  template<typename T,int N, int M, int K>
464  class FunctionCombination_Multiplication_Matrix :public ALFunction<T, adoreMatrix<T,N,K>>
465  {
466  public:
467  typedef T DT;
468  typedef adoreMatrix<T,N,M> CTa;
469  typedef adoreMatrix<T,M,K> CTb;
470  typedef adoreMatrix<T,N,K> CT;
473  //Objects *a and *b are henceforth managed by the FunctionCombination. Supply a clone as a and b if you want to retain control over the original objects.
475  {
476  this->a = a;
477  this->b = b;
478  }
480  {
481  delete a;
482  delete b;
483  }
484  virtual CT f(DT x) const override { return a->f(x)*b->f(x); }
485  virtual DT limitHi() const override { return (std::min)(a->limitHi(), b->limitHi()); }
486  virtual DT limitLo() const override { return (std::max)(a->limitLo(), b->limitLo()); }
487  virtual void setLimits(DT lo, DT hi)override { a->setLimits(lo, hi); b->setLimits(lo, hi); }
490  {
493  a->create_derivative(),
494  b->clone()
495  ),
497  a->clone(),
499  )
500  );
501  }
502  virtual void bound(const DT& xmin, const DT& xmax, CT& ymin, CT& ymax)override
503  {
504  CTa y0min, y0max;
505  CTb y1min, y1max;
506  a->bound(xmin, xmax, y0min, y0max);
507  b->bound(xmin, xmax, y1min, y1max);
508  imultiply<T,N,M,K>(y0min, y0max, y1min, y1max, ymin, ymax);
509  //auto y0_int = create_interval(y0min,y0max);
510  //auto y1_int = create_interval(y1min,y1max);
511  //imultiply(a,b,ymin,ymax);
512  //auto y_int = y0_int*y1_int;
513  //ymin = lower_bound(y_int);
514  //ymax = upper_bound(y_int);
515  }
516  };
517 
521  template<typename DT, typename CT, typename CTa, typename CTb>
523  {
524  public:
525  CTa a;
527  //Object *b is henceforth managed by the FunctionCombination. Supply a clone as a if you want to retain control over the original objects.
529  {
530  this->a = a;
531  this->b = b;
532  }
534  {
535  delete b;
536  }
537  virtual CT f(DT x) const override { return a*b->f(x); }
538  virtual DT limitHi() const override { return b->limitHi(); }
539  virtual DT limitLo() const override { return b->limitLo(); }
540  virtual void setLimits(DT lo, DT hi)override { b->setLimits(lo, hi); }
543  {
545  a,
547  );
548  }
549  virtual void bound(const DT& xmin, const DT& xmax, CT& ymin, CT& ymax)override
550  {
551  CTa y0min, y0max;
552  CTb y1min, y1max;
553  y0min = a; y0max = a;
554  b->bound(xmin, xmax, y1min, y1max);
555  imultiply(y0min, y0max, y1min, y1max, ymin, ymax);
556  }
557  };
558 
562  template<typename DTa, typename CTa, typename DTb>
563  class FunctionCombination_Chain :public ALFunction<DTb, CTa>
564  {
565  public:
568  typedef DTb DT;
569  typedef CTa CT;
570  //Objects *a and *b are henceforth managed by the FunctionCombination. Supply a clone as a and b if you want to retain control over the original objects.
572  {
573  this->a = a;
574  this->b = b;
575  }
577  {
578  delete a;
579  delete b;
580  }
581  virtual CTa f(DTb x) const override { return a->f(b->f(x)); }
582  virtual DTb limitHi() const override { return b->limitHi(); }
583  virtual DTb limitLo() const override { return b->limitLo(); }
584  virtual void setLimits(DT lo, DT hi)override { b->setLimits(lo, hi); }
585  virtual ALFunction<DT, CT>* clone()override { return new FunctionCombination_Chain(a->clone(), b->clone()); }
587  {
591  );
592  }
593  virtual void bound(const DTb& xmin, const DTb& xmax, CTa& ymin, CTa& ymax)override
594  {
595  DTa ybmin, ybmax;
596  b->bound(xmin, xmax, ybmin, ybmax);
597  a->bound(ybmin, ybmax, ymin, ymax);
598  }
599  };
600 
604  template<typename T, int Na, int Nb>
605  class FunctionCombination_Stack :public ALFunction<T, adoreMatrix<T, Na + Nb, 1>>
606  {
607  public:
608  typedef adoreMatrix<T, Na + Nb, 1> CT;
609  typedef adoreMatrix<T, Na, 1> CTa;
610  typedef adoreMatrix<T, Nb, 1> CTb;
611  typedef T DT;
614  //Objects *a and *b are henceforth managed by the FunctionCombination. Supply a clone as a and b if you want to retain control over the original objects.
616  {
617  this->a = a;
618  this->b = b;
619  }
621  {
622  delete a;
623  delete b;
624  }
625  virtual CT f(T x) const override
626  {
627  adoreMatrix<T, Na + Nb, 1> y;
628  set_rowm(y, dlib::range(0, Na - 1)) = a->f(x);
629  set_rowm(y, dlib::range(Na, Na + Nb - 1)) = b->f(x);
630  return y;
631  }
632  virtual DT limitHi() const override { return (std::min)(a->limitHi(), b->limitHi()); }
633  virtual DT limitLo() const override { return (std::max)(a->limitLo(), b->limitLo()); }
634  virtual void setLimits(DT lo, DT hi)override { a->setLimits(lo, hi); b->setLimits(lo, hi); }
635  virtual ALFunction<DT, CT>* clone()override
636  {
637  return new FunctionCombination_Stack(a->clone(), b->clone());
638  }
640  {
641  return new FunctionCombination_Stack(
644  );
645  }
646  virtual void bound(const DT& xmin, const DT& xmax, CT& ymin, CT& ymax)override
647  {
648  CTa yamin, yamax;
649  CTb ybmin, ybmax;
650  a->bound(xmin, xmax, yamin, yamax);
651  b->bound(xmin, xmax, ybmin, ybmax);
652  set_rowm(ymin, dlib::range(0, Na - 1)) = yamin;
653  set_rowm(ymax, dlib::range(0, Na - 1)) = yamax;
654  set_rowm(ymin, dlib::range(Na, Na + Nb - 1)) = ybmin;
655  set_rowm(ymax, dlib::range(Na, Na + Nb - 1)) = ybmax;
656  }
657  };
658 
662  template<typename T>
664  {
665  public:
666  typedef typename AScalarToN<T,2>::DT DT;
667  typedef typename AScalarToN<T,2>::CT CT;
671  //Objects *a and *b are henceforth managed by the FunctionCombination. Supply a clone as a and b if you want to retain control over the original objects.
673  {
674  this->a = a;
675  this->b = b;
676  }
678  {
679  delete a;
680  delete b;
681  }
682  virtual adoreMatrix<T, 2, 1> f(T x) const override
683  {
684  adoreMatrix<T, 2, 1> y;
685  y(0) = a->f(x);
686  y(1) = b->f(x);
687  return y;
688  }
689  virtual DT limitHi() const override { return (std::min)(a->limitHi(), b->limitHi()); }
690  virtual DT limitLo() const override { return (std::max)(a->limitLo(), b->limitLo()); }
691  virtual void setLimits(DT lo, DT hi)override { a->setLimits(hi, lo); b->setLimits(hi, lo); }
692  virtual ALFunction<DT, CT>* clone()override
693  {
695  a->clone(),
696  b->clone()
697  );
698  }
699  virtual SUBFUN* dimension(int i) override
700  {
701  if (i == 0)return a;
702  else return b;
703  }
704  virtual T fi(T x, int i) const override
705  {
706  if (i == 0)return a->f(x);
707  else return b->f(x);
708  }
709  virtual void multiply(adoreMatrix<T, 0, 0> A, int rowi, int rowj)
710  {
711  throw FunctionNotImplemented();
712  }
713  virtual void add(adoreMatrix<T, 0, 1> c, int rowi, int rowj)
714  {
715  throw FunctionNotImplemented();
716  }
718  {
720  a->create_derivative(),
722  );
723  }
724  virtual void bound(const T& xmin, const T& xmax, CT& ymin, CT& ymax)override
725  {
726  T yamin, yamax, ybmin, ybmax;
727  a->bound(xmin, xmax, yamin, yamax);
728  b->bound(xmin, xmax, ybmin, ybmax);
729  ymin(0) = yamin;
730  ymin(1) = ybmin;
731  ymax(0) = yamax;
732  ymax(1) = ybmax;
733  }
734  };
735 
736  namespace funop
737  {
741  template<typename DT, typename CT>
743  {
744  return new FunctionCombination_Addition<DT, CT>(a, b);
745  }
746 
750  template<typename DT, typename CT, typename CTa, typename CTb>
752  {
754  }
755 
759  template<typename T, int N,int M,int K>
760  ALFunction<T, adoreMatrix<T,N,K> >* mmultiply(ALFunction<T, adoreMatrix<T,N,M> >* a, ALFunction<T, adoreMatrix<T,M,K> >* b)
761  {
763  }
764 
768  template<typename DT, typename CT, typename CTa, typename CTb>
770  {
772  }
773 
777  template<typename DTa, typename CTa, typename DTb>
779  {
781  }
782 
786  template<typename T, int Na, int Nb>
787  ALFunction<T, adoreMatrix<T, Na + Nb, 1>>* stack(ALFunction<T, adoreMatrix<T, Na, 1>>* a, ALFunction<T, adoreMatrix<T, Nb, 1>>* b)
788  {
789  return new FunctionCombination_Stack<T, Na, Nb>(a, b);
790  }
791  template<typename T>
793  {
794  return new FunctionCombination_StackScalar<T>(a, b);
795  }
796 
801  template<typename DT, typename CT>
803  {
804  if (from < to)
805  {
806  return chain<DT, CT, DT>(f, new LLinearFunction<DT, DT>(from, to, f->limitLo(), (f->limitHi() - f->limitLo()) / (to - from)));
807  }
808  else
809  {
810  return chain<DT, CT, DT>(f, new LLinearFunction<DT, DT>(to, from, f->limitHi(), (f->limitHi() - f->limitLo()) / (to - from)));
811  }
812  }
813  }
814 
818  template<typename T>
820  {
821  public:
822  typedef T DT;
823  typedef T CT;
826  virtual void setLimits(DT lo, DT hi)override { m_divisor->setLimits(lo, hi); }
827  virtual CT f(DT x) const override { return ((T)1) / m_divisor->f(x); }
828  virtual DT limitHi() const override { return m_divisor->limitHi(); }
829  virtual DT limitLo() const override { return m_divisor->limitLo(); }
832  {
833  return funop::multiply<T, T, T, T>(
834  funop::minus<T, T, T, T>(
836  funop::multiply<T, T, T, T>(m_divisor->clone(), m_divisor->clone())
837  )
838  ),
839  m_divisor->create_derivative() //not to forget the chaining...
840  );
841  }
842  virtual void bound(const DT& xmin, const DT& xmax, CT& ymin, CT& ymax)
843  {
844  T ymin_divisor;
845  T ymax_divisor;
846  m_divisor->bound(xmin, xmax, ymin_divisor, ymax_divisor);
847  if (ymin_divisor < 0 && 0 < ymax_divisor)
848  {
850  }
851  else
852  {
853  if (ymin_divisor > 0)
854  {
855  ymax = f(ymin_divisor);
856  ymin = f(ymax_divisor);
857  }
858  else
859  {
860  ymax = f(ymax_divisor);
861  ymin = f(ymin_divisor);
862  }
863  }
864  }
865  };
866 
867  namespace funop
868  {
869  template<typename T>
871  {
872  return new FunctionModification_ReciprocalScalar<T>(divisor);
873  }
874  }
875  }
876 }
Definition: alfunction.h:74
const CT operator()(DT x) const
Definition: alfunction.h:111
CT cached_ymax
Definition: alfunction.h:76
CT f_bounded(DT x)
Definition: alfunction.h:117
virtual void f(DT *xvec, CT *yvec, unsigned int count) const
Definition: alfunction.h:126
ALFunction()
Definition: alfunction.h:110
virtual void bound(const DT &xmin, const DT &xmax, CT &ymin, CT &ymax)=0
virtual ALFunction< DT, CT > * clone()=0
bool isInDomain(DT x)
Definition: alfunction.h:113
virtual ~ALFunction()
Definition: alfunction.h:109
void invalidateCachedBounds()
Definition: alfunction.h:145
virtual CT f(DT x) const =0
virtual DT limitHi() const =0
virtual DT limitLo() const =0
void bound(CT &ymin, CT &ymax)
Definition: alfunction.h:133
virtual ALFunction< DT, CT > * create_derivative()=0
bool cached_bounds_valid
Definition: alfunction.h:77
CT cached_ymin
Definition: alfunction.h:76
virtual void setLimits(DT lo, DT hi)=0
Definition: alfunction.h:214
ALFunction< DT, T > SUBFUN
Definition: alfunction.h:218
T DT
Definition: alfunction.h:216
virtual SUBFUN * dimension(int i)=0
void toArray(DT *xvec, T *yvec, unsigned int count)
Definition: alfunction.h:223
adoreMatrix< T, N, 1 > CT
Definition: alfunction.h:217
virtual T fi(DT x, int dim) const =0
virtual void operator*=(adoreMatrix< T, N, N > A)
Definition: alfunction.h:260
void toArray(DT *xvec, T *yvec, unsigned int count, unsigned int row)
Definition: alfunction.h:234
virtual void add(adoreMatrix< T, 0, 1 > b, int rowi, int rowj)=0
virtual void operator+=(adoreMatrix< T, N, 1 > b)
Definition: alfunction.h:261
virtual void operator-=(adoreMatrix< T, N, 1 > b)
Definition: alfunction.h:262
virtual void multiply(adoreMatrix< T, 0, 0 > A, int rowi, int rowj)=0
Definition: alfunction.h:375
ALFunction< DT, CT > * a
Definition: alfunction.h:377
virtual ALFunction< DT, CT > * clone() override
Definition: alfunction.h:394
virtual CT f(DT x) const override
Definition: alfunction.h:390
virtual void setLimits(DT lo, DT hi) override
Definition: alfunction.h:393
ALFunction< DT, CT > * b
Definition: alfunction.h:378
virtual DT limitLo() const override
Definition: alfunction.h:392
virtual DT limitHi() const override
Definition: alfunction.h:391
virtual ~FunctionCombination_Addition()
Definition: alfunction.h:385
virtual ALFunction< DT, CT > * create_derivative() override
Definition: alfunction.h:395
FunctionCombination_Addition(ALFunction< DT, CT > *a, ALFunction< DT, CT > *b)
Definition: alfunction.h:380
virtual void bound(const DT &xmin, const DT &xmax, CT &ymin, CT &ymax) override
Definition: alfunction.h:396
Definition: alfunction.h:564
virtual void bound(const DTb &xmin, const DTb &xmax, CTa &ymin, CTa &ymax) override
Definition: alfunction.h:593
DTb DT
Definition: alfunction.h:568
virtual void setLimits(DT lo, DT hi) override
Definition: alfunction.h:584
virtual DTb limitHi() const override
Definition: alfunction.h:582
virtual CTa f(DTb x) const override
Definition: alfunction.h:581
virtual ALFunction< DT, CT > * create_derivative() override
Definition: alfunction.h:586
virtual ~FunctionCombination_Chain()
Definition: alfunction.h:576
virtual DTb limitLo() const override
Definition: alfunction.h:583
FunctionCombination_Chain(ALFunction< DTa, CTa > *a, ALFunction< DTb, DTa > *b)
Definition: alfunction.h:571
virtual ALFunction< DT, CT > * clone() override
Definition: alfunction.h:585
CTa CT
Definition: alfunction.h:569
ALFunction< DTa, CTa > * a
Definition: alfunction.h:566
ALFunction< DTb, DTa > * b
Definition: alfunction.h:567
virtual DT limitLo() const override
Definition: alfunction.h:539
virtual ALFunction< DT, CT > * create_derivative() override
Definition: alfunction.h:542
virtual DT limitHi() const override
Definition: alfunction.h:538
ALFunction< DT, CTb > * b
Definition: alfunction.h:526
virtual void bound(const DT &xmin, const DT &xmax, CT &ymin, CT &ymax) override
Definition: alfunction.h:549
FunctionCombination_MultiplicationConst(CTa a, ALFunction< DT, CTb > *b)
Definition: alfunction.h:528
virtual ALFunction< DT, CT > * clone() override
Definition: alfunction.h:541
virtual void setLimits(DT lo, DT hi) override
Definition: alfunction.h:540
virtual CT f(DT x) const override
Definition: alfunction.h:537
virtual ~FunctionCombination_MultiplicationConst()
Definition: alfunction.h:533
ALFunction< DT, CTb > * b
Definition: alfunction.h:472
virtual void setLimits(DT lo, DT hi) override
Definition: alfunction.h:487
virtual ALFunction< DT, CT > * create_derivative() override
Definition: alfunction.h:489
virtual void bound(const DT &xmin, const DT &xmax, CT &ymin, CT &ymax) override
Definition: alfunction.h:502
virtual CT f(DT x) const override
Definition: alfunction.h:484
ALFunction< DT, CTa > * a
Definition: alfunction.h:471
virtual ALFunction< DT, CT > * clone() override
Definition: alfunction.h:488
virtual DT limitLo() const override
Definition: alfunction.h:486
virtual ~FunctionCombination_Multiplication_Matrix()
Definition: alfunction.h:479
virtual DT limitHi() const override
Definition: alfunction.h:485
FunctionCombination_Multiplication_Matrix(ALFunction< DT, CTa > *a, ALFunction< DT, CTb > *b)
Definition: alfunction.h:474
adoreMatrix< T, N, K > CT
Definition: alfunction.h:470
adoreMatrix< T, M, K > CTb
Definition: alfunction.h:469
adoreMatrix< T, N, M > CTa
Definition: alfunction.h:468
FunctionCombination_Multiplication(ALFunction< DT, CTa > *a, ALFunction< DT, CTb > *b)
Definition: alfunction.h:416
ALFunction< DT, CTa > * a
Definition: alfunction.h:413
virtual ALFunction< DT, CT > * clone() override
Definition: alfunction.h:430
virtual DT limitHi() const override
Definition: alfunction.h:427
virtual ALFunction< DT, CT > * create_derivative() override
Definition: alfunction.h:431
virtual CT f(DT x) const override
Definition: alfunction.h:426
virtual void bound(const DT &xmin, const DT &xmax, CT &ymin, CT &ymax) override
Definition: alfunction.h:444
ALFunction< DT, CTb > * b
Definition: alfunction.h:414
virtual ~FunctionCombination_Multiplication()
Definition: alfunction.h:421
virtual DT limitLo() const override
Definition: alfunction.h:428
virtual void setLimits(DT lo, DT hi) override
Definition: alfunction.h:429
virtual ALFunction< DT, CT > * clone() override
Definition: alfunction.h:692
virtual DT limitLo() const override
Definition: alfunction.h:690
virtual SUBFUN * dimension(int i) override
Definition: alfunction.h:699
AScalarToN< T, 2 >::DT DT
Definition: alfunction.h:666
virtual adoreMatrix< T, 2, 1 > f(T x) const override
Definition: alfunction.h:682
virtual T fi(T x, int i) const override
Definition: alfunction.h:704
virtual void add(adoreMatrix< T, 0, 1 > c, int rowi, int rowj)
Definition: alfunction.h:713
virtual ALFunction< DT, CT > * create_derivative() override
Definition: alfunction.h:717
AScalarToN< T, 2 >::CT CT
Definition: alfunction.h:667
virtual void bound(const T &xmin, const T &xmax, CT &ymin, CT &ymax) override
Definition: alfunction.h:724
virtual DT limitHi() const override
Definition: alfunction.h:689
virtual void setLimits(DT lo, DT hi) override
Definition: alfunction.h:691
virtual void multiply(adoreMatrix< T, 0, 0 > A, int rowi, int rowj)
Definition: alfunction.h:709
ALFunction< T, T > SUBFUN
Definition: alfunction.h:668
SUBFUN * a
Definition: alfunction.h:669
SUBFUN * b
Definition: alfunction.h:670
virtual ~FunctionCombination_StackScalar()
Definition: alfunction.h:677
FunctionCombination_StackScalar(ALFunction< T, T > *a, ALFunction< T, T > *b)
Definition: alfunction.h:672
Definition: alfunction.h:606
T DT
Definition: alfunction.h:611
ALFunction< T, CTb > * b
Definition: alfunction.h:613
virtual ALFunction< DT, CT > * clone() override
Definition: alfunction.h:635
adoreMatrix< T, Na+Nb, 1 > CT
Definition: alfunction.h:608
virtual DT limitHi() const override
Definition: alfunction.h:632
virtual void setLimits(DT lo, DT hi) override
Definition: alfunction.h:634
virtual ALFunction< DT, CT > * create_derivative() override
Definition: alfunction.h:639
virtual void bound(const DT &xmin, const DT &xmax, CT &ymin, CT &ymax) override
Definition: alfunction.h:646
adoreMatrix< T, Nb, 1 > CTb
Definition: alfunction.h:610
virtual CT f(T x) const override
Definition: alfunction.h:625
adoreMatrix< T, Na, 1 > CTa
Definition: alfunction.h:609
ALFunction< T, CTa > * a
Definition: alfunction.h:612
FunctionCombination_Stack(ALFunction< T, CTa > *a, ALFunction< T, CTb > *b)
Definition: alfunction.h:615
virtual ~FunctionCombination_Stack()
Definition: alfunction.h:620
virtual DT limitLo() const override
Definition: alfunction.h:633
Definition: alfunction.h:54
FunctionIndexingError()
Definition: alfunction.h:56
virtual ALFunction< DT, CT > * clone()
Definition: alfunction.h:830
ALFunction< T, T > * m_divisor
Definition: alfunction.h:824
virtual DT limitHi() const override
Definition: alfunction.h:828
FunctionModification_ReciprocalScalar(ALFunction< T, T > *divisor)
Definition: alfunction.h:825
virtual void bound(const DT &xmin, const DT &xmax, CT &ymin, CT &ymax)
Definition: alfunction.h:842
virtual DT limitLo() const override
Definition: alfunction.h:829
virtual CT f(DT x) const override
Definition: alfunction.h:827
virtual ALFunction< DT, CT > * create_derivative()
Definition: alfunction.h:831
virtual void setLimits(DT lo, DT hi) override
Definition: alfunction.h:826
Definition: alfunction.h:38
FunctionNotImplemented()
Definition: alfunction.h:40
Definition: alfunction.h:46
FunctionNotInitialized()
Definition: alfunction.h:48
Definition: alfunction.h:30
FunctionOutOfBoundsException()
Definition: alfunction.h:32
Definition: alfunction.h:62
FunctionUnboundedException()
Definition: alfunction.h:64
Definition: alfunction.h:287
CT m_value
Definition: alfunction.h:289
virtual CT f(DT x) const override
Definition: alfunction.h:292
virtual DT limitHi() const override
Definition: alfunction.h:293
virtual void invertDirection()
Definition: alfunction.h:295
virtual DT limitLo() const override
Definition: alfunction.h:294
virtual ALFunction< DT, CT > * create_derivative() override
Definition: alfunction.h:298
DT m_xhi
Definition: alfunction.h:290
virtual void setLimits(DT lo, DT hi)
Definition: alfunction.h:296
LConstFun(const CT &value, DT xlo, DT xhi)
Definition: alfunction.h:291
DT m_xlo
Definition: alfunction.h:290
virtual void bound(const DT &xmin, const DT &xmax, CT &ymin, CT &ymax) override
Definition: alfunction.h:299
virtual ALFunction< DT, CT > * clone() override
Definition: alfunction.h:297
Definition: alfunction.h:307
virtual ALFunction< DT, CT > * clone() override
Definition: alfunction.h:364
virtual void bound(const DT &xmin, const DT &xmax, CT &ymin, CT &ymax) override
Definition: alfunction.h:357
DT m_xLo
Definition: alfunction.h:309
virtual DT limitLo() const override
Definition: alfunction.h:343
virtual ALFunction< DT, CT > * create_derivative() override
Definition: alfunction.h:353
LLinearFunction(DT x0, DT x1, CT y0, CT dydx)
Definition: alfunction.h:312
DT m_x0
Definition: alfunction.h:309
virtual CT f(DT x) const override
Definition: alfunction.h:335
CT m_y0
Definition: alfunction.h:310
LLinearFunction(DT x0, DT x1, CT y0, CT dydx, DT xLo, DT xHi)
Definition: alfunction.h:321
DT m_x1
Definition: alfunction.h:309
virtual ~LLinearFunction()
Definition: alfunction.h:330
DT m_xHi
Definition: alfunction.h:309
virtual void setLimits(DT lo, DT hi) override
Definition: alfunction.h:348
virtual DT limitHi() const override
Definition: alfunction.h:339
CT m_dydx
Definition: alfunction.h:310
ALFunction< T, adoreMatrix< T, Na+Nb, 1 > > * stack(ALFunction< T, adoreMatrix< T, Na, 1 >> *a, ALFunction< T, adoreMatrix< T, Nb, 1 >> *b)
Definition: alfunction.h:787
ALFunction< DTb, CTa > * chain(ALFunction< DTa, CTa > *a, ALFunction< DTb, DTa > *b)
Definition: alfunction.h:778
ALFunction< DT, CT > * multiply(ALFunction< DT, CTa > *a, ALFunction< DT, CTb > *b)
Definition: alfunction.h:751
ALFunction< T, adoreMatrix< T, N, K > > * mmultiply(ALFunction< T, adoreMatrix< T, N, M > > *a, ALFunction< T, adoreMatrix< T, M, K > > *b)
Definition: alfunction.h:760
ALFunction< DT, CT > * add(ALFunction< DT, CT > *a, ALFunction< DT, CT > *b)
Definition: alfunction.h:742
ALFunction< DT, CT > * stretch(ALFunction< DT, CT > *f, DT from, DT to)
Definition: alfunction.h:802
ALFunction< T, T > * reciprocal(ALFunction< T, T > *divisor)
Definition: alfunction.h:870
FunctionCombination_MultiplicationConst< DT, CT, CTa, CTb > * minus(ALFunction< DT, CTb > *b)
Definition: alfunction.h:769
void sample(ALFunction< T, adoreMatrix< T, N, 1 >> *f, T *x, T *y, int dimension, unsigned int count)
Definition: alfunction.h:160
T min(T a, T b, T c, T d)
Definition: adoremath.h:663
void imultiply(const adoreMatrix< T, N, M > &lba, const adoreMatrix< T, N, M > &uba, const adoreMatrix< T, M, K > &lbb, const adoreMatrix< T, M, K > &ubb, adoreMatrix< T, N, K > &lb, adoreMatrix< T, N, K > &ub)
Definition: intervalarithmetic.h:143
adoreMatrix< T, N, M > max(adoreMatrix< T, N, M > a, const adoreMatrix< T, N, M > &b)
Definition: adoremath.h:686
x0
Definition: adore_set_goal.py:25
x
Definition: adore_set_goal.py:30
y0
Definition: adore_set_goal.py:26
y
Definition: adore_set_goal.py:31
y1
Definition: adore_set_pose.py:29
x1
Definition: adore_set_pose.py:28
Definition: areaofeffectconverter.h:20