## Name

pl_lft_generic — Generic Legendre Fenchel Transform (LFT)

## Calling Sequence

    [Conj]=pl_lft_generic(X,Y,S)
    [Conj]=pl_lft_generic(X,Y,S,isConvex)
    [Conj]=pl_lft_generic(Xr,Xc,f,Sr,Sc)
    [Conj]=pl_lft_generic(Xr,Xc,f,Sr,Sc,isConvex)

## Parameters

X

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

Y

  column vector. The value of the function on the grid X: usually Y(i)=f(X(i)) for some function f.

S

  column vector. The grid on which we want to compute the conjugate: f* is evaluated on S.

isConvex

  Boolean value either true or false depending if the given function is known to be convex or not. (Note, if convex parameter is true then must use method lft for computation)

Xr

  column vector of length n.

Xc

  column vector of length m.

f

  matrix of size nxm. The function f is sampled on a grid Xr x Xc so f(i,j)=fu(Xr(i),Xc(j)) for some function fu.

Sr

  column vector of size m1.

Sc

  column vector of size m2. The Conjugate is computed on a grid SrxSc.

Conj

  matrix of size m1xm2 containing the Conjugate of the function f.

## Description

<listitem>

The fenchel function is a wrapper for two different conjugate computations depending on the calling sequence. The first calling sequence [Conj]=pl_lft_generic(X,Y,S) uses pl_lft_llt function for the 1D lft computation. The third calling sequence [Conj]=pl_lft_generic(Xr,Xc,f,Sr,Sc) uses the pl_lft_llt_2d function for the 2D lft computation. The second and fourth calling sequence have an additional boolean parameter isConvex to speed up computational time for each dimension. For a more detailed description see links below.

</listitem>

## Examples

    //Example 1. First Calling Sequence
    X = [1:1:10]'
    Y = 0.5.*(X.^2)
    [Conjw] = pl_lft_generic(X, Y, X);

    //Example 2. Second Calling Sequence
    X = [1:1:10]'
    Y = 0.5.*(X.^2)
    [Conjw] = pl_lft_generic(X, Y, X, %t);

    //Example 3. Third Calling Sequence
    //xr and xc is the grid which f is evaluated on
    Xr=(-2:1:2)'; //x
    Xc=(-2:1:2)'; //y
    //sr and sc is the grid which f* is evaluated on
    Sr=(-2:1:2)';
    Sc=(-2:1:2)';
    f = rand(size(Xr,1),size(Xc,1));
    [Conj] = pl_lft_generic(Xr,Xc,f,Sr,Sc);

    //Example 4. Fourth Calling Sequence
    Xr=(-2:1:2)'; //x
    Xc=(-2:1:2)'; //y
    //sr and sc is the grid which f* is evaluated on
    Sr=(-2:1:2)';
    Sc=(-2:1:2)';
    f = rand(size(Xr,1),size(Xc,1));
    [Conj] = pl_lft_generic(Xr,Xc,f,Sr,Sc,%f);

## See Also

pl_lft_llt , lft_2d

## Authors

`Mike Trienis`, University of British Columbia, BC, Canada