comparison main/optim/inst/cpiv_bard.m @ 9930:d30cfca46e8a octave-forge

optim: upgrade license to GPLv3+ and mention on DESCRIPTION the other package licenses
author carandraug
date Fri, 30 Mar 2012 15:14:48 +0000
parents 41f92a4ada86
children fba8cdd5f9ad
comparison
equal deleted inserted replaced
9929:df50d0ae107f 9930:d30cfca46e8a
1 %% Copyright (C) 2010, 2011 Olaf Till 1 %% Copyright (C) 2010, 2011 Olaf Till <olaf.till@uni-jena.de>
2 %% 2 %%
3 %% This program is free software; you can redistribute it and/or modify 3 %% This program is free software; you can redistribute it and/or modify it under
4 %% it under the terms of the GNU General Public License as published by 4 %% the terms of the GNU General Public License as published by the Free Software
5 %% the Free Software Foundation; either version 2 of the License, or (at 5 %% Foundation; either version 3 of the License, or (at your option) any later
6 %% your option) any later version. 6 %% version.
7 %% 7 %%
8 %% This program is distributed in the hope that it will be useful, but 8 %% This program is distributed in the hope that it will be useful, but WITHOUT
9 %% WITHOUT ANY WARRANTY; without even the implied warranty of 9 %% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 %% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11 %% General Public License for more details. 11 %% details.
12 %% 12 %%
13 %% You should have received a copy of the GNU General Public License 13 %% You should have received a copy of the GNU General Public License along with
14 %% along with this program; if not, write to the Free Software 14 %% this program; if not, see <http://www.gnu.org/licenses/>.
15 %% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301USA 15
16 %% [lb, idx, ridx, mv] = cpiv_bard (v, m[, incl])
17 %%
18 %% v: column vector; m: matrix; incl (optional): index. length (v)
19 %% must equal rows (m). Finds column vectors w and l with w == v + m *
20 %% l, w >= 0, l >= 0, l.' * w == 0. Chooses idx, w, and l so that
21 %% l(~idx) == 0, l(idx) == -inv (m(idx, idx)) * v(idx), w(idx) roughly
22 %% == 0, and w(~idx) == v(~idx) + m(idx, ~idx).' * l(idx). idx indexes
23 %% at least everything indexed by incl, but l(incl) may be < 0. lb:
24 %% l(idx) (column vector); idx: logical index, defined above; ridx:
25 %% ~idx & w roughly == 0; mv: [m, v] after performing a Gauss-Jordan
26 %% 'sweep' (with gjp.m) on each diagonal element indexed by idx.
27 %% Except the handling of incl (which enables handling of equality
28 %% constraints in the calling code), this is called solving the
29 %% 'complementary pivot problem' (Cottle, R. W. and Dantzig, G. B.,
30 %% 'Complementary pivot theory of mathematical programming', Linear
31 %% Algebra and Appl. 1, 102--125. References for the current
32 %% algorithm: Bard, Y.: Nonlinear Parameter Estimation, p. 147--149,
33 %% Academic Press, New York and London 1974; Bard, Y., 'An eclectic
34 %% approach to nonlinear programming', Proc. ANU Sem. Optimization,
35 %% Canberra, Austral. Nat. Univ.).
16 36
17 function [lb, idx, ridx, m] = cpiv_bard (v, m, incl) 37 function [lb, idx, ridx, m] = cpiv_bard (v, m, incl)
18
19 %% [lb, idx, ridx, mv] = cpiv_bard (v, m[, incl])
20 %%
21 %% v: column vector; m: matrix; incl (optional): index. length (v)
22 %% must equal rows (m). Finds column vectors w and l with w == v + m *
23 %% l, w >= 0, l >= 0, l.' * w == 0. Chooses idx, w, and l so that
24 %% l(~idx) == 0, l(idx) == -inv (m(idx, idx)) * v(idx), w(idx) roughly
25 %% == 0, and w(~idx) == v(~idx) + m(idx, ~idx).' * l(idx). idx indexes
26 %% at least everything indexed by incl, but l(incl) may be < 0. lb:
27 %% l(idx) (column vector); idx: logical index, defined above; ridx:
28 %% ~idx & w roughly == 0; mv: [m, v] after performing a Gauss-Jordan
29 %% 'sweep' (with gjp.m) on each diagonal element indexed by idx.
30 %% Except the handling of incl (which enables handling of equality
31 %% constraints in the calling code), this is called solving the
32 %% 'complementary pivot problem' (Cottle, R. W. and Dantzig, G. B.,
33 %% 'Complementary pivot theory of mathematical programming', Linear
34 %% Algebra and Appl. 1, 102--125. References for the current
35 %% algorithm: Bard, Y.: Nonlinear Parameter Estimation, p. 147--149,
36 %% Academic Press, New York and London 1974; Bard, Y., 'An eclectic
37 %% approach to nonlinear programming', Proc. ANU Sem. Optimization,
38 %% Canberra, Austral. Nat. Univ.).
39 38
40 n = length (v); 39 n = length (v);
41 if (n > size (v, 1)) 40 if (n > size (v, 1))
42 error ('first argument is no column vector'); % the most typical mistake 41 error ('first argument is no column vector'); % the most typical mistake
43 end 42 end