28 template<
typename DT,
typename CT>
32 std::vector<ALFunction<DT, CT>*>
m_data;
46 for (
unsigned int i = 0; i <
m_data.size(); i++)
delete m_data.at(i);
56 unsigned int lower = 0;
57 unsigned int upper =
m_data.size() - 1;
66 unsigned int new_index = (std::ceil)((
float)(
m_searchIndex + upper) / 2.0f);
74 unsigned int new_index = (std::floor)((
float)(
m_searchIndex + lower) / 2.0f);
88 std::cout<<
"domain error: old function's high limit is "<<
limitHi()<<
", new functions low limit is "<<newfun->
limitLo()<<
"\n";
109 virtual CT
f(DT
x)
const override
122 return m_data.at(0)->limitLo();
139 std::vector<int> indicesToRemove;
142 for(
unsigned int i=0; i <
m_data.size(); i++)
145 if(
m_data.at(i)->limitHi() <= lo)
147 indicesToRemove.push_back(i);
152 if(
m_data.at(i)->limitLo() >= hi)
154 indicesToRemove.push_back(i);
160 if(
m_data.at(i)->limitLo() < lo)
165 if(
m_data.at(i)->limitHi() > hi)
173 for(
int i = indicesToRemove.size()-1; i >= 0; i--)
183 for (
auto it =
m_data.begin(); it !=
m_data.end(); it++)
185 derivative->
appendHi((*it)->create_derivative());
192 for (
auto it =
m_data.begin(); it !=
m_data.end(); it++)
198 virtual void bound(
const DT& xmin,
const DT& xmax, CT& ymin, CT& ymax)
override
204 m_data.at(i0)->bound(xmin, xmax, ymin, ymax);
208 CT ymin_tmp, ymax_tmp;
209 m_data.at(i0)->bound(xmin,
m_data.at(i0)->limitHi(), ymin, ymax);
210 m_data.at(i1)->bound(
m_data.at(i1)->limitLo(), xmax, ymin_tmp, ymax_tmp);
213 for (
int i = i0 + 1; i < i1; i++)
215 m_data.at(i)->bound(ymin_tmp, ymax_tmp);
226 for (
int i = 0; i < xymatrix.nc() - 1; i++)
228 T
x0 = xymatrix(0, i);
229 T
x1 = xymatrix(0, i + 1);
230 T
y0 = xymatrix(1, i);
231 T
y1 = xymatrix(1, i + 1);
240 for (
int i = 0; i < xvec.nc() - 1; i++)
243 T
x1 = xvec(0, i + 1);
245 T
y1 = yvec(row, i + 1);
250 template<
typename T,
int n>
254 for (
int i = 0; i < xvec.nc() - 1; i++)
258 adoreMatrix<T, n, 1>
y0 = dlib::colm(ymatrix, i);
259 adoreMatrix<T, n, 1>
y1 = dlib::colm(ymatrix, i+1);
264 template<
typename T,
int n>
268 for (
int i = 0; i < xymatrix.nc() - 1; i++)
270 T
x0 = xymatrix(0, i);
271 T
x1 = xymatrix(0, i + 1);
272 adoreMatrix<T, n, 1>
y0 = dlib::subm(xymatrix,dlib::range(1,xymatrix.nr()),dlib::range(i, i));
273 adoreMatrix<T, n, 1>
y1 = dlib::subm(xymatrix,dlib::range(1,xymatrix.nr()),dlib::range(i+1, i+1));
278 template<
typename T,
int n>
281 for (
int i = 0; i < count; i++)
283 ydest[i] = fun->f(xvec[i])(row);
Definition: alfunction.h:74
virtual DT limitHi() const =0
virtual DT limitLo() const =0
Definition: alfunction.h:54
Definition: alfunction.h:46
Definition: alfunction.h:30
Definition: alfunction.h:307
Definition: lpiecewisefunction.h:30
virtual void setLimits(DT lo, DT hi) override
Definition: lpiecewisefunction.h:125
virtual DT limitHi() const override
Definition: lpiecewisefunction.h:114
virtual void bound(const DT &xmin, const DT &xmax, CT &ymin, CT &ymax) override
Definition: lpiecewisefunction.h:198
virtual DT limitLo() const override
Definition: lpiecewisefunction.h:119
LPiecewiseFunction()
Definition: lpiecewisefunction.h:36
unsigned int m_searchIndex
Definition: lpiecewisefunction.h:33
virtual ALFunction< DT, CT > * clone() override
Definition: lpiecewisefunction.h:189
virtual ALFunction< DT, CT > * create_derivative() override
Definition: lpiecewisefunction.h:180
std::vector< ALFunction< DT, CT > * > m_data
Definition: lpiecewisefunction.h:32
unsigned int findIndex(DT x) const
Definition: lpiecewisefunction.h:50
LPiecewiseFunction(bool deconstruct_pieces)
Definition: lpiecewisefunction.h:37
void appendHi(ALFunction< DT, CT > *newfun)
Definition: lpiecewisefunction.h:82
virtual CT f(DT x) const override
Definition: lpiecewisefunction.h:109
void setDeconstructPieces(bool value)
Definition: lpiecewisefunction.h:38
bool m_deconstruct_pieces
Definition: lpiecewisefunction.h:34
void appendHi_shifted(ALFunction< DT, CT > *newfun)
Definition: lpiecewisefunction.h:95
virtual ~LPiecewiseFunction()
Definition: lpiecewisefunction.h:42
ALFunction< DT, CT > * stretch(ALFunction< DT, CT > *f, DT from, DT to)
Definition: alfunction.h:802
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
LPiecewiseFunction< T, T > * createPiecewiseLinear(const adoreMatrix< T, 2, 0 > &xymatrix)
Definition: lpiecewisefunction.h:223
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
y1
Definition: adore_set_pose.py:29
x1
Definition: adore_set_pose.py:28
Definition: areaofeffectconverter.h:20