Piecewise linear quadratic (plq), build a zeroth- or first-order function approximation
plqf = plq_build(x,f,df) plqf = plq_build(x,f,df [,needEval] [,exclude] [,method] [,extrapolate])
column vector. A grid of points on which the function is sampled.
function. The function to build a PLQ representation of.
function, optional. The derivative of f.
boolean, optional. False, or not entered implies that function does not need to be evaluated and the function is vectorized, otherwise evaluate point by point.
boolean, optional.
boolean, optional. The method 'plq' or not entered implies a normal plq approximation. The method 'soqs' uses a Shape-Preserving Osculatory Spline approximation (see McAllister and Roulier, ACM TOMS, Sep. 1981). If no derivatives are provided, forward differentiation is used for 'plq' and shape-preserving calculation is used for 'soqs'.
string, optional. 'constant' (default) or 'bounded' to extend outside of domain by constant of %inf.
Builds a plq approximation of a function when given a function and optionally the function's derivative. If df is given, a first-order model is built, otherwise a zeroth-order model is built.
//Example 1 x=linspace(0,4)'; plqf = plq_build(x,exp,exp); y=plq_eval(plqf,x); //Example 2 function y=f(x),i1=find(x<0);i2=find(x==0);i3=find(x>0);y(i1)=%inf*ones(i1);y(i2)=0;y(i3)=x(i3).*log(x(i3))-x(i3);endfunction function y=df(x),i1=find(x<=0);i2=find(x>0);y(i1)=%inf*ones(i1);y(i2)=log(x(i2));endfunction x=linspace(0,20,3)'; plqf = plq_build(x,f,df); y = plq_eval(plqf,x); | ![]() | ![]() |
Yves Lucet
, University of British Columbia, BC, Canada