<< plq_add plq plq_check >>

CCA (Computational Convex Analysis) >> plq > plq_build

plq_build

Piecewise linear quadratic (plq), build a zeroth- or first-order function approximation

Calling Sequence

plqf = plq_build(x,f,df)
plqf = plq_build(x,f,df [,needEval] [,exclude] [,method] [,extrapolate])

Parameters

x

column vector. A grid of points on which the function is sampled.

f

function. The function to build a PLQ representation of.

df

function, optional. The derivative of f.

needEval

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.

exclude

boolean, optional.

method

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'.

extrapolate

string, optional. 'constant' (default) or 'bounded' to extend outside of domain by constant of %inf.

Description

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.

Examples

//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);

See Also

Authors

Yves Lucet, University of British Columbia, BC, Canada


Report an issue
<< plq_add plq plq_check >>