lft_direct - [For comparison only] Legendre-Fenchel conjugate, direct computation
Warning: This function is provided only for comparison purposes and unit testing, use the more efficient lft_llt or lft_plt for faster computation.
Compute numerically the discrete Legendre transform of a set of planar points (X(i),Y(i)) at slopes S, i.e.,
Conj(j)=max[S(j)*X(i)-Y(i)]. iIt uses straight computation for a quadratic-time algorithm theta(n*m) with n=length(X)=length(Y) and m=length(S).
S=(-10:1:10)'; X1=(-2:0.2:2)';f=abs(X1);C1 = lft_direct(X1, f, S); X2=(-4:0.4:4)';f=abs(X2);C2 = lft_direct(X2, f, S); X3=(-8:0.8:8)';f=abs(X3);C3 = lft_direct(X3, f, S); X4=(-160:16:160)';f=abs(X4);C4 = lft_direct(X4, f, S); scf(0);clf; plot2d([S S S S],[C1 C2 C3 C4],rect=[-3,-0.5,3,10]); xtitle("Convergence of the discrete Legendre transform of the absolute value to the indicator of [-1,1]");
Yves Lucet, University of British Columbia, BC, Canada