### 5.1 A complementary pivoting algorithm ¶

#### Helptext: ¶

    [lb, idx, ridx, mv] = cpiv_bard (v, m[, incl])

    v: column vector; m: matrix; incl (optional): index. length (v)
    must equal rows (m). Finds column vectors w and l with w == v + m *
    l, w >= 0, l >= 0, l.' * w == 0. Chooses idx, w, and l so that
    l(~idx) == 0, l(idx) == -inv (m(idx, idx)) * v(idx), w(idx) roughly
    == 0, and w(~idx) == v(~idx) + m(idx, ~idx).' * l(idx). idx indexes
    at least everything indexed by incl, but l(incl) may be < 0. lb:
    l(idx) (column vector); idx: logical index, defined above; ridx:
    ~idx & w roughly == 0; mv: [m, v] after performing a Gauss-Jordan
    'sweep' (with gjp.m) on each diagonal element indexed by idx.
    Except the handling of incl (which enables handling of equality
    constraints in the calling code), this is called solving the
    'complementary pivot problem' (Cottle, R. W. and Dantzig, G. B.,
    'Complementary pivot theory of mathematical programming', Linear
    Algebra and Appl. 1, 102--125. References for the current
    algorithm: Bard, Y.: Nonlinear Parameter Estimation, p. 147--149,
    Academic Press, New York and London 1974; Bard, Y., 'An eclectic
    approach to nonlinear programming', Proc. ANU Sem. Optimization,
    Canberra, Austral. Nat. Univ.).