<< plq_check | plq | plq_co >>

CCA (Computational Convex Analysis) >> plq > plq_clean

# plq_clean

Piecewise linear quadratic (plq), clears duplicate rows

### Calling Sequence

    [plqClean] = plq_clean(plqDirty)

### Parameters

plqDirty

  matrix. A plq function with dimensions n x 4.

plqClean

  matrix. A plq function with dimensions n x 4.

### Description

The plq_clean function is used to help clear duplicate rows which arise during the plq fenchel conjugate operation. For example, the function reduces the number of rows by merging these two pieces of a plq function into one e.g. [0,1,0,0;0,1,0,0] -> [0,1,0,0]. The function also compresses duplicate point values e.g. [0,1,0,1;0,2,0,0] -> [0,1,0,1], and merges adjacent rows that are always infinite (which arise in plq_add).

This algorithm runs in O(n) time, where n is the number of pieces in plqf.

### Examples

    // Example 1. Clear Duplicate Points
    plqDirty=[0,1,0,0;0,2,0,0;1,2,3,4;%inf,3,0,0];
    plqClean=plq_clean(plqDirty);
    // plqClean == [0,1,0,0;1,2,3,4;%inf,3,0,0];

    // Example 2. Clear Duplicate Rows
    plqDirty=[0,1,0,0;0,1,0,0;1,2,3,4;%inf,3,0,0];
    plqClean=plq_clean(plqDirty);
    // plqClean == [0,1,0,0;1,2,3,4;%inf,3,0,0];

    // Example 3. Clear Duplicate Infinites
    plqDirty = [-1  ,  0,  -1, %inf; ...
                -0.5,  0,   1, %inf; ...
                 0  ,  0,   1, 1   ; ...
                 0.5,  0,  -1, 1   ; ...
                 1  ,  0,  -1, %inf; ...
                %inf,  0,   1, %inf];
    plqClean = plq_clean(plqDirty);
    // plqClean == [-0.5,  0,  0, %inf; ...
    //               0  ,  0,  1, 1   ; ...
    //               0.5,  0, -1, 1   ; ...
    //              %inf,  0,  0, %inf];

### See Also

- plq_function

### Authors

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

<< plq_check | plq | plq_co >>