Mercurial > forge
comparison main/optim/inst/gjp.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 %% m = gjp (m, k[, l]) | |
17 %% | |
18 %% m: matrix; k, l: row- and column-index of pivot, l defaults to k. | |
19 %% | |
20 %% Gauss-Jordon pivot as defined in Bard, Y.: Nonlinear Parameter | |
21 %% Estimation, p. 296, Academic Press, New York and London 1974. In | |
22 %% the pivot column, this seems not quite the same as the usual | |
23 %% Gauss-Jordan(-Clasen) pivot. Bard gives Beaton, A. E., 'The use of | |
24 %% special matrix operators in statistical calculus' Research Bulletin | |
25 %% RB-64-51 (1964), Educational Testing Service, Princeton, New Jersey | |
26 %% as a reference, but this article is not easily accessible. Another | |
27 %% reference, whose definition of gjp differs from Bards by some | |
28 %% signs, is Clarke, R. B., 'Algorithm AS 178: The Gauss-Jordan sweep | |
29 %% operator with detection of collinearity', Journal of the Royal | |
30 %% Statistical Society, Series C (Applied Statistics) (1982), 31(2), | |
31 %% 166--168. | |
16 | 32 |
17 function m = gjp (m, k, l) | 33 function m = gjp (m, k, l) |
18 | |
19 %% m = gjp (m, k[, l]) | |
20 %% | |
21 %% m: matrix; k, l: row- and column-index of pivot, l defaults to k. | |
22 %% | |
23 %% Gauss-Jordon pivot as defined in Bard, Y.: Nonlinear Parameter | |
24 %% Estimation, p. 296, Academic Press, New York and London 1974. In | |
25 %% the pivot column, this seems not quite the same as the usual | |
26 %% Gauss-Jordan(-Clasen) pivot. Bard gives Beaton, A. E., 'The use of | |
27 %% special matrix operators in statistical calculus' Research Bulletin | |
28 %% RB-64-51 (1964), Educational Testing Service, Princeton, New Jersey | |
29 %% as a reference, but this article is not easily accessible. Another | |
30 %% reference, whose definition of gjp differs from Bards by some | |
31 %% signs, is Clarke, R. B., 'Algorithm AS 178: The Gauss-Jordan sweep | |
32 %% operator with detection of collinearity', Journal of the Royal | |
33 %% Statistical Society, Series C (Applied Statistics) (1982), 31(2), | |
34 %% 166--168. | |
35 | 34 |
36 if (nargin < 3) | 35 if (nargin < 3) |
37 l = k; | 36 l = k; |
38 end | 37 end |
39 | 38 |
49 m([1:k-1, k+1:end], [1:l-1, l+1:end]) = ... % except pivot row and col | 48 m([1:k-1, k+1:end], [1:l-1, l+1:end]) = ... % except pivot row and col |
50 m([1:k-1, k+1:end], [1:l-1, l+1:end]) - ... | 49 m([1:k-1, k+1:end], [1:l-1, l+1:end]) - ... |
51 m([1:k-1, k+1:end], l) * m(k, [1:l-1, l+1:end]); | 50 m([1:k-1, k+1:end], l) * m(k, [1:l-1, l+1:end]); |
52 m([1:k-1, k+1:end], l) = - m([1:k-1, k+1:end], l) / p; % pivot column | 51 m([1:k-1, k+1:end], l) = - m([1:k-1, k+1:end], l) / p; % pivot column |
53 m(k, l) = 1 / p; | 52 m(k, l) = 1 / p; |
53 end |