40 FunctionNotImplemented() :runtime_error(
"An function has been called on an ALFunction object, which is not implemented.") {}
48 FunctionNotInitialized() :runtime_error(
"An operation has been called on an ALFunction object, although the object is not properly initialized.") {}
72 template<
typename DT,
typename CT>
95 virtual CT
f(DT
x)
const = 0;
107 virtual void bound(
const DT& xmin,
const DT& xmax, CT& ymin, CT& ymax) = 0;
126 virtual void f(DT* xvec, CT* yvec,
unsigned int count)
const
128 for (
unsigned int i = 0; i < count; i++)yvec[i] =
f(xvec[i]);
159 template<
typename T,
int N>
162 adoreMatrix<T, N, 1> yi;
163 for (
unsigned int i = 0; i < count; i++)
166 y[i] = yi(dimension);
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)
181 for (
unsigned int i = 0; i < K; i++)
183 dlib::set_colm(
y,i+offset) = (*f)(
x(i));
195 template<
typename T,
int N>
198 adoreMatrix<T, N, 1> yi;
199 for (
unsigned int i = 0; i < count; i++)
202 for (
unsigned int j = 0; j < N; j++)
212 template<
typename T,
int N>
217 typedef adoreMatrix<T, N, 1>
CT;
225 for (
unsigned int i = 0; i < count; i++)
227 for (
unsigned int j = 0; j < count; j++)
229 yvec[i*N + j] =
fi(xvec[i], j);
234 void toArray(
DT* xvec, T* yvec,
unsigned int count,
unsigned int row)
236 for (
unsigned int i = 0; i < count; i++)
238 yvec[i] =
fi(xvec[i], row);
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;
273 template<
typename T,
int N>
276 for (
unsigned int i = 0; i < K; i++)
278 dlib::set_colm(
y,i+offset) = (*f)(
x(i));
285 template<
typename DT,
typename CT>
299 virtual void bound(
const DT& xmin,
const DT& xmax, CT& ymin, CT& ymax)
override { ymin =
m_value; ymax =
m_value; }
305 template<
typename DT,
typename CT>
335 virtual CT
f(DT
x)
const override
357 virtual void bound(
const DT& xmin,
const DT& xmax, CT& ymin, CT& ymax)
override
373 template<
typename DT,
typename CT>
390 virtual CT
f(DT
x)
const override {
return a->f(
x) +
b->f(
x); }
393 virtual void setLimits(DT lo, DT hi)
override {
a->setLimits(lo, hi);
b->setLimits(lo, hi); }
396 virtual void bound(
const DT& xmin,
const DT& xmax, CT& ymin, CT& ymax)
override
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;
409 template<
typename DT,
typename CT,
typename CTa,
typename CTb>
426 virtual CT
f(DT
x)
const override {
return a->
f(
x)*
b->
f(
x); }
444 virtual void bound(
const DT& xmin,
const DT& xmax, CT& ymin, CT& ymax)
override
448 a->
bound(xmin, xmax, y0min, y0max);
449 b->
bound(xmin, xmax, y1min, y1max);
450 imultiply(y0min, y0max, y1min, y1max, ymin, ymax);
463 template<
typename T,
int N,
int M,
int K>
468 typedef adoreMatrix<T,N,M>
CTa;
469 typedef adoreMatrix<T,M,K>
CTb;
470 typedef adoreMatrix<T,N,K>
CT;
502 virtual void bound(
const DT& xmin,
const DT& xmax,
CT& ymin,
CT& ymax)
override
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);
521 template<
typename DT,
typename CT,
typename CTa,
typename CTb>
537 virtual CT
f(DT
x)
const override {
return a*
b->
f(
x); }
549 virtual void bound(
const DT& xmin,
const DT& xmax, CT& ymin, CT& ymax)
override
553 y0min =
a; y0max =
a;
554 b->
bound(xmin, xmax, y1min, y1max);
555 imultiply(y0min, y0max, y1min, y1max, ymin, ymax);
562 template<
typename DTa,
typename CTa,
typename DTb>
581 virtual CTa
f(DTb
x)
const override {
return a->
f(
b->
f(
x)); }
593 virtual void bound(
const DTb& xmin,
const DTb& xmax, CTa& ymin, CTa& ymax)
override
596 b->
bound(xmin, xmax, ybmin, ybmax);
597 a->
bound(ybmin, ybmax, ymin, ymax);
604 template<
typename T,
int Na,
int Nb>
608 typedef adoreMatrix<T, Na + Nb, 1>
CT;
609 typedef adoreMatrix<T, Na, 1>
CTa;
610 typedef adoreMatrix<T, Nb, 1>
CTb;
625 virtual CT f(T
x)
const override
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);
646 virtual void bound(
const DT& xmin,
const DT& xmax,
CT& ymin,
CT& ymax)
override
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;
682 virtual adoreMatrix<T, 2, 1>
f(T
x)
const override
684 adoreMatrix<T, 2, 1>
y;
704 virtual T
fi(T
x,
int i)
const override
706 if (i == 0)
return a->
f(
x);
709 virtual void multiply(adoreMatrix<T, 0, 0> A,
int rowi,
int rowj)
713 virtual void add(adoreMatrix<T, 0, 1> c,
int rowi,
int rowj)
724 virtual void bound(
const T& xmin,
const T& xmax,
CT& ymin,
CT& ymax)
override
726 T yamin, yamax, ybmin, ybmax;
727 a->
bound(xmin, xmax, yamin, yamax);
728 b->
bound(xmin, xmax, ybmin, ybmax);
741 template<
typename DT,
typename CT>
750 template<
typename DT,
typename CT,
typename CTa,
typename CTb>
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)
768 template<
typename DT,
typename CT,
typename CTa,
typename CTb>
777 template<
typename DTa,
typename CTa,
typename DTb>
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)
801 template<
typename DT,
typename CT>
833 return funop::multiply<T, T, T, T>(
834 funop::minus<T, T, T, T>(
847 if (ymin_divisor < 0 && 0 < ymax_divisor)
853 if (ymin_divisor > 0)
855 ymax =
f(ymin_divisor);
856 ymin =
f(ymax_divisor);
860 ymax =
f(ymax_divisor);
861 ymin =
f(ymin_divisor);
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
Definition: alfunction.h:523
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
CTa a
Definition: alfunction.h:525
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
Definition: alfunction.h:465
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
T DT
Definition: alfunction.h:467
adoreMatrix< T, N, M > CTa
Definition: alfunction.h:468
Definition: alfunction.h:411
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
Definition: alfunction.h:664
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
Definition: alfunction.h:820
T CT
Definition: alfunction.h:823
T DT
Definition: alfunction.h:822
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