This list is closed, nobody may subscribe to it.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(10) |
Aug
(5) |
Sep
(3) |
Oct
(41) |
Nov
(41) |
Dec
(33) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(75) |
Feb
(10) |
Mar
(170) |
Apr
(174) |
May
(66) |
Jun
(11) |
Jul
(10) |
Aug
(44) |
Sep
(73) |
Oct
(28) |
Nov
(139) |
Dec
(52) |
2003 |
Jan
(35) |
Feb
(93) |
Mar
(62) |
Apr
(10) |
May
(55) |
Jun
(70) |
Jul
(37) |
Aug
(16) |
Sep
(56) |
Oct
(31) |
Nov
(57) |
Dec
(83) |
2004 |
Jan
(85) |
Feb
(67) |
Mar
(27) |
Apr
(37) |
May
(75) |
Jun
(85) |
Jul
(160) |
Aug
(68) |
Sep
(104) |
Oct
(25) |
Nov
(39) |
Dec
(23) |
2005 |
Jan
(10) |
Feb
(45) |
Mar
(43) |
Apr
(19) |
May
(108) |
Jun
(31) |
Jul
(41) |
Aug
(23) |
Sep
(65) |
Oct
(58) |
Nov
(44) |
Dec
(54) |
2006 |
Jan
(96) |
Feb
(27) |
Mar
(69) |
Apr
(59) |
May
(67) |
Jun
(35) |
Jul
(13) |
Aug
(461) |
Sep
(160) |
Oct
(399) |
Nov
(32) |
Dec
(72) |
2007 |
Jan
(316) |
Feb
(305) |
Mar
(318) |
Apr
(54) |
May
(194) |
Jun
(173) |
Jul
(282) |
Aug
(91) |
Sep
(227) |
Oct
(365) |
Nov
(168) |
Dec
(18) |
2008 |
Jan
(71) |
Feb
(111) |
Mar
(155) |
Apr
(173) |
May
(70) |
Jun
(67) |
Jul
(55) |
Aug
(83) |
Sep
(32) |
Oct
(68) |
Nov
(80) |
Dec
(29) |
2009 |
Jan
(46) |
Feb
(18) |
Mar
(95) |
Apr
(76) |
May
(140) |
Jun
(98) |
Jul
(84) |
Aug
(123) |
Sep
(94) |
Oct
(131) |
Nov
(142) |
Dec
(125) |
2010 |
Jan
(128) |
Feb
(158) |
Mar
(172) |
Apr
(134) |
May
(94) |
Jun
(84) |
Jul
(32) |
Aug
(127) |
Sep
(167) |
Oct
(109) |
Nov
(69) |
Dec
(78) |
2011 |
Jan
(39) |
Feb
(58) |
Mar
(52) |
Apr
(47) |
May
(56) |
Jun
(76) |
Jul
(55) |
Aug
(54) |
Sep
(165) |
Oct
(255) |
Nov
(328) |
Dec
(263) |
2012 |
Jan
(82) |
Feb
(147) |
Mar
(400) |
Apr
(216) |
May
(209) |
Jun
(160) |
Jul
(86) |
Aug
(141) |
Sep
(156) |
Oct
(6) |
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
(2) |
2016 |
Jan
|
Feb
(2) |
Mar
(2) |
Apr
(1) |
May
(1) |
Jun
(2) |
Jul
(1) |
Aug
(1) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
2019 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2021 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
(4) |
Jun
(8) |
Jul
(2) |
Aug
(5) |
Sep
(9) |
Oct
|
Nov
|
Dec
|
From: <par...@us...> - 2012-05-21 13:03:12
|
Revision: 10473 http://octave.svn.sourceforge.net/octave/?rev=10473&view=rev Author: paramaniac Date: 2012-05-21 13:03:02 +0000 (Mon, 21 May 2012) Log Message: ----------- control-devel: work on identification user functions Modified Paths: -------------- trunk/octave-forge/extra/control-devel/devel/CDplayer.m trunk/octave-forge/extra/control-devel/devel/GlassFurnace.m trunk/octave-forge/extra/control-devel/devel/pH.m trunk/octave-forge/extra/control-devel/inst/__slicot_identification__.m Modified: trunk/octave-forge/extra/control-devel/devel/CDplayer.m =================================================================== --- trunk/octave-forge/extra/control-devel/devel/CDplayer.m 2012-05-21 09:45:39 UTC (rev 10472) +++ trunk/octave-forge/extra/control-devel/devel/CDplayer.m 2012-05-21 13:03:02 UTC (rev 10473) @@ -50,7 +50,7 @@ dat = iddata (Y, U) -[sys, x0] = ident (dat, 15, 8) % s=15, n=8 +[sys, x0] = moen4 (dat, 8) % s=15, n=8 [y, t] = lsim (sys, U, [], x0); Modified: trunk/octave-forge/extra/control-devel/devel/GlassFurnace.m =================================================================== --- trunk/octave-forge/extra/control-devel/devel/GlassFurnace.m 2012-05-21 09:45:39 UTC (rev 10472) +++ trunk/octave-forge/extra/control-devel/devel/GlassFurnace.m 2012-05-21 13:03:02 UTC (rev 10473) @@ -48,7 +48,7 @@ dat = iddata (Y, U) -[sys, x0] = ident (dat, 10, 5) % s=10, n=5 +[sys, x0] = moen4 (dat, 5) % s=10, n=5 [y, t] = lsim (sys, U, [], x0); Modified: trunk/octave-forge/extra/control-devel/devel/pH.m =================================================================== --- trunk/octave-forge/extra/control-devel/devel/pH.m 2012-05-21 09:45:39 UTC (rev 10472) +++ trunk/octave-forge/extra/control-devel/devel/pH.m 2012-05-21 13:03:02 UTC (rev 10473) @@ -51,7 +51,7 @@ dat = iddata (Y, U) -[sys, x0] = ident (dat, 15, 6) % s=15, n=6 +[sys, x0] = moen4 (dat, 6) % s=15, n=6 [y, t] = lsim (sys, U, [], x0); Modified: trunk/octave-forge/extra/control-devel/inst/__slicot_identification__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__slicot_identification__.m 2012-05-21 09:45:39 UTC (rev 10472) +++ trunk/octave-forge/extra/control-devel/inst/__slicot_identification__.m 2012-05-21 13:03:02 UTC (rev 10473) @@ -1,4 +1,4 @@ -function [sys, x0] = __slicot_identification__ (method, dat, s = [], n = []) +function [sys, x0] = __slicot_identification__ (method, dat, n = []) switch (method) case "moesp" @@ -15,14 +15,25 @@ error ("%s: first argument must be an 'iddata' dataset", method); endif + ## default arguments alg = 0; - conct = 1; - ctrl = 0; %1; + conct = 1; # no connection between experiments + ctrl = 1; # don't confirm order n rcond = 0.0; tol = -1.0; % 0; [ns, l, m, e] = size (dat); + s = min (2*n, n+10); # upper bound for n + nsmp = sum (ns); # total number of samples + nobr = fix ((nsmp+1)/(2*(m+l+1))); + if (e > 1) + nobr = min (nobr, fix (min (ns) / 2)); + endif + nobr = min (nobr, s) + +%{ + if (isempty (s) && isempty (n)) nsmp = ns(1); nobr = fix ((nsmp+1)/(2*(m+l+1))); @@ -50,6 +61,7 @@ ctrl = 1; ## TODO: specify n for IB01BD endif +%} [a, b, c, d, q, ry, s, k, x0] = slident (dat.y, dat.u, nobr, n, meth, alg, conct, ctrl, rcond, tol); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-05-21 09:45:50
|
Revision: 10472 http://octave.svn.sourceforge.net/octave/?rev=10472&view=rev Author: carandraug Date: 2012-05-21 09:45:39 +0000 (Mon, 21 May 2012) Log Message: ----------- linear-algebra: add FreeBSD to licenses because of nmf_pg Modified Paths: -------------- trunk/octave-forge/main/linear-algebra/DESCRIPTION Modified: trunk/octave-forge/main/linear-algebra/DESCRIPTION =================================================================== --- trunk/octave-forge/main/linear-algebra/DESCRIPTION 2012-05-21 07:13:05 UTC (rev 10471) +++ trunk/octave-forge/main/linear-algebra/DESCRIPTION 2012-05-21 09:45:39 UTC (rev 10472) @@ -8,5 +8,5 @@ Categories: Linear algebra Depends: octave (>= 3.2.3), general (>= 1.3.0) Autoload: no -License: GPLv3+, LGPLv3+ +License: GPLv3+, LGPLv3+, FreeBSD Url: http://octave.sf.net This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-05-21 07:13:16
|
Revision: 10471 http://octave.svn.sourceforge.net/octave/?rev=10471&view=rev Author: jpicarbajal Date: 2012-05-21 07:13:05 +0000 (Mon, 21 May 2012) Log Message: ----------- linear-algebra: Adding nonnegative matrix factorization and bumping version Modified Paths: -------------- trunk/octave-forge/main/linear-algebra/DESCRIPTION trunk/octave-forge/main/linear-algebra/INDEX trunk/octave-forge/main/linear-algebra/NEWS Added Paths: ----------- trunk/octave-forge/main/linear-algebra/inst/nmf_bpas.m trunk/octave-forge/main/linear-algebra/inst/nmf_pg.m Removed Paths: ------------- trunk/octave-forge/main/linear-algebra/devel/nmf_bpas.m trunk/octave-forge/main/linear-algebra/devel/nmf_pg.m Modified: trunk/octave-forge/main/linear-algebra/DESCRIPTION =================================================================== --- trunk/octave-forge/main/linear-algebra/DESCRIPTION 2012-05-20 16:04:12 UTC (rev 10470) +++ trunk/octave-forge/main/linear-algebra/DESCRIPTION 2012-05-21 07:13:05 UTC (rev 10471) @@ -1,6 +1,6 @@ Name: Linear-algebra -Version: 2.1.0 -Date: 2011-11-06 +Version: 2.2.0 +Date: 2012-21-05 Author: various authors Maintainer: Octave-Forge community <oct...@li...> Title: Linear algebra. Modified: trunk/octave-forge/main/linear-algebra/INDEX =================================================================== --- trunk/octave-forge/main/linear-algebra/INDEX 2012-05-20 16:04:12 UTC (rev 10470) +++ trunk/octave-forge/main/linear-algebra/INDEX 2012-05-21 07:13:05 UTC (rev 10471) @@ -12,6 +12,8 @@ thfm Matrix factorization gsvd + nmf_bpas + nmf_pg sparse >> Sparse matrix support Block sparse matrices @@ -69,7 +71,7 @@ @kronprod/transpose @kronprod/uminus @kronprod/uplus - + Circulant matrices circulant_make_matrix circulant_matrix_vector_product Modified: trunk/octave-forge/main/linear-algebra/NEWS =================================================================== --- trunk/octave-forge/main/linear-algebra/NEWS 2012-05-20 16:04:12 UTC (rev 10470) +++ trunk/octave-forge/main/linear-algebra/NEWS 2012-05-21 07:13:05 UTC (rev 10471) @@ -5,6 +5,7 @@ circulant_eig circulant_inv circulant_make_matrix circulant_matrix_vector_product + nmf_pg nmf_bpas ** Package is now dependent on general (>= 1.3.0) Deleted: trunk/octave-forge/main/linear-algebra/devel/nmf_bpas.m =================================================================== --- trunk/octave-forge/main/linear-algebra/devel/nmf_bpas.m 2012-05-20 16:04:12 UTC (rev 10470) +++ trunk/octave-forge/main/linear-algebra/devel/nmf_bpas.m 2012-05-21 07:13:05 UTC (rev 10471) @@ -1,711 +0,0 @@ -## Copyright (c) 2012 by Jingu Kim and Haesun Park <ji...@cc...> -## -## This program is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## any later version. -## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {[@var{W}, @var{H}, @var{iter}, @var{HIS}] = } nmf_bpas (@var{A}, @var{k}) -## Nonnegative Matrix Factorization by Alternating Nonnegativity Constrained Least Squares -## using Block Principal Pivoting/Active Set method. -## -## This function solves one the following problems: given @var{A} and @var{k}, find @var{W} and @var{H} such that -## (1) minimize 1/2 * || @var{A}-@var{W}@var{H} ||_F^2 -## (2) minimize 1/2 * ( || @var{A}-@var{W}@var{H} ||_F^2 + alpha * || @var{W} ||_F^2 + beta * || @var{H} ||_F^2 ) -## (3) minimize 1/2 * ( || @var{A}-@var{W}@var{H} ||_F^2 + alpha * || @var{W} ||_F^2 + beta * (sum_(i=1)^n || @var{H}(:,i) ||_1^2 ) ) -## where @var{W}>=0 and @var{H}>=0 elementwise. -## The input arguments are @var{A} : Input data matrix (m x n) and @var{k} : Target low-rank. -## -## -## @strong{Optional Inputs} -## @table @samp -## @item Type : Default is 'regularized', which is recommended for quick application testing unless 'sparse' or 'plain' is explicitly needed. If sparsity is needed for 'W' factor, then apply this function for the transpose of 'A' with formulation (3). Then, exchange 'W' and 'H' and obtain the transpose of them. Imposing sparsity for both factors is not recommended and thus not included in this software. -## @table @asis -## @item 'plain' to use formulation (1) -## @item 'regularized' to use formulation (2) -## @item 'sparse' to use formulation (3) -## @end table -## -## @item NNLSSolver : Default is 'bp', which is in general faster. -## @table @asis -## item 'bp' to use the algorithm in [1] -## item 'as' to use the algorithm in [2] -## @end table -## -## @item Alpha : Parameter alpha in the formulation (2) or (3). Default is the average of all elements in A. No good justfication for this default value, and you might want to try other values. -## @item Beta : Parameter beta in the formulation (2) or (3). -## Default is the average of all elements in A. No good justfication for this default value, and you might want to try other values. -## @item MaxIter : Maximum number of iterations. Default is 100. -## @item MinIter : Minimum number of iterations. Default is 20. -## @item MaxTime : Maximum amount of time in seconds. Default is 100,000. -## @item Winit : (m x k) initial value for W. -## @item Hinit : (k x n) initial value for H. -## @item Tol : Stopping tolerance. Default is 1e-3. If you want to obtain a more accurate solution, decrease TOL and increase MAX_ITER at the same time. -## @item Verbose : -## @table @asis -## @item 0 (default) - No debugging information is collected.@* -## @item 1 (debugging purpose) - History of computation is returned by 'HIS' variable. -## @item 2 (debugging purpose) - History of computation is additionally printed on screen. -## @end table -## @end table -## -## @strong{Outputs} -## @table @samp -## @item W : Obtained basis matrix (m x k) -## @item H : Obtained coefficients matrix (k x n) -## @item iter : Number of iterations -## @item HIS : (debugging purpose) History of computation -## @end table -## -## Usage Examples: -## @example -## nmf(A,10) -## nmf(A,20,'verbose',2) -## nmf(A,30,'verbose',2,'nnls_solver','as') -## nmf(A,5,'verbose',2,'type','sparse') -## nmf(A,60,'verbose',1,'type','plain','w_init',rand(m,k)) -## nmf(A,70,'verbose',2,'type','sparse','nnls_solver','bp','alpha',1.1,'beta',1.3) -## @end example -## -## References: -## [1] For using this software, please cite:@* -## Jingu Kim and Haesun Park, Toward Faster Nonnegative Matrix Factorization: A New Algorithm and Comparisons,@* -## In Proceedings of the 2008 Eighth IEEE International Conference on Data Mining (ICDM'08), 353-362, 2008@* -## [2] If you use 'nnls_solver'='as' (see below), please cite:@* -## Hyunsoo Kim and Haesun Park, Nonnegative Matrix Factorization Based @* -## on Alternating Nonnegativity Constrained Least Squares and Active Set Method, @* -## SIAM Journal on Matrix Analysis and Applications, 2008, 30, 713-730 -## -## Check original code at @url{http://www.cc.gatech.edu/~jingu} -## -## @seealso{nmf_pg} -## @end deftypefn - -## 2012 - Modified and adapted to Octave 3.6.1 by -## Juan Pablo Carbajal <car...@if...> - -# TODO -# - Format code. -# - Vectorize loops. - -function [W, H, iter, HIS] = nmf_bpas (A, k , varargin) - page_screen_output (0, "local"); - - [m,n] = size(A); - ST_RULE = 1; - - # --- Parse arguments --- # - parser = inputParser (); - parser.FunctionName = "nmf_bpas"; - parser = addParamValue (parser,'Winit', rand(m,k), @ismatrix); - parser = addParamValue (parser,'Hinit', rand(k,n), @ismatrix); - parser = addParamValue (parser,'Tol', 1e-3, @(x)x>0); - parser = addParamValue (parser,'Alpha', mean (A(:)), @(x)x>=0); - parser = addParamValue (parser,'Beta', mean (A(:)), @(x)x>=0); - parser = addParamValue (parser,'MaxIter', 100, @(x)x>0); - parser = addParamValue (parser,'MaxTime', 1e3, @(x)x>0); - parser = addParamValue (parser,'Verbose', false); - - val_type = @(x,c) ischar (x) && any (strcmpi (x,c)); - parser = addParamValue (parser,'Type', 'regularized', ... - @(x)val_type (x,{'regularized', 'sparse','plain'})); - parser = addParamValue (parser,'NNLSSolver', 'bp', ... - @(x)val_type (x,{'bp', 'as'})); - - parser = parse(parser,varargin{:}); - - % Default configuration - par.m = m; - par.n = n; - par.type = parser.Results.Type; - par.nnls_solver = parser.Results.NNLSSolver; - par.alpha = parser.Results.Alpha; - par.beta = parser.Results.Beta; - par.max_iter = parser.Results.MaxIter; - par.min_iter = 20; - par.max_time = parser.Results.MaxTime; - par.tol = parser.Results.Tol; - par.verbose = parser.Results.Verbose; - W = parser.Results.Winit; - H = parser.Results.Hinit; - - # TODO check if can be removed - argAlpha = par.alpha; - argBeta = par.beta; - - clear parser val_type - -### PARSING TYPE -# TODO add callbacks here to use during main loop. See [1] - % for regularized/sparse case - salphaI = sqrt (par.alpha) * eye (k); - zerokm = zeros (k,m); - - if strcmpi (par.type, 'regularized') - sbetaI = sqrt (par.beta) * eye (k); - zerokn = zeros (k,n); - - elseif strcmpi (par.type, 'sparse') - sbetaE = sqrt (par.beta) * ones (1,k); - betaI = par.beta * ones (k,k); - zero1n = zeros (1,n); - - end -### - -# Verbosity - display(par); -### Done till here Sun Mar 25 19:00:26 2012 - - HIS = 0; - if par.verbose % collect information for analysis/debugging - [gradW,gradH] = getGradient(A,W,H,par.type,par.alpha,par.beta); - initGrNormW = norm(gradW,'fro'); - initGrNormH = norm(gradH,'fro'); - initNorm = norm(A,'fro'); - numSC = 3; - initSCs = zeros(numSC,1); - for j=1:numSC - initSCs(j) = getInitCriterion(j,A,W,H,par.type,par.alpha,par.beta,gradW,gradH); - end -%---(1)------(2)--------(3)--------(4)--------(5)---------(6)----------(7)------(8)-----(9)-------(10)--------------(11)------- -% iter # | elapsed | totalTime | subIterW | subIterH | rel. obj.(%) | NM_GRAD | GRAD | DELTA | W density (%) | H density (%) -%------------------------------------------------------------------------------------------------------------------------------ - HIS = zeros(1,11); - HIS(1,[1:5])=0; - ver.initGrNormW = initGrNormW; - ver.initGrNormH = initGrNormH; - ver.initNorm = initNorm; HIS(1,6) = ver.initNorm; - ver.SC1 = initSCs(1); HIS(1,7) = ver.SC1; - ver.SC2 = initSCs(2); HIS(1,8) = ver.SC2; - ver.SC3 = initSCs(3); HIS(1,9) = ver.SC3; - ver.W_density = length(find(W>0))/(m*k); HIS(1,10) = ver.W_density; - ver.H_density = length(find(H>0))/(n*k); HIS(1,11) = ver.H_density; - if par.verbose == 2 - disp (ver); - end - tPrev = cputime; - end - - tStart = cputime; - tTotal = 0; - initSC = getInitCriterion(ST_RULE,A,W,H,par.type,par.alpha,par.beta); - SCconv = 0; - SC_COUNT = 3; - -#TODO: [1] Replace with callbacks avoid switching each time - for iter=1:par.max_iter - switch par.type - case 'plain' - [H,gradHX,subIterH] = nnlsm(W,A,H,par.nnls_solver); - [W,gradW,subIterW] = nnlsm(H',A',W',par.nnls_solver);, W=W';, gradW=gradW'; - gradH = (W'*W)*H - W'*A; - case 'regularized' - [H,gradHX,subIterH] = nnlsm([W;sbetaI],[A;zerokn],H,par.nnls_solver); - [W,gradW,subIterW] = nnlsm([H';salphaI],[A';zerokm],W',par.nnls_solver);, W=W';, gradW=gradW'; - gradH = (W'*W)*H - W'*A + par.beta*H; - case 'sparse' - [H,gradHX,subIterH] = nnlsm([W;sbetaE],[A;zero1n],H,par.nnls_solver); - [W,gradW,subIterW] = nnlsm([H';salphaI],[A';zerokm],W',par.nnls_solver);, W=W';, gradW=gradW'; - gradH = (W'*W)*H - W'*A + betaI*H; - end - - if par.verbose % collect information for analysis/debugging - elapsed = cputime-tPrev; - tTotal = tTotal + elapsed; - ver = []; - idx = iter+1; -%---(1)------(2)--------(3)--------(4)--------(5)---------(6)----------(7)------(8)-----(9)-------(10)--------------(11)------- -% iter # | elapsed | totalTime | subIterW | subIterH | rel. obj.(%) | NM_GRAD | GRAD | DELTA | W density (%) | H density (%) -%------------------------------------------------------------------------------------------------------------------------------ - ver.iter = iter; HIS(idx,1)=iter; - ver.elapsed = elapsed; HIS(idx,2)=elapsed; - ver.tTotal = tTotal; HIS(idx,3)=tTotal; - ver.subIterW = subIterW; HIS(idx,4)=subIterW; - ver.subIterH = subIterH; HIS(idx,5)=subIterH; - ver.relError = norm(A-W*H,'fro')/initNorm; HIS(idx,6)=ver.relError; - ver.SC1 = getStopCriterion(1,A,W,H,par.type,par.alpha,par.beta,gradW,gradH)/initSCs(1); HIS(idx,7)=ver.SC1; - ver.SC2 = getStopCriterion(2,A,W,H,par.type,par.alpha,par.beta,gradW,gradH)/initSCs(2); HIS(idx,8)=ver.SC2; - ver.SC3 = getStopCriterion(3,A,W,H,par.type,par.alpha,par.beta,gradW,gradH)/initSCs(3); HIS(idx,9)=ver.SC3; - ver.W_density = length(find(W>0))/(m*k); HIS(idx,10)=ver.W_density; - ver.H_density = length(find(H>0))/(n*k); HIS(idx,11)=ver.H_density; - if par.verbose == 2, display(ver);, end - tPrev = cputime; - end - - if (iter > par.min_iter) - SC = getStopCriterion(ST_RULE,A,W,H,par.type,par.alpha,par.beta,gradW,gradH); - if (par.verbose && (tTotal > par.max_time)) || (~par.verbose && ((cputime-tStart)>par.max_time)) - break; - elseif (SC/initSC <= par.tol) - SCconv = SCconv + 1; - if (SCconv >= SC_COUNT) - break; - end - else - SCconv = 0; - end - end - end - [m,n]=size(A); - norm2=sqrt(sum(W.^2,1)); - toNormalize = norm2>0; - W(:,toNormalize) = W(:,toNormalize)./repmat(norm2(toNormalize),m,1); - H(toNormalize,:) = H(toNormalize,:).*repmat(norm2(toNormalize)',1,n); - - final.iterations = iter; - if par.verbose - final.elapsed_total = tTotal; - else - final.elapsed_total = cputime-tStart; - end - final.relative_error = norm(A-W*H,'fro')/norm(A,'fro'); - final.W_density = length(find(W>0))/(m*k); - final.H_density = length(find(H>0))/(n*k); - display(final); - -endfunction - -%------------------------------------------------------------------------------------------------------------------------ -% Utility Functions -%------------------------------------------------------------------------------- -function retVal = getInitCriterion(stopRule,A,W,H,type,alpha,beta,gradW,gradH) -% STOPPING_RULE : 1 - Normalized proj. gradient -% 2 - Proj. gradient -% 3 - Delta by H. Kim -% 0 - None (want to stop by MAX_ITER or MAX_TIME) - if nargin~=9 - [gradW,gradH] = getGradient(A,W,H,type,alpha,beta); - end - [m,k]=size(W);, [k,n]=size(H);, numAll=(m*k)+(k*n); - switch stopRule - case 1 - retVal = norm([gradW; gradH'],'fro')/numAll; - case 2 - retVal = norm([gradW; gradH'],'fro'); - case 3 - retVal = getStopCriterion(3,A,W,H,type,alpha,beta,gradW,gradH); - case 0 - retVal = 1; - end - -endfunction -%------------------------------------------------------------------------------- -function retVal = getStopCriterion(stopRule,A,W,H,type,alpha,beta,gradW,gradH) -% STOPPING_RULE : 1 - Normalized proj. gradient -% 2 - Proj. gradient -% 3 - Delta by H. Kim -% 0 - None (want to stop by MAX_ITER or MAX_TIME) - if nargin~=9 - [gradW,gradH] = getGradient(A,W,H,type,alpha,beta); - end - - switch stopRule - case 1 - pGradW = gradW(gradW<0|W>0); - pGradH = gradH(gradH<0|H>0); - pGrad = [gradW(gradW<0|W>0); gradH(gradH<0|H>0)]; - pGradNorm = norm(pGrad); - retVal = pGradNorm/length(pGrad); - case 2 - pGradW = gradW(gradW<0|W>0); - pGradH = gradH(gradH<0|H>0); - pGrad = [gradW(gradW<0|W>0); gradH(gradH<0|H>0)]; - retVal = norm(pGrad); - case 3 - resmat=min(H,gradH); resvec=resmat(:); - resmat=min(W,gradW); resvec=[resvec; resmat(:)]; - deltao=norm(resvec,1); %L1-norm - num_notconv=length(find(abs(resvec)>0)); - retVal=deltao/num_notconv; - case 0 - retVal = 1e100; - end - -endfunction -%------------------------------------------------------------------------------- -function [gradW,gradH] = getGradient(A,W,H,type,alpha,beta) - switch type - case 'plain' - gradW = W*(H*H') - A*H'; - gradH = (W'*W)*H - W'*A; - case 'regularized' - gradW = W*(H*H') - A*H' + alpha*W; - gradH = (W'*W)*H - W'*A + beta*H; - case 'sparse' - k=size(W,2); - betaI = beta*ones(k,k); - gradW = W*(H*H') - A*H' + alpha*W; - gradH = (W'*W)*H - W'*A + betaI*H; - end - -endfunction - -%------------------------------------------------------------------------------------------------------------------------ -function [X,grad,iter] = nnlsm(A,B,init,solver) - switch solver - case 'bp' - [X,grad,iter] = nnlsm_blockpivot(A,B,0,init); - case 'as' - [X,grad,iter] = nnlsm_activeset(A,B,1,0,init); - end - -endfunction -%------------------------------------------------------------------------------------------------------------------------ -function [ X,Y,iter,success ] = nnlsm_activeset( A, B, overwrite, isInputProd, init) -% Nonnegativity Constrained Least Squares with Multiple Righthand Sides -% using Active Set method -% -% This software solves the following problem: given A and B, find X such that -% minimize || AX-B ||_F^2 where X>=0 elementwise. -% -% Reference: -% Charles L. Lawson and Richard J. Hanson, Solving Least Squares Problems, -% Society for Industrial and Applied Mathematics, 1995 -% M. H. Van Benthem and M. R. Keenan, -% Fast Algorithm for the Solution of Large-scale Non-negativity-constrained Least Squares Problems, -% J. Chemometrics 2004; 18: 441-450 -% -% Written by Jingu Kim (ji...@cc...) -% School of Computational Science and Engineering, -% Georgia Institute of Technology -% -% Last updated Feb-20-2010 -% -% <Inputs> -% A : input matrix (m x n) (by default), or A'*A (n x n) if isInputProd==1 -% B : input matrix (m x k) (by default), or A'*B (n x k) if isInputProd==1 -% overwrite : (optional, default:0) if turned on, unconstrained least squares solution is computed in the beginning -% isInputProd : (optional, default:0) if turned on, use (A'*A,A'*B) as input instead of (A,B) -% init : (optional) initial value for X -% <Outputs> -% X : the solution (n x k) -% Y : A'*A*X - A'*B where X is the solution (n x k) -% iter : number of iterations -% success : 1 for success, 0 for failure. -% Failure could only happen on a numericall very ill-conditioned problem. - - if nargin<3, overwrite=0;, end - if nargin<4, isInputProd=0;, end - - if isInputProd - AtA=A;,AtB=B; - else - AtA=A'*A;, AtB=A'*B; - end - - [n,k]=size(AtB); - MAX_ITER = n*5; - % set initial feasible solution - if overwrite - [X,iter] = solveNormalEqComb(AtA,AtB); - PassSet = (X > 0); - NotOptSet = any(X<0); - else - if nargin<5 - X = zeros(n,k); - PassSet = false(n,k); - NotOptSet = true(1,k); - else - X = init; - PassSet = (X > 0); - NotOptSet = any(X<0); - end - iter = 0; - end - - Y = zeros(n,k); - Y(:,~NotOptSet)=AtA*X(:,~NotOptSet) - AtB(:,~NotOptSet); - NotOptCols = find(NotOptSet); - - bigIter = 0;, success=1; - while(~isempty(NotOptCols)) - bigIter = bigIter+1; - if ((MAX_ITER >0) && (bigIter > MAX_ITER)) % set max_iter for ill-conditioned (numerically unstable) case - success = 0;, bigIter, break - end - - % find unconstrained LS solution for the passive set - Z = zeros(n,length(NotOptCols)); - [ Z,subiter ] = solveNormalEqComb(AtA,AtB(:,NotOptCols),PassSet(:,NotOptCols)); - iter = iter + subiter; - %Z(abs(Z)<1e-12) = 0; % One can uncomment this line for numerical stability. - InfeaSubSet = Z < 0; - InfeaSubCols = find(any(InfeaSubSet)); - FeaSubCols = find(all(~InfeaSubSet)); - - if ~isempty(InfeaSubCols) % for infeasible cols - ZInfea = Z(:,InfeaSubCols); - InfeaCols = NotOptCols(InfeaSubCols); - Alpha = zeros(n,length(InfeaSubCols));, Alpha(:,:) = Inf; - InfeaSubSet(:,InfeaSubCols); - [i,j] = find(InfeaSubSet(:,InfeaSubCols)); - InfeaSubIx = sub2ind(size(Alpha),i,j); - if length(InfeaCols) == 1 - InfeaIx = sub2ind([n,k],i,InfeaCols * ones(length(j),1)); - else - InfeaIx = sub2ind([n,k],i,InfeaCols(j)'); - end - Alpha(InfeaSubIx) = X(InfeaIx)./(X(InfeaIx)-ZInfea(InfeaSubIx)); - - [minVal,minIx] = min(Alpha); - Alpha(:,:) = repmat(minVal,n,1); - X(:,InfeaCols) = X(:,InfeaCols)+Alpha.*(ZInfea-X(:,InfeaCols)); - IxToActive = sub2ind([n,k],minIx,InfeaCols); - X(IxToActive) = 0; - PassSet(IxToActive) = false; - end - if ~isempty(FeaSubCols) % for feasible cols - FeaCols = NotOptCols(FeaSubCols); - X(:,FeaCols) = Z(:,FeaSubCols); - Y(:,FeaCols) = AtA * X(:,FeaCols) - AtB(:,FeaCols); - %Y( abs(Y)<1e-12 ) = 0; % One can uncomment this line for numerical stability. - - NotOptSubSet = (Y(:,FeaCols) < 0) & ~PassSet(:,FeaCols); - NewOptCols = FeaCols(all(~NotOptSubSet)); - UpdateNotOptCols = FeaCols(any(NotOptSubSet)); - if ~isempty(UpdateNotOptCols) - [minVal,minIx] = min(Y(:,UpdateNotOptCols).*~PassSet(:,UpdateNotOptCols)); - PassSet(sub2ind([n,k],minIx,UpdateNotOptCols)) = true; - end - NotOptSet(NewOptCols) = false; - NotOptCols = find(NotOptSet); - end - end - -endfunction -%------------------------------------------------------------------------------------------------------------------------ -function [ X,Y,iter,success ] = nnlsm_blockpivot( A, B, isInputProd, init ) -% Nonnegativity Constrained Least Squares with Multiple Righthand Sides -% using Block Principal Pivoting method -% -% This software solves the following problem: given A and B, find X such that -% minimize || AX-B ||_F^2 where X>=0 elementwise. -% -% Reference: -% Jingu Kim and Haesun Park, Toward Faster Nonnegative Matrix Factorization: A New Algorithm and Comparisons, -% In Proceedings of the 2008 Eighth IEEE International Conference on Data Mining (ICDM'08), 353-362, 2008 -% -% Written by Jingu Kim (ji...@cc...) -% Copyright 2008-2009 by Jingu Kim and Haesun Park, -% School of Computational Science and Engineering, -% Georgia Institute of Technology -% -% Check updated code at http://www.cc.gatech.edu/~jingu -% Please send bug reports, comments, or questions to Jingu Kim. -% This code comes with no guarantee or warranty of any kind. Note that this algorithm assumes that the -% input matrix A has full column rank. -% -% Last modified Feb-20-2009 -% -% <Inputs> -% A : input matrix (m x n) (by default), or A'*A (n x n) if isInputProd==1 -% B : input matrix (m x k) (by default), or A'*B (n x k) if isInputProd==1 -% isInputProd : (optional, default:0) if turned on, use (A'*A,A'*B) as input instead of (A,B) -% init : (optional) initial value for X -% <Outputs> -% X : the solution (n x k) -% Y : A'*A*X - A'*B where X is the solution (n x k) -% iter : number of iterations -% success : 1 for success, 0 for failure. -% Failure could only happen on a numericall very ill-conditioned problem. - - if nargin<3, isInputProd=0;, end - if isInputProd - AtA = A;, AtB = B; - else - AtA = A'*A;, AtB = A'*B; - end - - [n,k]=size(AtB); - MAX_ITER = n*5; - % set initial feasible solution - X = zeros(n,k); - if nargin<4 - Y = - AtB; - PassiveSet = false(n,k); - iter = 0; - else - PassiveSet = (init > 0); - [ X,iter ] = solveNormalEqComb(AtA,AtB,PassiveSet); - Y = AtA * X - AtB; - end - % parameters - pbar = 3; - P = zeros(1,k);, P(:) = pbar; - Ninf = zeros(1,k);, Ninf(:) = n+1; - iter = 0; - - NonOptSet = (Y < 0) & ~PassiveSet; - InfeaSet = (X < 0) & PassiveSet; - NotGood = sum(NonOptSet)+sum(InfeaSet); - NotOptCols = NotGood > 0; - - bigIter = 0;, success=1; - while(~isempty(find(NotOptCols))) - bigIter = bigIter+1; - if ((MAX_ITER >0) && (bigIter > MAX_ITER)) % set max_iter for ill-conditioned (numerically unstable) case - success = 0;, break - end - - Cols1 = NotOptCols & (NotGood < Ninf); - Cols2 = NotOptCols & (NotGood >= Ninf) & (P >= 1); - Cols3Ix = find(NotOptCols & ~Cols1 & ~Cols2); - if ~isempty(find(Cols1)) - P(Cols1) = pbar;,Ninf(Cols1) = NotGood(Cols1); - PassiveSet(NonOptSet & repmat(Cols1,n,1)) = true; - PassiveSet(InfeaSet & repmat(Cols1,n,1)) = false; - end - if ~isempty(find(Cols2)) - P(Cols2) = P(Cols2)-1; - PassiveSet(NonOptSet & repmat(Cols2,n,1)) = true; - PassiveSet(InfeaSet & repmat(Cols2,n,1)) = false; - end - if ~isempty(Cols3Ix) - for i=1:length(Cols3Ix) - Ix = Cols3Ix(i); - toChange = max(find( NonOptSet(:,Ix)|InfeaSet(:,Ix) )); - if PassiveSet(toChange,Ix) - PassiveSet(toChange,Ix)=false; - else - PassiveSet(toChange,Ix)=true; - end - end - end - NotOptMask = repmat(NotOptCols,n,1); - [ X(:,NotOptCols),subiter ] = solveNormalEqComb(AtA,AtB(:,NotOptCols),PassiveSet(:,NotOptCols)); - iter = iter + subiter; - X(abs(X)<1e-12) = 0; % for numerical stability - Y(:,NotOptCols) = AtA * X(:,NotOptCols) - AtB(:,NotOptCols); - Y(abs(Y)<1e-12) = 0; % for numerical stability - - % check optimality - NonOptSet = NotOptMask & (Y < 0) & ~PassiveSet; - InfeaSet = NotOptMask & (X < 0) & PassiveSet; - NotGood = sum(NonOptSet)+sum(InfeaSet); - NotOptCols = NotGood > 0; - end -endfunction -%------------------------------------------------------------------------------------------------------------------------ -function [ Z,iter ] = solveNormalEqComb( AtA,AtB,PassSet ) -% Solve normal equations using combinatorial grouping. -% Although this function was originally adopted from the code of -% "M. H. Van Benthem and M. R. Keenan, J. Chemometrics 2004; 18: 441-450", -% important modifications were made to fix bugs. -% -% Modified by Jingu Kim (ji...@cc...) -% School of Computational Science and Engineering, -% Georgia Institute of Technology -% -% Last updated Aug-12-2009 - - iter = 0; - if (nargin ==2) || isempty(PassSet) || all(PassSet(:)) - Z = AtA\AtB; - iter = iter + 1; - else - Z = zeros(size(AtB)); - [n,k1] = size(PassSet); - - ## Fixed on Aug-12-2009 - if k1==1 - Z(PassSet)=AtA(PassSet,PassSet)\AtB(PassSet); - else - ## Fixed on Aug-12-2009 - % The following bug was identified by investigating a bug report by Hanseung Lee. - [sortedPassSet,sortIx] = sortrows(PassSet'); - breaks = any(diff(sortedPassSet)'); - breakIx = [0 find(breaks) k1]; - % codedPassSet = 2.^(n-1:-1:0)*PassSet; - % [sortedPassSet,sortIx] = sort(codedPassSet); - % breaks = diff(sortedPassSet); - % breakIx = [0 find(breaks) k1]; - - for k=1:length(breakIx)-1 - cols = sortIx(breakIx(k)+1:breakIx(k+1)); - vars = PassSet(:,sortIx(breakIx(k)+1)); - Z(vars,cols) = AtA(vars,vars)\AtB(vars,cols); - iter = iter + 1; - end - end - end -endfunction - -%!shared m, n, k, A -%! m = 30; -%! n = 20; -%! k = 10; -%! A = rand(m,n); - -%!test -%! [W,H,iter,HIS]=nmf_bpas(A,k); - -%!test -%! [W,H,iter,HIS]=nmf_bpas(A,k,'verbose',2); - -%!test -%! [W,H,iter,HIS]=nmf_bpas(A,k,'verbose',1,'nnls_solver','as'); - -%!test -%! [W,H,iter,HIS]=nmf_bpas(A,k,'verbose',1,'type','sparse'); - -%!test -%! [W,H,iter,HIS]=nmf_bpas(A,k,'verbose',1,'type','sparse','nnls_solver','bp','alpha',1.1,'beta',1.3); - -%!test -%! [W,H,iter,HIS]=nmf_bpas(A,k,'verbose',2,'type','plain','w_init',rand(m,k)); - -%!demo -%! m = 300; -%! n = 200; -%! k = 10; -%! -%! W_org = rand(m,k);, W_org(rand(m,k)>0.5)=0; -%! H_org = rand(k,n);, H_org(rand(k,n)>0.5)=0; -%! -%! % normalize W, since 'nmf' normalizes W before return -%! norm2=sqrt(sum(W_org.^2,1)); -%! toNormalize = norm2>0; -%! W_org(:,toNormalize) = W_org(:,toNormalize)./repmat(norm2(toNormalize),m,1); -%! -%! A = W_org * H_org; -%! -%! [W,H,iter,HIS]=nmf_bpas (A,k,'type','plain','tol',1e-4); -%! -%! % -------------------- column reordering before computing difference -%! reorder = zeros(k,1); -%! selected = zeros(k,1); -%! for i=1:k -%! for j=1:k -%! if ~selected(j), break, end -%! end -%! minIx = j; -%! -%! for j=minIx+1:k -%! if ~selected(j) -%! d1 = norm(W(:,i)-W_org(:,minIx)); -%! d2 = norm(W(:,i)-W_org(:,j)); -%! if (d2<d1) -%! minIx = j; -%! end -%! end -%! end -%! reorder(i) = minIx; -%! selected(minIx) = 1; -%! end -%! -%! W_org = W_org(:,reorder); -%! H_org = H_org(reorder,:); -%! % --------------------------------------------------------------------- -%! -%! recovery_error_W = norm(W_org-W)/norm(W_org) -%! recovery_error_H = norm(H_org-H)/norm(H_org) Deleted: trunk/octave-forge/main/linear-algebra/devel/nmf_pg.m =================================================================== --- trunk/octave-forge/main/linear-algebra/devel/nmf_pg.m 2012-05-20 16:04:12 UTC (rev 10470) +++ trunk/octave-forge/main/linear-algebra/devel/nmf_pg.m 2012-05-21 07:13:05 UTC (rev 10471) @@ -1,297 +0,0 @@ -## Copyright (C) 2005-2006 Chih-Jen Lin <cj...@cs...> -## All rights reserved. -## -## Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are met: -## -## 1 Redistributions of source code must retain the above copyright notice, -## this list of conditions and the following disclaimer. -## 2 Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in the -## documentation and/or other materials provided with the distribution. -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ''AS IS'' -## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -## ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR -## ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -## DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -## SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -## CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -## -## The views and conclusions contained in the software and documentation are -## those of the authors and should not be interpreted as representing official -## policies, either expressed or implied, of the copyright holders. - -## -*- texinfo -*- -## @deftypefn {Function File} {[@var{W}, @var{H}] =} nmf_pg (@var{V}, @var{Winit}, @ -## @var{Hinit}, @var{tol}, @var{timelimit}, @var{maxiter}) -## -## Non-negative matrix factorization by alternative non-negative least squares -## using projected gradients. -## -## The matrix @var{V} is factorized into two possitive matrices @var{W} and -## @var{H} such that @code{V = W*H + U}. Where @var{U} is a matrix of residuals -## that can be negative or positive. When the matrix @var{V} is positive the order -## of the elements in @var{U} is bounded by the optional named argument @var{tol} -## (default value @code{1e-9}). -## -## The factorization is not unique and depends on the inital guess for the matrices -## @var{W} and @var{H}. You can pass this initalizations using the optional -## named arguments @var{Winit} and @var{Hinit}. -## -## timelimit, maxiter: limit of time and iterations -## -## Examples: -## -## @example -## A = rand(10,5); -## [W H] = nmf_pg(A,tol=1e-3); -## U = W*H -A; -## disp(max(abs(U))); -## @end example -## -## @end deftypefn - -## 2012 - Modified and adapted to Octave 3.6.1 by -## Juan Pablo Carbajal <car...@if...> - -function [W, H] = nmf_pg (V, varargin) - -# JuanPi Fri 16 Mar 2012 10:49:11 AM CET -# TODO: -# - finish docstring -# - avoid multiple transpositions - - # --- Parse arguments --- # - parser = inputParser (); - parser.FunctionName = "nmf_pg"; - parser = addParamValue (parser,'Winit', [], @ismatrix); - parser = addParamValue (parser,'Hinit', [], @ismatrix); - parser = addParamValue (parser,'Tol', 1e-6, @(x)x>0); - parser = addParamValue (parser,'TimeLimit', 10, @(x)x>0); - parser = addParamValue (parser,'MaxIter', 100, @(x)x>0); - parser = addParamValue (parser,'MaxSubIter', 1e3, @(x)x>0); - parser = addParamValue (parser,'Verbose', true); - parser = parse(parser,varargin{:}); - - Winit = parser.Results.Winit; - Hinit = parser.Results.Hinit; - tol = parser.Results.Tol; - timelimit = parser.Results.TimeLimit; - maxiter = parser.Results.MaxIter; - maxsubiter = parser.Results.MaxSubIter; - verbose = parser.Results.Verbose; - - clear parser - # ------ # - - # --- Initialize matrices --- # - [r c] = size (V); - Hgiven = !isempty (Hinit); - Wgiven = !isempty (Winit); - if Wgiven && !Hgiven - - W = Winit; - H = ones (size (W,2),c); - - elseif !Wgiven && Hgiven - - H = Hinit; - W = ones (r, size(H,2)); - - elseif !Wgiven && !Hgiven - - if r == c - W = ones (r) - H = W - else - W = ones (r); - H = ones (r,c); - end - - else - - W = Winit; - H = Hinit; - - end - [Hr,Hc] = size(H); - [Wr,Wc] = size(W); - - # start tracking time - initt = cputime (); - - gradW = W*(H*H') - V*H'; - gradH = (W'*W)*H - W'*V; - - initgrad = norm([gradW; gradH'],'fro'); - - # Tolerances for matrices - tolW = max(0.001,tol)*initgrad; - tolH = tolW; - - # ------ # - - # --- Main Loop --- # - if verbose - fprintf ('--- Factorizing %d-by-%d matrix into %d-by-%d times %d-by-%d\n',... - r,c,Wr,Wc,Hr,Hc); - fprintf ("Initial gradient norm = %f\n", initgrad); - fflush (stdout); - text_waitbar(0,'Please wait ...'); - end - - for iter = 1:maxiter - - # stopping condition - projnorm = norm ( [ gradW(gradW<0 | W>0); gradH(gradH<0 | H>0) ] ); - stop_cond = [projnorm < tol*initgrad , cputime-initt > timelimit]; - if any (stop_cond) - if stop_cond(2) - warning('mnf_pg:MaxIter',["Time limit exceeded.\n" ... - "Could be solved increasing TimeLimit.\n"]); - end - break - end - - - # FIXME: avoid multiple transpositions - [W, gradW, iterW] = nlssubprob(V', H', W', tolW, maxsubiter, verbose); - W = W'; - gradW = gradW'; - - if iterW == 1, - tolW = 0.1 * tolW; - end - - [H, gradH, iterH] = nlssubprob(V, W, H, tolH, maxsubiter, verbose); - if iterH == 1, - tolH = 0.1 * tolH; - end - - if (iterW == 1 && iterH == 1 && tolH + tolW < tol*initgrad), - warning ('nmf_pg:InvalidArgument','Failed to move'); - break - end - - if verbose - text_waitbar (iter/maxiter); - end - end - - if iter == maxiter - warning('mnf_pg:MaxIter',["Reached maximum iterations in main loop.\n" ... - "Could be solved increasing MaxIter.\n"]); - end - - if verbose - fprintf ('\nIterations = %d\nFinal proj-grad norm = %f\n', iter, projnorm); - fflush (stdout); - end -endfunction - -function [H, grad,iter] = nlssubprob(V,W,Hinit,tol,maxiter,verbose) -% H, grad: output solution and gradient -% iter: #iterations used -% V, W: constant matrices -% Hinit: initial solution -% tol: stopping tolerance -% maxiter: limit of iterations - - H = Hinit; - WtV = W'*V; - WtW = W'*W; - - alpha = 1; - beta = 0.1; - - for iter=1:maxiter - grad = WtW*H - WtV; - projgrad = norm ( grad(grad < 0 | H >0) ); - - if projgrad < tol, - break - end - - % search step size - Hn = max(H - alpha*grad, 0); - d = Hn-H; - gradd = sum ( sum (grad.*d) ); - dQd = sum ( sum ((WtW*d).*d) ); - - if gradd + 0.5*dQd > 0.01*gradd, - % decrease alpha - while 1, - alpha *= beta; - Hn = max (H - alpha*grad, 0); - d = Hn-H; - gradd = sum (sum (grad.*d) ); - dQd = sum (sum ((WtW*d).*d)); - - if gradd + 0.5*dQd <= 0.01*gradd || alpha < 1e-20 - H = Hn; - break - end - - endwhile - - else - % increase alpha - while 1, - Hp = Hn; - alpha /= beta; - Hn = max (H - alpha*grad, 0); - d = Hn-H; - gradd = sum ( sum (grad.*d) ); - dQd = sum (sum ( (WtW*d).*d ) ); - - if gradd + 0.5*dQd > 0.01*gradd || Hn == Hp || alpha > 1e10 - H = Hp; - alpha *= beta; - break - end - - endwhile - end - - endfor - - if iter == maxiter - warning('mnf_pg:MaxIter',["Reached maximum iterations in nlssubprob\n" ... - "Could be solved increasing MaxSubIter.\n"]); - end - -endfunction - -%!demo -%! t = linspace (0,1,100)'; -%! -%! ## --- Build hump functions of different frequency -%! W_true = arrayfun ( @(f)sin(2*pi*f*t).^2, linspace (0.5,2,4), ... -%! 'uniformoutput', false ); -%! W_true = cell2mat (W_true); -%! ## --- Build combinator vectors -%! c = (1:4)'; -%! H_true = arrayfun ( @(f)circshift(c,f), linspace (0,3,4), ... -%! 'uniformoutput', false ); -%! H_true = cell2mat (H_true); -%! ## --- Mix them -%! V = W_true*H_true; -%! ## --- Give good inital guesses -%! Winit = W_true + 0.4*randn(size(W_true)); -%! Hinit = H_true + 0.2*randn(size(H_true)); -%! ## --- Factorize -%! [W H] = nmf_pg(V,'Winit',Winit,'Hinit',Hinit,'Tol',1e-6,'MaxIter',1e3); -%! disp('True mixer') -%! disp(H_true) -%! disp('Rounded factorized mixer') -%! disp(round(H)) -%! ## --- Plot results -%! plot(t,W,'o;factorized;') -%! hold on -%! plot(t,W_true,'-;True;') -%! hold off -%! axis tight Copied: trunk/octave-forge/main/linear-algebra/inst/nmf_bpas.m (from rev 10470, trunk/octave-forge/main/linear-algebra/devel/nmf_bpas.m) =================================================================== --- trunk/octave-forge/main/linear-algebra/inst/nmf_bpas.m (rev 0) +++ trunk/octave-forge/main/linear-algebra/inst/nmf_bpas.m 2012-05-21 07:13:05 UTC (rev 10471) @@ -0,0 +1,711 @@ +## Copyright (c) 2012 by Jingu Kim and Haesun Park <ji...@cc...> +## +## This program is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{W}, @var{H}, @var{iter}, @var{HIS}] = } nmf_bpas (@var{A}, @var{k}) +## Nonnegative Matrix Factorization by Alternating Nonnegativity Constrained Least Squares +## using Block Principal Pivoting/Active Set method. +## +## This function solves one the following problems: given @var{A} and @var{k}, find @var{W} and @var{H} such that +## (1) minimize 1/2 * || @var{A}-@var{W}@var{H} ||_F^2 +## (2) minimize 1/2 * ( || @var{A}-@var{W}@var{H} ||_F^2 + alpha * || @var{W} ||_F^2 + beta * || @var{H} ||_F^2 ) +## (3) minimize 1/2 * ( || @var{A}-@var{W}@var{H} ||_F^2 + alpha * || @var{W} ||_F^2 + beta * (sum_(i=1)^n || @var{H}(:,i) ||_1^2 ) ) +## where @var{W}>=0 and @var{H}>=0 elementwise. +## The input arguments are @var{A} : Input data matrix (m x n) and @var{k} : Target low-rank. +## +## +## @strong{Optional Inputs} +## @table @samp +## @item Type : Default is 'regularized', which is recommended for quick application testing unless 'sparse' or 'plain' is explicitly needed. If sparsity is needed for 'W' factor, then apply this function for the transpose of 'A' with formulation (3). Then, exchange 'W' and 'H' and obtain the transpose of them. Imposing sparsity for both factors is not recommended and thus not included in this software. +## @table @asis +## @item 'plain' to use formulation (1) +## @item 'regularized' to use formulation (2) +## @item 'sparse' to use formulation (3) +## @end table +## +## @item NNLSSolver : Default is 'bp', which is in general faster. +## @table @asis +## item 'bp' to use the algorithm in [1] +## item 'as' to use the algorithm in [2] +## @end table +## +## @item Alpha : Parameter alpha in the formulation (2) or (3). Default is the average of all elements in A. No good justfication for this default value, and you might want to try other values. +## @item Beta : Parameter beta in the formulation (2) or (3). +## Default is the average of all elements in A. No good justfication for this default value, and you might want to try other values. +## @item MaxIter : Maximum number of iterations. Default is 100. +## @item MinIter : Minimum number of iterations. Default is 20. +## @item MaxTime : Maximum amount of time in seconds. Default is 100,000. +## @item Winit : (m x k) initial value for W. +## @item Hinit : (k x n) initial value for H. +## @item Tol : Stopping tolerance. Default is 1e-3. If you want to obtain a more accurate solution, decrease TOL and increase MAX_ITER at the same time. +## @item Verbose : +## @table @asis +## @item 0 (default) - No debugging information is collected.@* +## @item 1 (debugging purpose) - History of computation is returned by 'HIS' variable. +## @item 2 (debugging purpose) - History of computation is additionally printed on screen. +## @end table +## @end table +## +## @strong{Outputs} +## @table @samp +## @item W : Obtained basis matrix (m x k) +## @item H : Obtained coefficients matrix (k x n) +## @item iter : Number of iterations +## @item HIS : (debugging purpose) History of computation +## @end table +## +## Usage Examples: +## @example +## nmf(A,10) +## nmf(A,20,'verbose',2) +## nmf(A,30,'verbose',2,'nnls_solver','as') +## nmf(A,5,'verbose',2,'type','sparse') +## nmf(A,60,'verbose',1,'type','plain','w_init',rand(m,k)) +## nmf(A,70,'verbose',2,'type','sparse','nnls_solver','bp','alpha',1.1,'beta',1.3) +## @end example +## +## References: +## [1] For using this software, please cite:@* +## Jingu Kim and Haesun Park, Toward Faster Nonnegative Matrix Factorization: A New Algorithm and Comparisons,@* +## In Proceedings of the 2008 Eighth IEEE International Conference on Data Mining (ICDM'08), 353-362, 2008@* +## [2] If you use 'nnls_solver'='as' (see below), please cite:@* +## Hyunsoo Kim and Haesun Park, Nonnegative Matrix Factorization Based @* +## on Alternating Nonnegativity Constrained Least Squares and Active Set Method, @* +## SIAM Journal on Matrix Analysis and Applications, 2008, 30, 713-730 +## +## Check original code at @url{http://www.cc.gatech.edu/~jingu} +## +## @seealso{nmf_pg} +## @end deftypefn + +## 2012 - Modified and adapted to Octave 3.6.1 by +## Juan Pablo Carbajal <car...@if...> + +# TODO +# - Format code. +# - Vectorize loops. + +function [W, H, iter, HIS] = nmf_bpas (A, k , varargin) + page_screen_output (0, "local"); + + [m,n] = size(A); + ST_RULE = 1; + + # --- Parse arguments --- # + parser = inputParser (); + parser.FunctionName = "nmf_bpas"; + parser = addParamValue (parser,'Winit', rand(m,k), @ismatrix); + parser = addParamValue (parser,'Hinit', rand(k,n), @ismatrix); + parser = addParamValue (parser,'Tol', 1e-3, @(x)x>0); + parser = addParamValue (parser,'Alpha', mean (A(:)), @(x)x>=0); + parser = addParamValue (parser,'Beta', mean (A(:)), @(x)x>=0); + parser = addParamValue (parser,'MaxIter', 100, @(x)x>0); + parser = addParamValue (parser,'MaxTime', 1e3, @(x)x>0); + parser = addParamValue (parser,'Verbose', false); + + val_type = @(x,c) ischar (x) && any (strcmpi (x,c)); + parser = addParamValue (parser,'Type', 'regularized', ... + @(x)val_type (x,{'regularized', 'sparse','plain'})); + parser = addParamValue (parser,'NNLSSolver', 'bp', ... + @(x)val_type (x,{'bp', 'as'})); + + parser = parse(parser,varargin{:}); + + % Default configuration + par.m = m; + par.n = n; + par.type = parser.Results.Type; + par.nnls_solver = parser.Results.NNLSSolver; + par.alpha = parser.Results.Alpha; + par.beta = parser.Results.Beta; + par.max_iter = parser.Results.MaxIter; + par.min_iter = 20; + par.max_time = parser.Results.MaxTime; + par.tol = parser.Results.Tol; + par.verbose = parser.Results.Verbose; + W = parser.Results.Winit; + H = parser.Results.Hinit; + + # TODO check if can be removed + argAlpha = par.alpha; + argBeta = par.beta; + + clear parser val_type + +### PARSING TYPE +# TODO add callbacks here to use during main loop. See [1] + % for regularized/sparse case + salphaI = sqrt (par.alpha) * eye (k); + zerokm = zeros (k,m); + + if strcmpi (par.type, 'regularized') + sbetaI = sqrt (par.beta) * eye (k); + zerokn = zeros (k,n); + + elseif strcmpi (par.type, 'sparse') + sbetaE = sqrt (par.beta) * ones (1,k); + betaI = par.beta * ones (k,k); + zero1n = zeros (1,n); + + end +### + +# Verbosity + display(par); +### Done till here Sun Mar 25 19:00:26 2012 + + HIS = 0; + if par.verbose % collect information for analysis/debugging + [gradW,gradH] = getGradient(A,W,H,par.type,par.alpha,par.beta); + initGrNormW = norm(gradW,'fro'); + initGrNormH = norm(gradH,'fro'); + initNorm = norm(A,'fro'); + numSC = 3; + initSCs = zeros(numSC,1); + for j=1:numSC + initSCs(j) = getInitCriterion(j,A,W,H,par.type,par.alpha,par.beta,gradW,gradH); + end +%---(1)------(2)--------(3)--------(4)--------(5)---------(6)----------(7)------(8)-----(9)-------(10)--------------(11)------- +% iter # | elapsed | totalTime | subIterW | subIterH | rel. obj.(%) | NM_GRAD | GRAD | DELTA | W density (%) | H density (%) +%------------------------------------------------------------------------------------------------------------------------------ + HIS = zeros(1,11); + HIS(1,[1:5])=0; + ver.initGrNormW = initGrNormW; + ver.initGrNormH = initGrNormH; + ver.initNorm = initNorm; HIS(1,6) = ver.initNorm; + ver.SC1 = initSCs(1); HIS(1,7) = ver.SC1; + ver.SC2 = initSCs(2); HIS(1,8) = ver.SC2; + ver.SC3 = initSCs(3); HIS(1,9) = ver.SC3; + ver.W_density = length(find(W>0))/(m*k); HIS(1,10) = ver.W_density; + ver.H_density = length(find(H>0))/(n*k); HIS(1,11) = ver.H_density; + if par.verbose == 2 + disp (ver); + end + tPrev = cputime; + end + + tStart = cputime; + tTotal = 0; + initSC = getInitCriterion(ST_RULE,A,W,H,par.type,par.alpha,par.beta); + SCconv = 0; + SC_COUNT = 3; + +#TODO: [1] Replace with callbacks avoid switching each time + for iter=1:par.max_iter + switch par.type + case 'plain' + [H,gradHX,subIterH] = nnlsm(W,A,H,par.nnls_solver); + [W,gradW,subIterW] = nnlsm(H',A',W',par.nnls_solver);, W=W';, gradW=gradW'; + gradH = (W'*W)*H - W'*A; + case 'regularized' + [H,gradHX,subIterH] = nnlsm([W;sbetaI],[A;zerokn],H,par.nnls_solver); + [W,gradW,subIterW] = nnlsm([H';salphaI],[A';zerokm],W',par.nnls_solver);, W=W';, gradW=gradW'; + gradH = (W'*W)*H - W'*A + par.beta*H; + case 'sparse' + [H,gradHX,subIterH] = nnlsm([W;sbetaE],[A;zero1n],H,par.nnls_solver); + [W,gradW,subIterW] = nnlsm([H';salphaI],[A';zerokm],W',par.nnls_solver);, W=W';, gradW=gradW'; + gradH = (W'*W)*H - W'*A + betaI*H; + end + + if par.verbose % collect information for analysis/debugging + elapsed = cputime-tPrev; + tTotal = tTotal + elapsed; + ver = []; + idx = iter+1; +%---(1)------(2)--------(3)--------(4)--------(5)---------(6)----------(7)------(8)-----(9)-------(10)--------------(11)------- +% iter # | elapsed | totalTime | subIterW | subIterH | rel. obj.(%) | NM_GRAD | GRAD | DELTA | W density (%) | H density (%) +%------------------------------------------------------------------------------------------------------------------------------ + ver.iter = iter; HIS(idx,1)=iter; + ver.elapsed = elapsed; HIS(idx,2)=elapsed; + ver.tTotal = tTotal; HIS(idx,3)=tTotal; + ver.subIterW = subIterW; HIS(idx,4)=subIterW; + ver.subIterH = subIterH; HIS(idx,5)=subIterH; + ver.relError = norm(A-W*H,'fro')/initNorm; HIS(idx,6)=ver.relError; + ver.SC1 = getStopCriterion(1,A,W,H,par.type,par.alpha,par.beta,gradW,gradH)/initSCs(1); HIS(idx,7)=ver.SC1; + ver.SC2 = getStopCriterion(2,A,W,H,par.type,par.alpha,par.beta,gradW,gradH)/initSCs(2); HIS(idx,8)=ver.SC2; + ver.SC3 = getStopCriterion(3,A,W,H,par.type,par.alpha,par.beta,gradW,gradH)/initSCs(3); HIS(idx,9)=ver.SC3; + ver.W_density = length(find(W>0))/(m*k); HIS(idx,10)=ver.W_density; + ver.H_density = length(find(H>0))/(n*k); HIS(idx,11)=ver.H_density; + if par.verbose == 2, display(ver);, end + tPrev = cputime; + end + + if (iter > par.min_iter) + SC = getStopCriterion(ST_RULE,A,W,H,par.type,par.alpha,par.beta,gradW,gradH); + if (par.verbose && (tTotal > par.max_time)) || (~par.verbose && ((cputime-tStart)>par.max_time)) + break; + elseif (SC/initSC <= par.tol) + SCconv = SCconv + 1; + if (SCconv >= SC_COUNT) + break; + end + else + SCconv = 0; + end + end + end + [m,n]=size(A); + norm2=sqrt(sum(W.^2,1)); + toNormalize = norm2>0; + W(:,toNormalize) = W(:,toNormalize)./repmat(norm2(toNormalize),m,1); + H(toNormalize,:) = H(toNormalize,:).*repmat(norm2(toNormalize)',1,n); + + final.iterations = iter; + if par.verbose + final.elapsed_total = tTotal; + else + final.elapsed_total = cputime-tStart; + end + final.relative_error = norm(A-W*H,'fro')/norm(A,'fro'); + final.W_density = length(find(W>0))/(m*k); + final.H_density = length(find(H>0))/(n*k); + display(final); + +endfunction + +%------------------------------------------------------------------------------------------------------------------------ +% Utility Functions +%------------------------------------------------------------------------------- +function retVal = getInitCriterion(stopRule,A,W,H,type,alpha,beta,gradW,gradH) +% STOPPING_RULE : 1 - Normalized proj. gradient +% 2 - Proj. gradient +% 3 - Delta by H. Kim +% 0 - None (want to stop by MAX_ITER or MAX_TIME) + if nargin~=9 + [gradW,gradH] = getGradient(A,W,H,type,alpha,beta); + end + [m,k]=size(W);, [k,n]=size(H);, numAll=(m*k)+(k*n); + switch stopRule + case 1 + retVal = norm([gradW; gradH'],'fro')/numAll; + case 2 + retVal = norm([gradW; gradH'],'fro'); + case 3 + retVal = getStopCriterion(3,A,W,H,type,alpha,beta,gradW,gradH); + case 0 + retVal = 1; + end + +endfunction +%------------------------------------------------------------------------------- +function retVal = getStopCriterion(stopRule,A,W,H,type,alpha,beta,gradW,gradH) +% STOPPING_RULE : 1 - Normalized proj. gradient +% 2 - Proj. gradient +% 3 - Delta by H. Kim +% 0 - None (want to stop by MAX_ITER or MAX_TIME) + if nargin~=9 + [gradW,gradH] = getGradient(A,W,H,type,alpha,beta); + end + + switch stopRule + case 1 + pGradW = gradW(gradW<0|W>0); + pGradH = gradH(gradH<0|H>0); + pGrad = [gradW(gradW<0|W>0); gradH(gradH<0|H>0)]; + pGradNorm = norm(pGrad); + retVal = pGradNorm/length(pGrad); + case 2 + pGradW = gradW(gradW<0|W>0); + pGradH = gradH(gradH<0|H>0); + pGrad = [gradW(gradW<0|W>0); gradH(gradH<0|H>0)]; + retVal = norm(pGrad); + case 3 + resmat=min(H,gradH); resvec=resmat(:); + resmat=min(W,gradW); resvec=[resvec; resmat(:)]; + deltao=norm(resvec,1); %L1-norm + num_notconv=length(find(abs(resvec)>0)); + retVal=deltao/num_notconv; + case 0 + retVal = 1e100; + end + +endfunction +%------------------------------------------------------------------------------- +function [gradW,gradH] = getGradient(A,W,H,type,alpha,beta) + switch type + case 'plain' + gradW = W*(H*H') - A*H'; + gradH = (W'*W)*H - W'*A; + case 'regularized' + gradW = W*(H*H') - A*H' + alpha*W; + gradH = (W'*W)*H - W'*A + beta*H; + case 'sparse' + k=size(W,2); + betaI = beta*ones(k,k); + gradW = W*(H*H') - A*H' + alpha*W; + gradH = (W'*W)*H - W'*A + betaI*H; + end + +endfunction + +%------------------------------------------------------------------------------------------------------------------------ +function [X,grad,iter] = nnlsm(A,B,init,solver) + switch solver + case 'bp' + [X,grad,iter] = nnlsm_blockpivot(A,B,0,init); + case 'as' + [X,grad,iter] = nnlsm_activeset(A,B,1,0,init); + end + +endfunction +%------------------------------------------------------------------------------------------------------------------------ +function [ X,Y,iter,success ] = nnlsm_activeset( A, B, overwrite, isInputProd, init) +% Nonnegativity Constrained Least Squares with Multiple Righthand Sides +% using Active Set method +% +% This software solves the following problem: given A and B, find X such that +% minimize || AX-B ||_F^2 where X>=0 elementwise. +% +% Reference: +% Charles L. Lawson and Richard J. Hanson, Solving Least Squares Problems, +% Society for Industrial and Applied Mathematics, 1995 +% M. H. Van Benthem and M. R. Keenan, +% Fast Algorithm for the Solution of Large-scale Non-negativity-constrained Least Squares Problems, +% J. Chemometrics 2004; 18: 441-450 +% +% Written by Jingu Kim (ji...@cc...) +% School of Computational Science and Engineering, +% Georgia Institute of Technology +% +% Last updated Feb-20-2010 +% +% <Inputs> +% A : input matrix (m x n) (by default), or A'*A (n x n) if isInputProd==1 +% B : input matrix (m x k) (by default), or A'*B (n x k) if isInputProd==1 +% overwrite : (optional, default:0) if turned on, unconstrained least squares solution is computed in the beginning +% isInputProd : (optional, default:0) if turned on, use (A'*A,A'*B) as input instead of (A,B) +% init : (optional) initial value for X +% <Outputs> +% X : the solution (n x k) +% Y : A'*A*X - A'*B where X is the solution (n x k) +% iter : number of iterations +% success : 1 for success, 0 for failure. +% Failure could only happen on a numericall very ill-conditioned problem. + + if nargin<3, overwrite=0;, end + if nargin<4, isInputProd=0;, end + + if isInputProd + AtA=A;,AtB=B; + else + AtA=A'*A;, AtB=A'*B; + end + + [n,k]=size(AtB); + MAX_ITER = n*5; + % set initial feasible solution + if overwrite + [X,iter] = solveNormalEqComb(AtA,AtB); + PassSet = (X > 0); + NotOptSet = any(X<0); + else + if nargin<5 + X = zeros(n,k); + PassSet = false(n,k); + NotOptSet = true(1,k); + else + X = init; + PassSet = (X > 0); + NotOptSet = any(X<0); + end + iter = 0; + end + + Y = zeros(n,k); + Y(:,~NotOptSet)=AtA*X(:,~NotOptSet) - AtB(:,~NotOptSet); + NotOptCols = find(NotOptSet); + + bigIter = 0;, success=1; + while(~isempty(NotOptCols)) + bigIter = bigIter+1; + if ((MAX_ITER >0) && (bigIter > MAX_ITER)) % set max_iter for ill-conditioned (numerically unstable) case + success = 0;, bigIter, break + end + + % find unconstrained LS solution for the passive set + Z = zeros(n,length(NotOptCols)); + [ Z,subiter ] = solveNormalEqComb(AtA,AtB(:,NotOptCols),PassSet(:,NotOptCols)); + iter = iter + subiter; + %Z(abs(Z)<... [truncated message content] |
From: <mtm...@us...> - 2012-05-20 16:04:19
|
Revision: 10470 http://octave.svn.sourceforge.net/octave/?rev=10470&view=rev Author: mtmiller Date: 2012-05-20 16:04:12 +0000 (Sun, 20 May 2012) Log Message: ----------- istrellis, poly2trellis: new functions for comm package Modified Paths: -------------- trunk/octave-forge/main/comm/NEWS Added Paths: ----------- trunk/octave-forge/main/comm/inst/istrellis.m trunk/octave-forge/main/comm/inst/poly2trellis.m Modified: trunk/octave-forge/main/comm/NEWS =================================================================== --- trunk/octave-forge/main/comm/NEWS 2012-05-20 15:13:10 UTC (rev 10469) +++ trunk/octave-forge/main/comm/NEWS 2012-05-20 16:04:12 UTC (rev 10470) @@ -1,3 +1,10 @@ +Summary of important user-visible changes for communications 1.1.2: +------------------------------------------------------------------- + + ** The following functions are new: + istrellis + poly2trellis + Summary of important user-visible changes for communications 1.1.1: ------------------------------------------------------------------- Added: trunk/octave-forge/main/comm/inst/istrellis.m =================================================================== --- trunk/octave-forge/main/comm/inst/istrellis.m (rev 0) +++ trunk/octave-forge/main/comm/inst/istrellis.m 2012-05-20 16:04:12 UTC (rev 10470) @@ -0,0 +1,110 @@ +## Copyright (C) 2012 Mike Miller <mtm...@ie...> +## +## This program is free software; you can redistribute it and/or modify it under +## the terms of the GNU General Public License as published by the Free Software +## Foundation; either version 3 of the License, or (at your option) any later +## version. +## +## This program is distributed in the hope that it will be useful, but WITHOUT +## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +## details. +## +## You should have received a copy of the GNU General Public License along with +## this program; if not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {} istrellis (@var{t}) +## @deftypefnx {Function File} {[@var{status}, @var{text}] =} istrellis (@var{t}) +## +## Return true if @var{t} is a valid trellis structure. +## +## If called with two output arguments, @var{text} contains a string indicating +## a reason if @var{status} is false or an empty string if @var{status} is true. +## +## @seealso{poly2trellis, struct} +## @end deftypefn + +function [status, text] = istrellis (t) + + if (nargin != 1) + print_usage (); + endif + + status = false; + text = ""; + + if !( isstruct (t) && + isfield (t, "numInputSymbols") && + isfield (t, "numOutputSymbols") && + isfield (t, "numStates") && + isfield (t, "nextStates") && + isfield (t, "outputs") ) + text = "t is not a valid trellis structure"; + else + try + outputs = oct2dec(t.outputs); + outputs_is_octal = true; + catch + outputs_is_octal = false; + end_try_catch + k = log2 (t.numInputSymbols); + n = log2 (t.numOutputSymbols); + nu = log2 (t.numStates); + if ( !isscalar(k) || (k < 0) || (k != fix (k))) + text = "numInputSymbols is not a power of 2"; + elseif ( !isscalar(n) || (n < 0) || (n != fix (n))) + text = "numOutputSymbols is not a power of 2"; + elseif ( !isscalar(nu) || (nu < 0) || (nu != fix (nu))) + text = "numStates is not a power of 2"; + elseif (any (size (t.nextStates) != [t.numStates t.numInputSymbols])) + text = "nextStates is not a numStates-by-numInputSymbols matrix"; + elseif (any (size (t.outputs) != [t.numStates t.numInputSymbols])) + text = "outputs is not a numStates-by-numInputSymbols matrix"; + elseif ( any (t.nextStates(:) != fix (t.nextStates(:))) || + any (t.nextStates(:) < 0) || + any (t.nextStates(:) > t.numStates - 1) ) + text = "nextStates must contain integers from 0 to numStates-1"; + elseif ( !outputs_is_octal || + any (t.outputs(:) != fix (t.outputs(:))) || + any (t.outputs(:) < 0) || + any (outputs(:) > t.numOutputSymbols - 1) ) + text = "outputs must contain octal integers from 0 to numOutputSymbols-1"; + else + status = true; + endif + endif + +endfunction + +%% Test the simple (2,1,3) encoder from Lin & Costello example 11.1 +%!test +%! T = struct ("numInputSymbols", 2, +%! "numOutputSymbols", 4, +%! "numStates", 8, +%! "nextStates", [0 4; 0 4; 1 5; 1 5; 2 6; 2 6; 3 7; 3 7], +%! "outputs", [0 3; 3 0; 3 0; 0 3; 1 2; 2 1; 2 1; 1 2]); +%! assert (istrellis (T), true) + +%% Tests of invalid arguments or invalid structures +%!test +%! [status, text] = istrellis ([]); +%! assert (status, false); +%! assert (isempty (strfind (text, "not a valid trellis")), false) +%!test +%! [status, text] = istrellis (struct ()); +%! assert (status, false); +%! assert (isempty (strfind (text, "not a valid trellis")), false) +%!test +%! T = struct ("numInputSymbols", 3, +%! "numOutputSymbols", 4, +%! "numStates", 0, +%! "nextStates", zeros(0,4), +%! "outputs", zeros(0,4)); +%! [status, text] = istrellis (T); +%! assert (status, false); +%! assert (isempty (strfind (text, "numInputSymbols")), false) + +%% Test input validation +%!error istrellis () +%!error istrellis (1,2) Added: trunk/octave-forge/main/comm/inst/poly2trellis.m =================================================================== --- trunk/octave-forge/main/comm/inst/poly2trellis.m (rev 0) +++ trunk/octave-forge/main/comm/inst/poly2trellis.m 2012-05-20 16:04:12 UTC (rev 10470) @@ -0,0 +1,201 @@ +## Copyright (C) 2012 Mike Miller <mtm...@ie...> +## +## This program is free software; you can redistribute it and/or modify it under +## the terms of the GNU General Public License as published by the Free Software +## Foundation; either version 3 of the License, or (at your option) any later +## version. +## +## This program is distributed in the hope that it will be useful, but WITHOUT +## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +## details. +## +## You should have received a copy of the GNU General Public License along with +## this program; if not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {@var{t} =} poly2trellis (@var{m}, @var{g}) +## +## Convert convolutional code generator polynomials into trellis form. +## +## The arguments @var{m} and @var{g} together describe a rate k/n feedforward +## convolutional encoder. The output @var{t} is a trellis structure describing +## the same encoder with the fields listed below. +## +## The vector @var{m} is a k-by-1 array containing the lengths of each of the +## shift registers for the k input bits to the encoder. +## +## The matrix @var{g} is a k-by-n octal-value matrix describing the generation +## of each of the n outputs from each of the k inputs. For a particular entry +## of @var{g}, the least-significant bit corresponds to the most-delayed input +## bit in the kth shift-register. +## +## The returned trellis structure contains the following fields: +## +## @table @samp +## @item numInputSymbols +## The number of k-bit input symbols possible, i.e. 2^k. +## +## @item numOutputSymbols +## The number of n-bit output symbols possible, i.e. 2^n. +## +## @item numStates +## The number of states in the trellis. +## +## @item nextStates +## The state transition table for the trellis. The ith row contains the indices +## of the states reachable from the (i-1)th state for each possible input +## symbol. +## +## @item outputs +## A table of octal-encoded output values for the trellis. The ith row contains +## values representing the output symbols produced in the (i-1)th state for each +## possible input symbol. +## @end table +## +## Input symbols, output symbols, and encoder states are all interpreted with +## the lowest indices being the most significant bits. +## +## References: +## +## [1] S. Lin and D. J. Costello, "Convolutional codes," in @cite{Error +## Control Coding}, 2nd ed. Upper Saddle River, NJ: Pearson, 2004, +## ch. 11, pp. 453-513. +## +## @seealso{istrellis} +## @end deftypefn + +function t = poly2trellis (m, g) + + if (nargin != 2) + print_usage (); + endif + + ## Notation agrees with Lin & Costello for the most part: + ## m = length of each modulo-2 adder + ## = 1 + nu(:) = one more than length of each shift register + ## g = generator sequences, k-by-n + ## k = bits per input symbol = number of shift registers + ## n = bits per output symbol = number of modulo-2 adders + [nr, k] = size(m); + if (nr != 1) + error ("poly2trellis: m must be a 1-by-k positive integer row vector"); + endif + if (any (m < 1) || any (m != fix (m))) + error ("poly2trellis: m must be a 1-by-k positive integer row vector"); + endif + + [nr, n] = size(g); + if (nr != k) + error ("poly2trellis: g must be a k-by-n octal matrix"); + endif + + ## Convert g to decimal, let oct2dec validate the octal values + g = oct2dec (g); + + ## Check the ranges of the generators + ## nu = total number of linear shift registers for all k + nu = sum (m) - k; + + ## Number of states and input symbols needed to capture the state machine + nstates = 2^nu; + ninputs = 2^k; + noutputs = 2^n; + + t = struct ("numInputSymbols", ninputs, + "numOutputSymbols", noutputs, + "numStates", nstates, + "nextStates", zeros (nstates, ninputs), + "outputs", zeros (nstates, ninputs)); + + ## Split state indices into values for each distinct shift register. + ## Also precalculate new bit position for each shift register and the left + ## shifts required to reassemble the states into one state value. + ## + ## Conventions: + ## - Each shift register shifts to the right, MSB-to-LSB + ## - The MSB of each shift register is the newest input + ## - The MSBs of the state represent the k=1 shift register + statebits = de2bi (0:nstates - 1); + states = zeros (nstates, k); + newbit = zeros (1, k); + shifts = zeros (1, k); + offset = 1; + for i = 1:k + nu_i = m(i) - 1; + if (nu_i > 0) + states(:,i) = bi2de (statebits(:, offset:offset + nu_i - 1)); + endif + newbit(i) = bitshift (1, nu_i); + shifts(i) = offset - 1; + offset += nu_i; + + if (any (g(i,:) >= 2^m(i))) + error ("poly2trellis: code size is greater than constraint length"); + endif + if (all (g(i,:) < 2^nu_i) || !any (mod (g(i,:), 2))) + error ("poly2trellis: code size is less than constraint length"); + endif + endfor + + ## Generate conversion list of all possible output octal values + outputs = str2num (dec2base (0:noutputs - 1, 8)); + + ## Walk the trellis, each row index is state, each column index is input + for s = 1:nstates + + for i = 1:k + ## For each next input bit [0,1] calculate inputs to modulo-2 adder + ## and the next state for the ith linear shift register, left-shifted + ## to be combined into the total state. + state = states(s,i) + [0; newbit(i)]; + next = bitshift (bitshift (state, -1), shifts(i)); + + ## Calculate the modulo-2 sum of the state plus input for each n for + ## this particular shift register. + ## The MSB of the output represents the n=1 generator(s) + out = [0; 0]; + for adder = 1:n + val = mod (sum (de2bi (bitand (g(i, adder), state)), 2), 2); + out += bitshift(val, n - adder); + endfor + + ## Accumulate contributions to the trellis for this shift register. + ## The contribution to each input symbol depends on whether the + ## (k-i)th bit is 0 or 1. + bitpos = k - i; + for symbol = 1:ninputs + idx = bitget (symbol - 1, bitpos + 1) + 1; + t.nextStates(s, symbol) += next(idx); + t.outputs(s, symbol) = bitxor (t.outputs(s, symbol), out(idx)); + endfor + + endfor + + ## Convert output values to octal representation + t.outputs(s,:) = outputs(t.outputs(s,:) + 1); + + endfor + +endfunction + +%% Test the simple (2,1,3) encoder from Lin & Costello example 11.1 +%!test +%! T = struct ("numInputSymbols", 2, +%! "numOutputSymbols", 4, +%! "numStates", 8, +%! "nextStates", [0 4; 0 4; 1 5; 1 5; 2 6; 2 6; 3 7; 3 7], +%! "outputs", [0 3; 3 0; 3 0; 0 3; 1 2; 2 1; 2 1; 1 2]); +%! t = poly2trellis (4, [13 17]); +%! assert (t, T) +%! assert (istrellis (t), true) + +%% Test input validation +%!error poly2trellis () +%!error poly2trellis (1,2,3) +%!error poly2trellis (1) +%!error poly2trellis (2,8) +%!error poly2trellis (0,0) +%!error poly2trellis (2,0) +%!error poly2trellis (2,2) +%!error poly2trellis (2,7) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-05-20 15:13:16
|
Revision: 10469 http://octave.svn.sourceforge.net/octave/?rev=10469&view=rev Author: paramaniac Date: 2012-05-20 15:13:10 +0000 (Sun, 20 May 2012) Log Message: ----------- control-devel: minor enhancements for error messages Modified Paths: -------------- trunk/octave-forge/extra/control-devel/inst/__slicot_identification__.m trunk/octave-forge/extra/control-devel/inst/moen4.m trunk/octave-forge/extra/control-devel/inst/moesp.m trunk/octave-forge/extra/control-devel/inst/n4sid.m Modified: trunk/octave-forge/extra/control-devel/inst/__slicot_identification__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__slicot_identification__.m 2012-05-20 14:49:09 UTC (rev 10468) +++ trunk/octave-forge/extra/control-devel/inst/__slicot_identification__.m 2012-05-20 15:13:10 UTC (rev 10469) @@ -10,6 +10,10 @@ otherwise error ("ident: invalid method"); # should never happen endswitch + + if (! isa (dat, "iddata")) + error ("%s: first argument must be an 'iddata' dataset", method); + endif alg = 0; conct = 1; Modified: trunk/octave-forge/extra/control-devel/inst/moen4.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/moen4.m 2012-05-20 14:49:09 UTC (rev 10468) +++ trunk/octave-forge/extra/control-devel/inst/moen4.m 2012-05-20 15:13:10 UTC (rev 10469) @@ -28,6 +28,10 @@ function [sys, x0] = moen4 (varargin) + if (nargin == 0) + print_usage (); + endif + [sys, x0] = __slicot_identification__ ("moen4", varargin{:}); endfunction \ No newline at end of file Modified: trunk/octave-forge/extra/control-devel/inst/moesp.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/moesp.m 2012-05-20 14:49:09 UTC (rev 10468) +++ trunk/octave-forge/extra/control-devel/inst/moesp.m 2012-05-20 15:13:10 UTC (rev 10469) @@ -26,6 +26,10 @@ function [sys, x0] = moesp (varargin) + if (nargin == 0) + print_usage (); + endif + [sys, x0] = __slicot_identification__ ("moesp", varargin{:}); endfunction \ No newline at end of file Modified: trunk/octave-forge/extra/control-devel/inst/n4sid.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/n4sid.m 2012-05-20 14:49:09 UTC (rev 10468) +++ trunk/octave-forge/extra/control-devel/inst/n4sid.m 2012-05-20 15:13:10 UTC (rev 10469) @@ -26,6 +26,10 @@ function [sys, x0] = n4sid (varargin) + if (nargin == 0) + print_usage (); + endif + [sys, x0] = __slicot_identification__ ("n4sid", varargin{:}); endfunction \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mtm...@us...> - 2012-05-20 14:49:15
|
Revision: 10468 http://octave.svn.sourceforge.net/octave/?rev=10468&view=rev Author: mtmiller Date: 2012-05-20 14:49:09 +0000 (Sun, 20 May 2012) Log Message: ----------- oct2dec: update patch to handle larger number ranges Modified Paths: -------------- trunk/octave-forge/main/comm/inst/oct2dec.m Modified: trunk/octave-forge/main/comm/inst/oct2dec.m =================================================================== --- trunk/octave-forge/main/comm/inst/oct2dec.m 2012-05-20 14:23:17 UTC (rev 10467) +++ trunk/octave-forge/main/comm/inst/oct2dec.m 2012-05-20 14:49:09 UTC (rev 10468) @@ -37,7 +37,7 @@ d = zeros (size (c)); l = size (c, 2); for k = 1:l - str = num2str (c(:,k), "%d"); + str = num2str (c(:,k), "%ld"); d(:,k) = base2dec (str, 8); if (any (isnan (d(:,k)))) error ("oct2dec: c must be an octal matrix"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mtm...@us...> - 2012-05-20 14:23:24
|
Revision: 10467 http://octave.svn.sourceforge.net/octave/?rev=10467&view=rev Author: mtmiller Date: 2012-05-20 14:23:17 +0000 (Sun, 20 May 2012) Log Message: ----------- comm: Apply patch from S?\195?\169bastien Villemot on mailing list. Modified Paths: -------------- trunk/octave-forge/main/comm/inst/oct2dec.m Modified: trunk/octave-forge/main/comm/inst/oct2dec.m =================================================================== --- trunk/octave-forge/main/comm/inst/oct2dec.m 2012-05-20 09:18:53 UTC (rev 10466) +++ trunk/octave-forge/main/comm/inst/oct2dec.m 2012-05-20 14:23:17 UTC (rev 10467) @@ -37,7 +37,7 @@ d = zeros (size (c)); l = size (c, 2); for k = 1:l - str = num2str (c(:,k)); + str = num2str (c(:,k), "%d"); d(:,k) = base2dec (str, 8); if (any (isnan (d(:,k)))) error ("oct2dec: c must be an octal matrix"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-05-20 09:18:59
|
Revision: 10466 http://octave.svn.sourceforge.net/octave/?rev=10466&view=rev Author: paramaniac Date: 2012-05-20 09:18:53 +0000 (Sun, 20 May 2012) Log Message: ----------- control-devel: ARX models have individual error inputs for each output Modified Paths: -------------- trunk/octave-forge/extra/control-devel/inst/arx.m Modified: trunk/octave-forge/extra/control-devel/inst/arx.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/arx.m 2012-05-19 22:15:57 UTC (rev 10465) +++ trunk/octave-forge/extra/control-devel/inst/arx.m 2012-05-20 09:18:53 UTC (rev 10466) @@ -27,13 +27,6 @@ function sys = arx (dat, na, nb) ## TODO: delays - - ## FIXME: MIMO models have p error inputs, not just 1 - - ## FIXME: Unlike SISO or MISO models, the transfer function - ## B(z) over A(z) is wrong for MIMO models. - ## We need a Matrix Fraction Description (MFD) - ## y = A^-1(q) B(q) u(t) + A^-1(q) e(t) if (nargin != 3) print_usage (); @@ -60,24 +53,24 @@ if (is_real_scalar (na, nb)) - na = repmat (na, p, 1); # na(p-by-1) - nb = repmat (nb, p, m); # nb(p-by-m) + na = repmat (na, p, 1); # na(p-by-1) + nb = repmat (nb, p, m); # nb(p-by-m) elseif (! (is_real_vector (na) && is_real_matrix (nb) \ && rows (na) == p && rows (nb) == p && columns (nb) == m)) error ("arx: require na(%dx1) instead of (%dx%d) and nb(%dx%d) instead of (%dx%d)", \ p, rows (na), columns (na), p, m, rows (nb), columns (nb)); endif - max_nb = max (nb, [], 2); # one maximum for each row/output, max_nb(p-by-1) - n = max (na, max_nb); # n(p-by-1) + max_nb = max (nb, [], 2); # one maximum for each row/output, max_nb(p-by-1) + n = max (na, max_nb); # n(p-by-1) - num = cell (p, m+1); - den = cell (p, m+1); + num = cell (p, m+p); + den = cell (p, m+p); - for i = 1 : p # for every output + for i = 1 : p # for every output Phi = cell (ex, 1); - for e = 1 : ex # for every experiment + for e = 1 : ex # for every experiment ## avoid warning: toeplitz: column wins anti-diagonal conflict ## therefore set first row element equal to y(1) PhiY = toeplitz (Y{e}(1:end-1, i), [Y{e}(1, i); zeros(na(i)-1, 1)]); @@ -88,16 +81,25 @@ Theta = __theta__ (Phi, Y, i, n); - A = [1; Theta(1:na(i))]; # a0 = 1, a1 = Theta(1), an = Theta(n) - ThetaB = Theta(na(i)+1:end); # b0 = 0 (leading zero required by filt) + A = [1; Theta(1:na(i))]; # a0 = 1, a1 = Theta(1), an = Theta(n) + ThetaB = Theta(na(i)+1:end); # b0 = 0 (leading zero required by filt) B = mat2cell (ThetaB, nb(i,:)); B = reshape (B, 1, []); B = cellfun (@(x) [0; x], B, "uniformoutput", false); - num(i, :) = [B, {1}]; - den(i, :) = repmat ({A}, 1, m+1); + Be = repmat ({0}, 1, p); + Be(i) = 1; + num(i, :) = [B, Be]; + den(i, :) = repmat ({A}, 1, m+p); endfor + ## A(q) y(t) = B(q) u(t) + e(t) + ## there is only one A per row + ## B(z) and A(z) are a Matrix Fraction Description (MFD) + ## y = A^-1(q) B(q) u(t) + A^-1(q) e(t) + ## since A(q) is a diagonal polynomial matrix, its inverse is trivial: + ## the corresponding transfer function has common row denominators. + sys = filt (num, den, tsam); endfunction @@ -147,8 +149,8 @@ ## Th = Ph \ Y = Ph+ Y ## Th = V S+ U* Y, S+ = 1 ./ diag (S) - [U, S, V] = svd (A, 0); # 0 for "economy size" decomposition - S = diag (S); # extract main diagonal + [U, S, V] = svd (A, 0); # 0 for "economy size" decomposition + S = diag (S); # extract main diagonal r = sum (S > eps*S(1)); if (r < length (S)) warning ("arx: rank-deficient coefficient matrix"); @@ -158,6 +160,6 @@ V = V(:, 1:r); S = S(1:r); U = U(:, 1:r); - x = V * (S .\ (U' * b)); # U' is the conjugate transpose + x = V * (S .\ (U' * b)); # U' is the conjugate transpose endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-05-19 22:16:03
|
Revision: 10465 http://octave.svn.sourceforge.net/octave/?rev=10465&view=rev Author: paramaniac Date: 2012-05-19 22:15:57 +0000 (Sat, 19 May 2012) Log Message: ----------- control: work on docstrings Modified Paths: -------------- trunk/octave-forge/main/control/devel/dlqe.m trunk/octave-forge/main/control/devel/lqe.m Modified: trunk/octave-forge/main/control/devel/dlqe.m =================================================================== --- trunk/octave-forge/main/control/devel/dlqe.m 2012-05-19 08:39:04 UTC (rev 10464) +++ trunk/octave-forge/main/control/devel/dlqe.m 2012-05-19 22:15:57 UTC (rev 10465) @@ -1,3 +1,77 @@ +## Copyright (C) 2012 Lukas F. Reichlin +## +## This file is part of LTI Syncope. +## +## LTI Syncope is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## LTI Syncope is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{g}, @var{x}, @var{l}] =} lqr (@var{sys}, @var{q}, @var{r}) +## @deftypefnx {Function File} {[@var{g}, @var{x}, @var{l}] =} lqr (@var{sys}, @var{q}, @var{r}, @var{s}) +## @deftypefnx {Function File} {[@var{g}, @var{x}, @var{l}] =} lqr (@var{a}, @var{b}, @var{q}, @var{r}) +## @deftypefnx {Function File} {[@var{g}, @var{x}, @var{l}] =} lqr (@var{a}, @var{b}, @var{q}, @var{r}, @var{s}) +## @deftypefnx {Function File} {[@var{g}, @var{x}, @var{l}] =} lqr (@var{a}, @var{b}, @var{q}, @var{r}, @var{[]}, @var{e}) +## @deftypefnx {Function File} {[@var{g}, @var{x}, @var{l}] =} lqr (@var{a}, @var{b}, @var{q}, @var{r}, @var{s}, @var{e}) +## Linear-quadratic regulator. +## +## @strong{Inputs} +## @table @var +## @item sys +## Continuous or discrete-time LTI model. +## @item a +## State transition matrix of continuous-time system. +## @item b +## Input matrix of continuous-time system. +## @item q +## State weighting matrix. +## @item r +## Input weighting matrix. +## @item s +## Optional cross term matrix. If @var{s} is not specified, a zero matrix is assumed. +## @item e +## Optional descriptor matrix. If @var{e} is not specified, an identity matrix is assumed. +## @end table +## +## @strong{Outputs} +## @table @var +## @item g +## State feedback matrix. +## @item x +## Unique stabilizing solution of the continuous-time Riccati equation. +## @item l +## Closed-loop poles. +## @end table +## +## @strong{Equations} +## @example +## @group +## . +## x = A x + B u, x(0) = x0 +## +## inf +## J(x0) = INT (x' Q x + u' R u + 2 x' S u) dt +## 0 +## +## L = eig (A - B*G) +## @end group +## @end example +## @seealso{care, dare, dlqr} +## @end deftypefn + +## Author: Lukas Reichlin <luk...@gm...> +## Created: April 2012 +## Version: 0.1 + function [l, p, z, e] = dlqe (a, g, c, q, r, s = []) if (nargin < 5 || nargin > 6) @@ -19,4 +93,4 @@ ## z = p - p*c.' / (c*p*c.' + r) * c*p; z = p - l*c*p; -endfunction \ No newline at end of file +endfunction Modified: trunk/octave-forge/main/control/devel/lqe.m =================================================================== --- trunk/octave-forge/main/control/devel/lqe.m 2012-05-19 08:39:04 UTC (rev 10464) +++ trunk/octave-forge/main/control/devel/lqe.m 2012-05-19 22:15:57 UTC (rev 10465) @@ -1,3 +1,77 @@ +## Copyright (C) 2012 Lukas F. Reichlin +## +## This file is part of LTI Syncope. +## +## LTI Syncope is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## LTI Syncope is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{g}, @var{x}, @var{l}] =} lqe (@var{sys}, @var{q}, @var{r}) +## @deftypefnx {Function File} {[@var{g}, @var{x}, @var{l}] =} lqe (@var{sys}, @var{q}, @var{r}, @var{s}) +## @deftypefnx {Function File} {[@var{g}, @var{x}, @var{l}] =} lqe (@var{a}, @var{g}, @var{c}, @var{q}, @var{r}) +## @deftypefnx {Function File} {[@var{g}, @var{x}, @var{l}] =} lqe (@var{a}, @var{g}, @var{c}, @var{q}, @var{r}, @var{s}) +## @deftypefnx {Function File} {[@var{g}, @var{x}, @var{l}] =} lqe (@var{a}, @var{[]}, @var{c}, @var{q}, @var{r}) +## @deftypefnx {Function File} {[@var{g}, @var{x}, @var{l}] =} lqe (@var{a}, @var{[]}, @var{c}, @var{q}, @var{r}, @var{s}) +## Linear-quadratic estimator. +## +## @strong{Inputs} +## @table @var +## @item sys +## Continuous or discrete-time LTI model. +## @item a +## State transition matrix of continuous-time system. +## @item b +## Input matrix of continuous-time system. +## @item q +## State weighting matrix. +## @item r +## Input weighting matrix. +## @item s +## Optional cross term matrix. If @var{s} is not specified, a zero matrix is assumed. +## @item e +## Optional descriptor matrix. If @var{e} is not specified, an identity matrix is assumed. +## @end table +## +## @strong{Outputs} +## @table @var +## @item l +## Observer gain matrix. +## @item p +## Unique stabilizing solution of the continuous-time Riccati equation. +## @item e +## Closed-loop poles. +## @end table +## +## @strong{Equations} +## @example +## @group +## . +## x = A x + B u, x(0) = x0 +## +## inf +## J(x0) = INT (x' Q x + u' R u + 2 x' S u) dt +## 0 +## +## L = eig (A - B*G) +## @end group +## @end example +## @seealso{care, dare, dlqr} +## @end deftypefn + +## Author: Lukas Reichlin <luk...@gm...> +## Created: April 2012 +## Version: 0.1 + function [l, p, e] = lqe (a, g, c, q = [], r = [], s = []) if (nargin < 3 || nargin > 6) @@ -16,4 +90,4 @@ l = l.'; -endfunction \ No newline at end of file +endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-05-19 08:39:11
|
Revision: 10464 http://octave.svn.sourceforge.net/octave/?rev=10464&view=rev Author: paramaniac Date: 2012-05-19 08:39:04 +0000 (Sat, 19 May 2012) Log Message: ----------- control-devel: fix dimension conflict for multi-experiment ARX identification Modified Paths: -------------- trunk/octave-forge/extra/control-devel/inst/arx.m Added Paths: ----------- trunk/octave-forge/extra/control-devel/devel/DestillationMEarx.m trunk/octave-forge/extra/control-devel/devel/LakeErieARX.m Added: trunk/octave-forge/extra/control-devel/devel/DestillationMEarx.m =================================================================== --- trunk/octave-forge/extra/control-devel/devel/DestillationMEarx.m (rev 0) +++ trunk/octave-forge/extra/control-devel/devel/DestillationMEarx.m 2012-05-19 08:39:04 UTC (rev 10464) @@ -0,0 +1,92 @@ +%{ +This file describes the data in the destill.dat file. +1. Contributed by: + Peter Van Overschee + K.U.Leuven - ESAT - SISTA + K. Mercierlaan 94 + 3001 Heverlee + Pet...@es... +2. Process/Description: + Data of a simulation (not real !) related to the identification + of an ethane-ethylene destillationcolumn. The series consists of 4 + series: + U_dest, Y_dest: without noise (original series) + U_dest_n10, Y_dest_n10: 10 percent additive white noise + U_dest_n20, Y_dest_n20: 20 percent additive white noise + U_dest_n30, Y_dest_n30: 30 percent additive white noise +3. Sampling time + 15 min. +4. Number of samples: + 90 samples +5. Inputs: + a. ratio between the reboiler duty and the feed flow + b. ratio between the reflux rate and the feed flow + c. ratio between the distillate and the feed flow + d. input ethane composition + e. top pressure +6. Outputs: + a. top ethane composition + b. bottom ethylene composition + c. top-bottom differential pressure. +7. References: + R.P. Guidorzi, M.P. Losito, T. Muratori, The range error test in the + structural identification of linear multivariable systems, + IEEE transactions on automatic control, Vol AC-27, pp 1044-1054, oct. + 1982. +8. Known properties/peculiarities + +9. Some MATLAB-code to retrieve the data + !gunzip destill.dat.Z + load destill.dat + U=destill(:,1:20); + Y=destill(:,21:32); + U_dest=U(:,1:5); + U_dest_n10=U(:,6:10); + U_dest_n20=U(:,11:15); + U_dest_n30=U(:,16:20); + Y_dest=Y(:,1:3); + Y_dest_n10=Y(:,4:6); + Y_dest_n20=Y(:,7:9); + Y_dest_n30=Y(:,10:12); +%} + +clear all, close all, clc + +% DaISy code is wrong, +% first column is sample number +load destill.dat +U=destill(:,2:21); +Y=destill(:,22:33); +U_dest=U(:,1:5); +U_dest_n10=U(:,6:10); +U_dest_n20=U(:,11:15); +U_dest_n30=U(:,16:20); +Y_dest=Y(:,1:3); +Y_dest_n10=Y(:,4:6); +Y_dest_n20=Y(:,7:9); +Y_dest_n30=Y(:,10:12); + +Y = {Y_dest; Y_dest_n10; Y_dest_n20; Y_dest_n30}; +U = {U_dest; U_dest_n10; U_dest_n20; U_dest_n30}; + +dat = iddata (Y, U) + +[sys, x0] = ident (dat, 5, 4) % s=5, n=4 +sys2 = arx (dat, 4, 4); + +x0=x0{1}; + +[y, t] = lsim (sys, U_dest, [], x0); +[y2, t2] = lsim (sys(:, 1:5), U_dest); + +% ARX has no initial conditions, therefore the bad results + +err = norm (Y_dest - y, 1) / norm (Y_dest, 1) +err2 = norm (Y_dest - y2, 1) / norm (Y_dest, 1) + +figure (1) +%plot (t, Y_dest, 'b') +plot (t, Y_dest, t, y, t, y2) +legend ('y measured', 'y MOEN4', 'y ARX', 'location', 'southeast') + + Added: trunk/octave-forge/extra/control-devel/devel/LakeErieARX.m =================================================================== --- trunk/octave-forge/extra/control-devel/devel/LakeErieARX.m (rev 0) +++ trunk/octave-forge/extra/control-devel/devel/LakeErieARX.m 2012-05-19 08:39:04 UTC (rev 10464) @@ -0,0 +1,100 @@ +%{ +This file describes the data in the erie.dat file. +1. Contributed by: + Peter Van Overschee + K.U.Leuven - ESAT - SISTA + K. Mercierlaan 94 + 3001 Heverlee + Pet...@es... +2. Process/Description: + Data of a simulation (not real !) related to the related to the + identification of the western basin of Lake Erie. The series consists + of 4 series: + U_erie, Y_erie: without noise (original series) + U_erie_n10, Y_erie_n10: 10 percent additive white noise + U_erie_n20, Y_erie_n20: 20 percent additive white noise + U_erie_n30, Y_erie_n30: 30 percent additive white noise +3. Sampling time + 1 month +4. Number of samples: + 57 samples +5. Inputs: + a. water temperature + b. water conductivity + c. water alkalinity + d. NO3 + e. total hardness +6. Outputs: + a. dissolved oxigen + b. algae +7. References: + R.P. Guidorzi, M.P. Losito, T. Muratori, On the last eigenvalue + test in the structural identification of linear multivariable + systems, Proceedings of the V European meeting on cybernetics and + systems research, Vienna, april 1980. +8. Known properties/peculiarities + The considered period runs from march 1968 till november 1972. +9. Some MATLAB-code to retrieve the data + !guzip erie.dat.Z + load erie.dat + U=erie(:,1:20); + Y=erie(:,21:28); + U_erie=U(:,1:5); + U_erie_n10=U(:,6:10); + U_erie_n20=U(:,11:15); + U_erie_n30=U(:,16:20); + Y_erie=Y(:,1:2); + Y_erie_n10=Y(:,3:4); + Y_erie_n20=Y(:,5:6); + Y_erie_n30=Y(:,7:8); +%} + +clear all, close all, clc + +% DaISy code is wrong, +% first column is sample number +load erie.dat +U=erie(:,2:21); +Y=erie(:,22:29); +U_erie=U(:,1:5); +U_erie_n10=U(:,6:10); +U_erie_n20=U(:,11:15); +U_erie_n30=U(:,16:20); +Y_erie=Y(:,1:2); +Y_erie_n10=Y(:,3:4); +Y_erie_n20=Y(:,5:6); +Y_erie_n30=Y(:,7:8); + +Y = {Y_erie; Y_erie_n10; Y_erie_n20; Y_erie_n30}; +U = {U_erie; U_erie_n10; U_erie_n20; U_erie_n30}; + +dat = iddata (Y, U, [], 'inname', {'a. water temperature'; + 'b. water conductivity'; + 'c. water alkalinity'; + 'd. NO3'; + 'e. total hardness'}, \ + 'outname', {'a. dissolved oxygen'; + 'b. algae'}) + +[sys, x0] = ident (dat, 5, 4) % s=5, n=4 +sys2 = arx (dat, 4, 4) + +x0=x0{1}; + +[y, t] = lsim (sys, U_erie, [], x0); +[y2, t2] = lsim (sys2(:, 1:5), U_erie); + +err = norm (Y_erie - y, 1) / norm (Y_erie, 1) +err2 = norm (Y_erie - y2, 1) / norm (Y_erie, 1) + + +figure (1) +p = columns (Y_erie); +for k = 1 : p + subplot (2, 1, k) + plot (t, Y_erie(:,k), t, y(:,k), t, y2(:,k)) +endfor + +legend ('y measured', 'y MOEN4', 'y ARX', 'location', 'southeast') + + Modified: trunk/octave-forge/extra/control-devel/inst/arx.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/arx.m 2012-05-18 21:59:47 UTC (rev 10463) +++ trunk/octave-forge/extra/control-devel/inst/arx.m 2012-05-19 08:39:04 UTC (rev 10464) @@ -76,7 +76,7 @@ den = cell (p, m+1); for i = 1 : p # for every output - Phi = cell (1, ex); + Phi = cell (ex, 1); for e = 1 : ex # for every experiment ## avoid warning: toeplitz: column wins anti-diagonal conflict ## therefore set first row element equal to y(1) @@ -123,7 +123,7 @@ tmp = cellfun (@(Phi) Phi.' * Phi, phi, "uniformoutput", false); rc = cellfun (@rcond, tmp); # C auch noch testen? QR oder SVD? C = plus (tmp{:}); - + ## PhiTY = (Phi1' Y1 + Phi2' Y2 + ...) tmp = cellfun (@(Phi, Y) Phi.' * Y(n(i)+1:end, i), phi, y, "uniformoutput", false); PhiTY = plus (tmp{:}); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-05-18 22:54:00
|
Revision: 10462 http://octave.svn.sourceforge.net/octave/?rev=10462&view=rev Author: paramaniac Date: 2012-05-18 21:52:25 +0000 (Fri, 18 May 2012) Log Message: ----------- control-devel: yet another multi-experiment dataset Modified Paths: -------------- trunk/octave-forge/extra/control-devel/devel/ident.m Added Paths: ----------- trunk/octave-forge/extra/control-devel/devel/LakeErie.m trunk/octave-forge/extra/control-devel/devel/erie.dat Added: trunk/octave-forge/extra/control-devel/devel/LakeErie.m =================================================================== --- trunk/octave-forge/extra/control-devel/devel/LakeErie.m (rev 0) +++ trunk/octave-forge/extra/control-devel/devel/LakeErie.m 2012-05-18 21:52:25 UTC (rev 10462) @@ -0,0 +1,91 @@ +%{ +This file describes the data in the erie.dat file. +1. Contributed by: + Peter Van Overschee + K.U.Leuven - ESAT - SISTA + K. Mercierlaan 94 + 3001 Heverlee + Pet...@es... +2. Process/Description: + Data of a simulation (not real !) related to the related to the + identification of the western basin of Lake Erie. The series consists + of 4 series: + U_erie, Y_erie: without noise (original series) + U_erie_n10, Y_erie_n10: 10 percent additive white noise + U_erie_n20, Y_erie_n20: 20 percent additive white noise + U_erie_n30, Y_erie_n30: 30 percent additive white noise +3. Sampling time + 1 month +4. Number of samples: + 57 samples +5. Inputs: + a. water temperature + b. water conductivity + c. water alkalinity + d. NO3 + e. total hardness +6. Outputs: + a. dissolved oxigen + b. algae +7. References: + R.P. Guidorzi, M.P. Losito, T. Muratori, On the last eigenvalue + test in the structural identification of linear multivariable + systems, Proceedings of the V European meeting on cybernetics and + systems research, Vienna, april 1980. +8. Known properties/peculiarities + The considered period runs from march 1968 till november 1972. +9. Some MATLAB-code to retrieve the data + !guzip erie.dat.Z + load erie.dat + U=erie(:,1:20); + Y=erie(:,21:28); + U_erie=U(:,1:5); + U_erie_n10=U(:,6:10); + U_erie_n20=U(:,11:15); + U_erie_n30=U(:,16:20); + Y_erie=Y(:,1:2); + Y_erie_n10=Y(:,3:4); + Y_erie_n20=Y(:,5:6); + Y_erie_n30=Y(:,7:8); +%} + +clear all, close all, clc + +% DaISy code is wrong, +% first column is sample number +load erie.dat +U=erie(:,2:21); +Y=erie(:,22:29); +U_erie=U(:,1:5); +U_erie_n10=U(:,6:10); +U_erie_n20=U(:,11:15); +U_erie_n30=U(:,16:20); +Y_erie=Y(:,1:2); +Y_erie_n10=Y(:,3:4); +Y_erie_n20=Y(:,5:6); +Y_erie_n30=Y(:,7:8); + +Y = {Y_erie; Y_erie_n10; Y_erie_n20; Y_erie_n30}; +U = {U_erie; U_erie_n10; U_erie_n20; U_erie_n30}; + +dat = iddata (Y, U) + +[sys, x0] = ident (dat, 5, 4) % s=5, n=4 + +x0=x0{1}; + +[y, t] = lsim (sys, U_erie, [], x0); +%[y, t] = lsim (sys, U_erie); + +err = norm (Y_erie - y, 1) / norm (Y_erie, 1) + +figure (1) +p = columns (Y_erie); +for k = 1 : p + subplot (2, 1, k) + plot (t, Y_erie(:,k), 'b', t, y(:,k), 'r') +endfor + +legend ('y measured', 'y simulated', 'location', 'southeast') + + Added: trunk/octave-forge/extra/control-devel/devel/erie.dat =================================================================== --- trunk/octave-forge/extra/control-devel/devel/erie.dat (rev 0) +++ trunk/octave-forge/extra/control-devel/devel/erie.dat 2012-05-18 21:52:25 UTC (rev 10462) @@ -0,0 +1,57 @@ + 1.0000000e+00 3.7000000e+00 5.9000000e+02 1.4700000e+02 9.3000000e-01 2.6900000e+02 3.1145000e+00 5.8163000e+02 1.4701000e+02 9.5210000e-01 2.6958000e+02 2.5289000e+00 5.7326000e+02 1.4703000e+02 9.7420000e-01 2.7017000e+02 1.9434000e+00 5.6489000e+02 1.4704000e+02 9.9630000e-01 2.7075000e+02 1.5100000e+01 1.1001000e+04 1.5103000e+01 1.0820000e+04 1.5105000e+01 1.0638000e+04 1.5108000e+01 1.0457000e+04 + 2.0000000e+00 1.0300000e+01 3.5000000e+02 1.3600000e+02 8.9000000e-01 2.3700000e+02 9.0367000e+00 3.5832000e+02 1.3538000e+02 8.5518000e-01 2.3520000e+02 7.7735000e+00 3.6664000e+02 1.3476000e+02 8.2036000e-01 2.3340000e+02 6.5102000e+00 3.7496000e+02 1.3413000e+02 7.8554000e-01 2.3160000e+02 1.1700000e+01 6.8380000e+03 1.1908000e+01 6.6498000e+03 1.2116000e+01 6.4615000e+03 1.2324000e+01 6.2733000e+03 + 3.0000000e+00 1.2000000e+01 3.5400000e+02 1.3400000e+02 4.2000000e-01 2.3100000e+02 1.2261000e+01 3.4871000e+02 1.3458000e+02 4.7440000e-01 2.3327000e+02 1.2521000e+01 3.4342000e+02 1.3516000e+02 5.2880000e-01 2.3553000e+02 1.2782000e+01 3.3813000e+02 1.3574000e+02 5.8320000e-01 2.3780000e+02 9.2000000e+00 3.8830000e+03 9.3272000e+00 3.8519000e+03 9.4545000e+00 3.8208000e+03 9.5817000e+00 3.7897000e+03 + 4.0000000e+00 1.9300000e+01 3.3000000e+02 1.3900000e+02 5.3000000e-01 2.1700000e+02 1.6955000e+01 3.4008000e+02 1.3859000e+02 5.7118000e-01 2.1643000e+02 1.4609000e+01 3.5017000e+02 1.3817000e+02 6.1236000e-01 2.1586000e+02 1.2264000e+01 3.6025000e+02 1.3776000e+02 6.5354000e-01 2.1530000e+02 7.1821000e+00 4.2750000e+03 7.0040000e+00 4.4064000e+03 6.8260000e+00 4.5378000e+03 6.6480000e+00 4.6692000e+03 + 5.0000000e+00 2.2300000e+01 3.1200000e+02 9.9000000e+01 5.3000000e-01 1.4400000e+02 2.3995000e+01 3.1678000e+02 9.9816000e+01 5.7336000e-01 1.4049000e+02 2.5690000e+01 3.2156000e+02 1.0063000e+02 6.1673000e-01 1.3698000e+02 2.7385000e+01 3.2634000e+02 1.0145000e+02 6.6009000e-01 1.3347000e+02 6.3618000e+00 1.6240000e+03 6.1731000e+00 1.9356000e+03 5.9845000e+00 2.2472000e+03 5.7959000e+00 2.5588000e+03 + 6.0000000e+00 2.3900000e+01 3.0000000e+02 9.2000000e+01 1.9000000e-01 1.2600000e+02 2.3104000e+01 2.9823000e+02 8.8809000e+01 2.2017000e-01 1.2541000e+02 2.2309000e+01 2.9646000e+02 8.5617000e+01 2.5034000e-01 1.2482000e+02 2.1513000e+01 2.9469000e+02 8.2426000e+01 2.8051000e-01 1.2424000e+02 6.8801000e+00 2.2483000e+03 6.4963000e+00 1.9822000e+03 6.1125000e+00 1.7161000e+03 5.7287000e+00 1.4500000e+03 + 7.0000000e+00 2.0400000e+01 2.9000000e+02 9.3000000e+01 9.0000000e-02 1.2700000e+02 2.0538000e+01 2.8609000e+02 9.3713000e+01 8.9718000e-02 1.2683000e+02 2.0675000e+01 2.8218000e+02 9.4427000e+01 8.9437000e-02 1.2665000e+02 2.0813000e+01 2.7827000e+02 9.5140000e+01 8.9155000e-02 1.2648000e+02 6.8898000e+00 3.9738000e+03 6.8328000e+00 4.0152000e+03 6.7759000e+00 4.0566000e+03 6.7189000e+00 4.0981000e+03 + 8.0000000e+00 1.4600000e+01 3.0700000e+02 9.8000000e+01 1.6000000e-01 1.3400000e+02 1.5186000e+01 3.0894000e+02 9.7017000e+01 1.9783000e-01 1.3504000e+02 1.5771000e+01 3.1087000e+02 9.6035000e+01 2.3567000e-01 1.3609000e+02 1.6357000e+01 3.1281000e+02 9.5052000e+01 2.7350000e-01 1.3713000e+02 7.8991000e+00 2.0383000e+03 7.6782000e+00 2.4571000e+03 7.4573000e+00 2.8758000e+03 7.2363000e+00 3.2945000e+03 + 9.0000000e+00 7.5000000e+00 3.2800000e+02 1.0000000e+02 1.6000000e-01 1.3500000e+02 7.7212000e+00 3.3019000e+02 9.7981000e+01 1.8122000e-01 1.3467000e+02 7.9423000e+00 3.3238000e+02 9.5962000e+01 2.0243000e-01 1.3435000e+02 8.1635000e+00 3.3457000e+02 9.3943000e+01 2.2365000e-01 1.3402000e+02 1.0221000e+01 2.1588000e+03 9.9070000e+00 2.0836000e+03 9.5930000e+00 2.0084000e+03 9.2791000e+00 1.9333000e+03 + 1.0000000e+01 1.9000000e+00 3.2800000e+02 1.0200000e+02 3.4000000e-01 1.4100000e+02 1.1252000e+00 3.2008000e+02 1.0231000e+02 4.3967000e-01 1.3913000e+02 3.5037000e-01 3.1216000e+02 1.0263000e+02 5.3933000e-01 1.3726000e+02 -4.2445000e-01 3.0423000e+02 1.0294000e+02 6.3900000e-01 1.3539000e+02 1.2500000e+01 2.5214000e+03 1.2597000e+01 2.6088000e+03 1.2694000e+01 2.6963000e+03 1.2791000e+01 2.7837000e+03 + 1.1000000e+01 6.0000000e-01 3.2900000e+02 1.0100000e+02 1.8600000e+00 1.4500000e+02 8.9867000e-02 3.2403000e+02 1.0161000e+02 1.8850000e+00 1.4286000e+02 -4.2027000e-01 3.1906000e+02 1.0223000e+02 1.9099000e+00 1.4071000e+02 -9.3040000e-01 3.1409000e+02 1.0284000e+02 1.9349000e+00 1.3857000e+02 1.2840000e+01 1.0951000e+03 1.2839000e+01 1.5274000e+03 1.2838000e+01 1.9597000e+03 1.2837000e+01 2.3920000e+03 + 1.2000000e+01 7.0000000e-01 3.1700000e+02 9.4000000e+01 1.7900000e+00 1.3700000e+02 1.7621000e+00 3.2365000e+02 9.6855000e+01 1.7572000e+00 1.3005000e+02 2.8242000e+00 3.3031000e+02 9.9709000e+01 1.7243000e+00 1.2310000e+02 3.8863000e+00 3.3696000e+02 1.0256000e+02 1.6915000e+00 1.1615000e+02 1.2200000e+01 1.3970000e+03 1.2637000e+01 1.3155000e+03 1.3074000e+01 1.2340000e+03 1.3511000e+01 1.1525000e+03 + 1.3000000e+01 2.6000000e+00 3.3000000e+02 1.0000000e+02 3.0000000e-01 1.4100000e+02 2.8496000e+00 3.2963000e+02 1.0136000e+02 2.6840000e-01 1.3946000e+02 3.0992000e+00 3.2925000e+02 1.0272000e+02 2.3681000e-01 1.3792000e+02 3.3489000e+00 3.2888000e+02 1.0409000e+02 2.0521000e-01 1.3638000e+02 1.3079000e+01 5.8799000e+03 1.2661000e+01 5.9541000e+03 1.2244000e+01 6.0282000e+03 1.1826000e+01 6.1024000e+03 + 1.4000000e+01 8.0000000e+00 3.7100000e+02 1.0500000e+02 6.3000000e-01 1.6700000e+02 9.1160000e+00 3.7616000e+02 1.0339000e+02 5.3205000e-01 1.6664000e+02 1.0232000e+01 3.8132000e+02 1.0178000e+02 4.3410000e-01 1.6629000e+02 1.1348000e+01 3.8649000e+02 1.0017000e+02 3.3615000e-01 1.6593000e+02 1.0369000e+01 2.8351000e+03 1.0314000e+01 2.6667000e+03 1.0258000e+01 2.4983000e+03 1.0203000e+01 2.3299000e+03 + 1.5000000e+01 1.3700000e+01 3.6000000e+02 1.0600000e+02 2.5000000e-01 1.6500000e+02 1.4034000e+01 3.5580000e+02 1.0711000e+02 1.8465000e-01 1.6580000e+02 1.4368000e+01 3.5160000e+02 1.0823000e+02 1.1931000e-01 1.6660000e+02 1.4702000e+01 3.4741000e+02 1.0934000e+02 5.3964000e-02 1.6740000e+02 7.9369000e+00 2.1869000e+03 7.9194000e+00 2.2512000e+03 7.9019000e+00 2.3155000e+03 7.8844000e+00 2.3798000e+03 + 1.6000000e+01 1.8200000e+01 3.3300000e+02 1.0500000e+02 1.6000000e-01 1.5800000e+02 1.8374000e+01 3.2893000e+02 1.0377000e+02 1.4351000e-01 1.5721000e+02 1.8547000e+01 3.2485000e+02 1.0253000e+02 1.2702000e-01 1.5642000e+02 1.8721000e+01 3.2078000e+02 1.0130000e+02 1.1052000e-01 1.5564000e+02 6.9197000e+00 2.6760000e+03 6.9202000e+00 2.7458000e+03 6.9207000e+00 2.8155000e+03 6.9212000e+00 2.8852000e+03 + 1.7000000e+01 2.3100000e+01 3.4100000e+02 1.0600000e+02 6.0000000e-01 1.5500000e+02 2.3337000e+01 3.3886000e+02 1.0515000e+02 5.5670000e-01 1.5007000e+02 2.3574000e+01 3.3672000e+02 1.0429000e+02 5.1341000e-01 1.4515000e+02 2.3811000e+01 3.3458000e+02 1.0344000e+02 4.7012000e-01 1.4022000e+02 6.0534000e+00 6.5367000e+02 6.1792000e+00 4.5818000e+02 6.3049000e+00 2.6269000e+02 6.4306000e+00 6.7195000e+01 + 1.8000000e+01 2.4400000e+01 3.1700000e+02 9.6000000e+01 1.5000000e-01 1.3700000e+02 2.5773000e+01 3.2141000e+02 9.6602000e+01 1.7375000e-01 1.3417000e+02 2.7147000e+01 3.2583000e+02 9.7203000e+01 1.9751000e-01 1.3134000e+02 2.8520000e+01 3.3024000e+02 9.7805000e+01 2.2126000e-01 1.2851000e+02 5.6118000e+00 1.2498000e+03 5.6473000e+00 9.6790000e+02 5.6827000e+00 6.8599000e+02 5.7181000e+00 4.0408000e+02 + 1.9000000e+01 2.0600000e+01 2.8600000e+02 8.2000000e+01 8.0000000e-02 1.2300000e+02 2.0243000e+01 2.7550000e+02 8.1172000e+01 3.7005000e-03 1.2453000e+02 1.9885000e+01 2.6500000e+02 8.0343000e+01 -7.2599000e-02 1.2606000e+02 1.9528000e+01 2.5450000e+02 7.9515000e+01 -1.4890000e-01 1.2759000e+02 5.9670000e+00 1.9248000e+03 5.7545000e+00 1.8157000e+03 5.5421000e+00 1.7067000e+03 5.3297000e+00 1.5976000e+03 + 2.0000000e+01 1.4100000e+01 3.7000000e+02 9.0000000e+01 2.0000000e-01 1.2600000e+02 1.3765000e+01 3.7158000e+02 8.9533000e+01 1.6860000e-01 1.2957000e+02 1.3431000e+01 3.7317000e+02 8.9066000e+01 1.3720000e-01 1.3315000e+02 1.3096000e+01 3.7475000e+02 8.8598000e+01 1.0581000e-01 1.3672000e+02 7.5455000e+00 1.4240000e+03 7.2517000e+00 1.6983000e+03 6.9578000e+00 1.9726000e+03 6.6640000e+00 2.2469000e+03 + 2.1000000e+01 7.0000000e+00 4.0600000e+02 9.0000000e+01 2.8000000e-01 1.3100000e+02 7.3473000e+00 4.0357000e+02 8.9741000e+01 3.0234000e-01 1.3288000e+02 7.6945000e+00 4.0115000e+02 8.9482000e+01 3.2468000e-01 1.3475000e+02 8.0418000e+00 3.9872000e+02 8.9223000e+01 3.4702000e-01 1.3663000e+02 8.9543000e+00 3.3762000e+02 8.5805000e+00 5.5835000e+02 8.2067000e+00 7.7908000e+02 7.8329000e+00 9.9981000e+02 + 2.2000000e+01 1.0000000e+00 3.2800000e+02 9.6000000e+01 3.8000000e-01 1.4200000e+02 8.4949000e-01 3.2930000e+02 9.5490000e+01 3.4574000e-01 1.3899000e+02 6.9898000e-01 3.3061000e+02 9.4980000e+01 3.1149000e-01 1.3598000e+02 5.4847000e-01 3.3191000e+02 9.4470000e+01 2.7723000e-01 1.3297000e+02 1.1534000e+01 1.5653000e+03 1.1704000e+01 1.7501000e+03 1.1874000e+01 1.9350000e+03 1.2044000e+01 2.1198000e+03 + 2.3000000e+01 9.0000000e-01 3.4300000e+02 1.0000000e+02 5.1000000e-01 1.4300000e+02 1.7834000e+00 3.3280000e+02 9.9195000e+01 5.7671000e-01 1.4450000e+02 2.6668000e+00 3.2260000e+02 9.8391000e+01 6.4342000e-01 1.4600000e+02 3.5501000e+00 3.1240000e+02 9.7586000e+01 7.1013000e-01 1.4749000e+02 1.1803000e+01 1.2296000e+03 1.1819000e+01 1.2381000e+03 1.1836000e+01 1.2466000e+03 1.1853000e+01 1.2551000e+03 + 2.4000000e+01 1.1000000e+00 4.6500000e+02 1.1800000e+02 1.7600000e+00 1.9100000e+02 2.0522000e+00 4.6886000e+02 1.1714000e+02 1.7622000e+00 1.9036000e+02 3.0044000e+00 4.7272000e+02 1.1629000e+02 1.7643000e+00 1.8972000e+02 3.9566000e+00 4.7658000e+02 1.1543000e+02 1.7665000e+00 1.8908000e+02 1.2029000e+01 1.4752000e+02 1.1823000e+01 3.4673000e+01 1.1618000e+01 -7.8174000e+01 1.1412000e+01 -1.9102000e+02 + 2.5000000e+01 1.4000000e+00 3.6900000e+02 1.0200000e+02 2.6000000e-01 1.5700000e+02 3.5949000e+00 3.7613000e+02 1.0328000e+02 2.5764000e-01 1.6118000e+02 5.7898000e+00 3.8325000e+02 1.0456000e+02 2.5529000e-01 1.6537000e+02 7.9847000e+00 3.9038000e+02 1.0584000e+02 2.5293000e-01 1.6955000e+02 1.3116000e+01 4.6427000e+03 1.3049000e+01 4.4656000e+03 1.2982000e+01 4.2885000e+03 1.2915000e+01 4.1115000e+03 + 2.6000000e+01 6.9000000e+00 3.7600000e+02 1.0300000e+02 2.4000000e-01 1.6300000e+02 6.3879000e+00 3.8035000e+02 1.0197000e+02 2.3131000e-01 1.5902000e+02 5.8758000e+00 3.8470000e+02 1.0095000e+02 2.2261000e-01 1.5505000e+02 5.3638000e+00 3.8905000e+02 9.9922000e+01 2.1392000e-01 1.5107000e+02 1.1029000e+01 2.1075000e+03 1.1514000e+01 2.0658000e+03 1.1999000e+01 2.0240000e+03 1.2484000e+01 1.9823000e+03 + 2.7000000e+01 1.4900000e+01 3.2900000e+02 1.0000000e+02 8.0000000e-02 1.4700000e+02 1.4677000e+01 3.3070000e+02 9.9671000e+01 2.0175000e-02 1.4834000e+02 1.4454000e+01 3.3239000e+02 9.9342000e+01 -3.9651000e-02 1.4967000e+02 1.4230000e+01 3.3409000e+02 9.9013000e+01 -9.9476000e-02 1.5101000e+02 7.1788000e+00 2.6251000e+03 7.0070000e+00 2.5547000e+03 6.8351000e+00 2.4842000e+03 6.6632000e+00 2.4137000e+03 + 2.8000000e+01 1.9000000e+01 3.5600000e+02 9.9000000e+01 1.7000000e-01 1.4000000e+02 1.9134000e+01 3.5501000e+02 9.8714000e+01 1.7646000e-01 1.3522000e+02 1.9268000e+01 3.5402000e+02 9.8429000e+01 1.8292000e-01 1.3043000e+02 1.9403000e+01 3.5303000e+02 9.8143000e+01 1.8938000e-01 1.2565000e+02 6.9445000e+00 2.9250000e+03 7.0012000e+00 2.9022000e+03 7.0579000e+00 2.8793000e+03 7.1147000e+00 2.8565000e+03 + 2.9000000e+01 2.3200000e+01 3.1500000e+02 9.8000000e+01 3.1000000e-01 1.3100000e+02 2.4716000e+01 3.2129000e+02 9.7262000e+01 4.0496000e-01 1.2767000e+02 2.6232000e+01 3.2759000e+02 9.6523000e+01 4.9992000e-01 1.2434000e+02 2.7748000e+01 3.3388000e+02 9.5785000e+01 5.9488000e-01 1.2101000e+02 6.6144000e+00 2.0644000e+03 6.8971000e+00 2.2495000e+03 7.1798000e+00 2.4347000e+03 7.4624000e+00 2.6198000e+03 + 3.0000000e+01 2.4400000e+01 3.0400000e+02 9.2000000e+01 2.4000000e-01 1.2700000e+02 2.4326000e+01 3.0146000e+02 9.3074000e+01 2.0664000e-01 1.2688000e+02 2.4252000e+01 2.9893000e+02 9.4147000e+01 1.7327000e-01 1.2676000e+02 2.4178000e+01 2.9639000e+02 9.5221000e+01 1.3991000e-01 1.2664000e+02 5.4806000e+00 9.1526000e+02 6.2731000e+00 1.3864000e+03 7.0656000e+00 1.8576000e+03 7.8581000e+00 2.3287000e+03 + 3.1000000e+01 2.1000000e+01 2.9000000e+02 8.9000000e+01 3.8000000e-01 1.2400000e+02 2.1877000e+01 2.7681000e+02 9.1331000e+01 3.8685000e-01 1.2318000e+02 2.2755000e+01 2.6362000e+02 9.3663000e+01 3.9371000e-01 1.2236000e+02 2.3632000e+01 2.5042000e+02 9.5994000e+01 4.0056000e-01 1.2153000e+02 5.9610000e+00 2.1883000e+03 5.8529000e+00 1.9707000e+03 5.7448000e+00 1.7531000e+03 5.6367000e+00 1.5355000e+03 + 3.2000000e+01 1.4900000e+01 3.2700000e+02 9.7000000e+01 2.5000000e-01 1.2900000e+02 1.4088000e+01 3.2207000e+02 9.8103000e+01 3.1933000e-01 1.3091000e+02 1.3276000e+01 3.1713000e+02 9.9206000e+01 3.8866000e-01 1.3281000e+02 1.2463000e+01 3.1220000e+02 1.0031000e+02 4.5798000e-01 1.3472000e+02 7.8417000e+00 1.6283000e+03 8.0381000e+00 1.8826000e+03 8.2344000e+00 2.1368000e+03 8.4307000e+00 2.3911000e+03 + 3.3000000e+01 8.6000000e+00 3.0900000e+02 9.2000000e+01 2.7000000e-01 1.2400000e+02 7.5296000e+00 3.0602000e+02 9.2000000e+01 2.6647000e-01 1.2107000e+02 6.4592000e+00 3.0305000e+02 9.1999000e+01 2.6293000e-01 1.1813000e+02 5.3889000e+00 3.0007000e+02 9.1999000e+01 2.5940000e-01 1.1520000e+02 9.3533000e+00 1.3699000e+03 9.0012000e+00 1.5334000e+03 8.6492000e+00 1.6969000e+03 8.2971000e+00 1.8604000e+03 + 3.4000000e+01 2.5000000e+00 3.4000000e+02 1.0100000e+02 9.2000000e-01 1.5100000e+02 1.9609000e+00 3.4210000e+02 1.0205000e+02 9.3354000e-01 1.5565000e+02 1.4217000e+00 3.4420000e+02 1.0310000e+02 9.4707000e-01 1.6029000e+02 8.8262000e-01 3.4630000e+02 1.0416000e+02 9.6061000e-01 1.6494000e+02 1.1552000e+01 8.9206000e+02 1.1038000e+01 9.3857000e+02 1.0525000e+01 9.8508000e+02 1.0011000e+01 1.0316000e+03 + 3.5000000e+01 7.0000000e-01 3.1900000e+02 1.0000000e+02 6.1000000e-01 1.4100000e+02 1.8211000e+00 3.1137000e+02 1.0064000e+02 4.9515000e-01 1.3664000e+02 2.9423000e+00 3.0374000e+02 1.0128000e+02 3.8031000e-01 1.3228000e+02 4.0634000e+00 2.9611000e+02 1.0192000e+02 2.6546000e-01 1.2791000e+02 1.2692000e+01 2.9209000e+03 1.2729000e+01 2.8396000e+03 1.2766000e+01 2.7584000e+03 1.2804000e+01 2.6771000e+03 + 3.6000000e+01 5.0000000e-01 2.7100000e+02 8.5000000e+01 4.2000000e-01 1.2000000e+02 1.7151000e+00 2.7264000e+02 8.3098000e+01 4.3534000e-01 1.1958000e+02 2.9302000e+00 2.7428000e+02 8.1196000e+01 4.5067000e-01 1.1915000e+02 4.1453000e+00 2.7592000e+02 7.9294000e+01 4.6601000e-01 1.1873000e+02 1.1847000e+01 2.9915000e+03 1.1940000e+01 3.1021000e+03 1.2034000e+01 3.2127000e+03 1.2127000e+01 3.3232000e+03 + 3.7000000e+01 1.7000000e+00 3.1700000e+02 8.9000000e+01 1.3900000e+00 1.3800000e+02 3.6014000e+00 3.1296000e+02 8.8728000e+01 1.4214000e+00 1.3702000e+02 5.5029000e+00 3.0892000e+02 8.8455000e+01 1.4529000e+00 1.3604000e+02 7.4043000e+00 3.0487000e+02 8.8183000e+01 1.4843000e+00 1.3506000e+02 1.0925000e+01 2.2067000e+03 1.0866000e+01 2.4495000e+03 1.0806000e+01 2.6923000e+03 1.0746000e+01 2.9350000e+03 + 3.8000000e+01 7.1000000e+00 3.3100000e+02 9.9000000e+01 7.6000000e-01 1.4900000e+02 7.0039000e+00 3.2940000e+02 1.0032000e+02 8.1783000e-01 1.5307000e+02 6.9079000e+00 3.2780000e+02 1.0164000e+02 8.7566000e-01 1.5714000e+02 6.8118000e+00 3.2620000e+02 1.0296000e+02 9.3349000e-01 1.6121000e+02 1.0162000e+01 2.9916000e+03 9.9607000e+00 3.1980000e+03 9.7595000e+00 3.4044000e+03 9.5583000e+00 3.6108000e+03 + 3.9000000e+01 1.3500000e+01 3.0200000e+02 9.2000000e+01 8.1000000e-01 1.3500000e+02 1.3351000e+01 2.9856000e+02 9.4486000e+01 8.0669000e-01 1.3633000e+02 1.3203000e+01 2.9511000e+02 9.6972000e+01 8.0337000e-01 1.3766000e+02 1.3054000e+01 2.9167000e+02 9.9457000e+01 8.0006000e-01 1.3898000e+02 8.2172000e+00 2.9508000e+03 8.7254000e+00 2.9032000e+03 9.2336000e+00 2.8556000e+03 9.7418000e+00 2.8080000e+03 + 4.0000000e+01 2.0200000e+01 3.2200000e+02 9.2000000e+01 6.9000000e-01 1.3900000e+02 2.1094000e+01 3.3126000e+02 9.3353000e+01 6.6806000e-01 1.3950000e+02 2.1987000e+01 3.4053000e+02 9.4707000e+01 6.4612000e-01 1.4000000e+02 2.2881000e+01 3.4979000e+02 9.6060000e+01 6.2418000e-01 1.4051000e+02 5.4001000e+00 1.8132000e+02 5.5019000e+00 4.3807000e+02 5.6036000e+00 6.9482000e+02 5.7053000e+00 9.5157000e+02 + 4.1000000e+01 2.3600000e+01 3.0500000e+02 9.3000000e+01 3.0000000e-01 1.2800000e+02 2.2760000e+01 3.1011000e+02 9.4742000e+01 3.0167000e-01 1.3164000e+02 2.1919000e+01 3.1521000e+02 9.6483000e+01 3.0335000e-01 1.3527000e+02 2.1079000e+01 3.2032000e+02 9.8225000e+01 3.0502000e-01 1.3891000e+02 4.9960000e+00 3.1067000e+03 4.5675000e+00 2.9019000e+03 4.1390000e+00 2.6971000e+03 3.7105000e+00 2.4922000e+03 + 4.2000000e+01 2.2700000e+01 2.9000000e+02 9.0000000e+01 3.0000000e-02 1.2300000e+02 2.2709000e+01 2.8488000e+02 8.8976000e+01 -5.7520000e-02 1.1924000e+02 2.2718000e+01 2.7975000e+02 8.7953000e+01 -1.4504000e-01 1.1548000e+02 2.2727000e+01 2.7463000e+02 8.6929000e+01 -2.3256000e-01 1.1171000e+02 4.6419000e+00 1.0570000e+03 4.8364000e+00 1.1669000e+03 5.0310000e+00 1.2768000e+03 5.2255000e+00 1.3866000e+03 + 4.3000000e+01 2.0600000e+01 3.0400000e+02 9.1000000e+01 2.0000000e-02 1.2400000e+02 1.9255000e+01 2.9501000e+02 8.9534000e+01 4.0403000e-02 1.2159000e+02 1.7909000e+01 2.8602000e+02 8.8067000e+01 6.0806000e-02 1.1918000e+02 1.6564000e+01 2.7704000e+02 8.6601000e+01 8.1210000e-02 1.1677000e+02 5.5997000e+00 8.3792000e+02 5.4847000e+00 1.0612000e+03 5.3697000e+00 1.2845000e+03 5.2547000e+00 1.5078000e+03 + 4.4000000e+01 1.6900000e+01 2.9900000e+02 8.8000000e+01 1.0000000e-02 1.2100000e+02 1.6137000e+01 2.8608000e+02 8.7776000e+01 -5.7846000e-02 1.2497000e+02 1.5373000e+01 2.7317000e+02 8.7552000e+01 -1.2569000e-01 1.2894000e+02 1.4610000e+01 2.6025000e+02 8.7328000e+01 -1.9354000e-01 1.3292000e+02 6.8143000e+00 9.8747000e+02 6.5831000e+00 1.2349000e+03 6.3520000e+00 1.4824000e+03 6.1208000e+00 1.7299000e+03 + 4.5000000e+01 9.6000000e+00 2.9000000e+02 9.1000000e+01 1.8000000e-01 1.2600000e+02 1.1597000e+01 2.8840000e+02 8.9274000e+01 2.1845000e-01 1.3112000e+02 1.3594000e+01 2.8681000e+02 8.7548000e+01 2.5690000e-01 1.3624000e+02 1.5591000e+01 2.8521000e+02 8.5821000e+01 2.9535000e-01 1.4136000e+02 8.8926000e+00 1.8587000e+03 9.0529000e+00 1.9118000e+03 9.2131000e+00 1.9649000e+03 9.3733000e+00 2.0179000e+03 + 4.6000000e+01 3.2000000e+00 3.3000000e+02 8.9000000e+01 2.2000000e-01 1.3100000e+02 3.3971000e+00 3.2025000e+02 8.8500000e+01 2.3910000e-01 1.2937000e+02 3.5942000e+00 3.1049000e+02 8.8000000e+01 2.5820000e-01 1.2774000e+02 3.7913000e+00 3.0074000e+02 8.7500000e+01 2.7730000e-01 1.2611000e+02 1.0658000e+01 1.3863000e+03 1.0901000e+01 1.6101000e+03 1.1145000e+01 1.8338000e+03 1.1388000e+01 2.0575000e+03 + 4.7000000e+01 7.0000000e-01 3.3500000e+02 9.6000000e+01 2.6000000e-01 1.4900000e+02 5.0913000e-01 3.3862000e+02 9.6497000e+01 3.1548000e-01 1.5242000e+02 3.1826000e-01 3.4224000e+02 9.6994000e+01 3.7096000e-01 1.5584000e+02 1.2739000e-01 3.4585000e+02 9.7491000e+01 4.2643000e-01 1.5926000e+02 1.2199000e+01 2.0399000e+03 1.1942000e+01 1.9097000e+03 1.1685000e+01 1.7795000e+03 1.1428000e+01 1.6493000e+03 + 4.8000000e+01 8.0000000e-01 4.2000000e+02 9.8000000e+01 1.0600000e+00 1.5500000e+02 9.0429000e-01 4.1227000e+02 9.7193000e+01 1.0897000e+00 1.5279000e+02 1.0086000e+00 4.0453000e+02 9.6386000e+01 1.1194000e+00 1.5058000e+02 1.1129000e+00 3.9680000e+02 9.5579000e+01 1.1490000e+00 1.4837000e+02 1.2299000e+01 1.5762000e+03 1.1776000e+01 1.6418000e+03 1.1253000e+01 1.7073000e+03 1.0729000e+01 1.7729000e+03 + 4.9000000e+01 1.9000000e+00 3.2500000e+02 9.1000000e+01 7.3000000e-01 1.4300000e+02 1.0020000e+00 3.3190000e+02 8.9819000e+01 6.6673000e-01 1.4271000e+02 1.0403000e-01 3.3880000e+02 8.8639000e+01 6.0347000e-01 1.4242000e+02 -7.9396000e-01 3.4570000e+02 8.7458000e+01 5.4020000e-01 1.4214000e+02 1.0758000e+01 1.8956000e+03 1.1623000e+01 1.6330000e+03 1.2488000e+01 1.3704000e+03 1.3353000e+01 1.1078000e+03 + 5.0000000e+01 7.7000000e+00 3.9100000e+02 1.0000000e+02 1.3200000e+00 1.7200000e+02 7.3008000e+00 3.9338000e+02 9.9201000e+01 1.2141000e+00 1.7078000e+02 6.9015000e+00 3.9576000e+02 9.8402000e+01 1.1081000e+00 1.6957000e+02 6.5023000e+00 3.9815000e+02 9.7603000e+01 1.0022000e+00 1.6835000e+02 9.7454000e+00 5.2948000e+02 9.3058000e+00 2.3864000e+02 8.8661000e+00 -5.2197000e+01 8.4265000e+00 -3.4304000e+02 + 5.1000000e+01 1.4800000e+01 4.9700000e+02 1.0200000e+02 2.0100000e+00 1.6400000e+02 1.4854000e+01 5.0175000e+02 1.0204000e+02 1.9939000e+00 1.6173000e+02 1.4907000e+01 5.0651000e+02 1.0207000e+02 1.9779000e+00 1.5946000e+02 1.4961000e+01 5.1126000e+02 1.0211000e+02 1.9618000e+00 1.5720000e+02 7.7542000e+00 2.1092000e+02 7.4406000e+00 1.6812000e+02 7.1271000e+00 1.2531000e+02 6.8135000e+00 8.2509000e+01 + 5.2000000e+01 1.9100000e+01 3.7000000e+02 1.0000000e+02 1.0700000e+00 1.5200000e+02 1.9086000e+01 3.7169000e+02 1.0033000e+02 1.0895000e+00 1.4986000e+02 1.9071000e+01 3.7338000e+02 1.0066000e+02 1.1090000e+00 1.4771000e+02 1.9057000e+01 3.7506000e+02 1.0100000e+02 1.1285000e+00 1.4557000e+02 5.3767000e+00 -2.5834000e+02 5.4049000e+00 -1.1028000e+02 5.4331000e+00 3.7790000e+01 5.4613000e+00 1.8585000e+02 + 5.3000000e+01 2.1900000e+01 3.2400000e+02 9.4000000e+01 8.0000000e-02 1.3900000e+02 2.1301000e+01 3.2326000e+02 9.3173000e+01 1.1597000e-01 1.3890000e+02 2.0702000e+01 3.2252000e+02 9.2347000e+01 1.5194000e-01 1.3880000e+02 2.0102000e+01 3.2178000e+02 9.1520000e+01 1.8792000e-01 1.3870000e+02 4.8905000e+00 1.4666000e+03 4.7310000e+00 1.4452000e+03 4.5714000e+00 1.4237000e+03 4.4119000e+00 1.4023000e+03 + 5.4000000e+01 2.2200000e+01 3.0800000e+02 9.5000000e+01 1.0000000e-01 1.3700000e+02 2.0978000e+01 3.1130000e+02 9.4547000e+01 3.9649000e-02 1.3627000e+02 1.9756000e+01 3.1459000e+02 9.4094000e+01 -2.0702000e-02 1.3554000e+02 1.8535000e+01 3.1789000e+02 9.3641000e+01 -8.1054000e-02 1.3481000e+02 3.4676000e+00 3.5761000e+02 3.2257000e+00 1.8213000e+02 2.9838000e+00 6.6555000e+00 2.7420000e+00 -1.6882000e+02 + 5.5000000e+01 2.0500000e+01 3.0700000e+02 8.7000000e+01 1.0000000e-01 1.2700000e+02 2.1131000e+01 3.1003000e+02 8.6635000e+01 3.7252000e-02 1.2554000e+02 2.1761000e+01 3.1307000e+02 8.6271000e+01 -2.5496000e-02 1.2408000e+02 2.2392000e+01 3.1610000e+02 8.5906000e+01 -8.8244000e-02 1.2262000e+02 3.8646000e+00 -7.0276000e+02 3.4459000e+00 -9.3373000e+02 3.0273000e+00 -1.1647000e+03 2.6086000e+00 -1.3957000e+03 + 5.6000000e+01 1.3000000e+01 3.6200000e+02 1.1100000e+02 2.0000000e-01 1.6500000e+02 1.3693000e+01 3.6783000e+02 1.1214000e+02 2.5013000e-01 1.6998000e+02 1.4386000e+01 3.7366000e+02 1.1329000e+02 3.0025000e-01 1.7495000e+02 1.5080000e+01 3.7950000e+02 1.1443000e+02 3.5038000e-01 1.7993000e+02 8.1236000e+00 1.2863000e+03 8.0351000e+00 1.4553000e+03 7.9465000e+00 1.6243000e+03 7.8579000e+00 1.7934000e+03 + 5.7000000e+01 7.0000000e+00 3.4700000e+02 1.0700000e+02 1.1500000e+00 1.6100000e+02 7.2496000e+00 3.4432000e+02 1.0703000e+02 1.1775000e+00 1.6111000e+02 7.4993000e+00 3.4164000e+02 1.0706000e+02 1.2049000e+00 1.6122000e+02 7.7489000e+00 3.3897000e+02 1.0708000e+02 1.2324000e+00 1.6133000e+02 9.7466000e+00 -6.3451000e+00 9.5681000e+00 3.0895000e+02 9.3897000e+00 6.2424000e+02 9.2112000e+00 9.3954000e+02 Modified: trunk/octave-forge/extra/control-devel/devel/ident.m =================================================================== --- trunk/octave-forge/extra/control-devel/devel/ident.m 2012-05-18 20:51:39 UTC (rev 10461) +++ trunk/octave-forge/extra/control-devel/devel/ident.m 2012-05-18 21:52:25 UTC (rev 10462) @@ -33,7 +33,7 @@ nsmp = ns(1); nobr = fix ((nsmp+1)/(2*(m+l+1))); if (s > nobr) - error ("ident: s > nobr"); + warning ("ident: s > nobr"); endif nobr = s; ctrl = 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-05-18 22:53:54
|
Revision: 10463 http://octave.svn.sourceforge.net/octave/?rev=10463&view=rev Author: paramaniac Date: 2012-05-18 21:59:47 +0000 (Fri, 18 May 2012) Log Message: ----------- control-devel: add i/o names Modified Paths: -------------- trunk/octave-forge/extra/control-devel/devel/LakeErie.m Modified: trunk/octave-forge/extra/control-devel/devel/LakeErie.m =================================================================== --- trunk/octave-forge/extra/control-devel/devel/LakeErie.m 2012-05-18 21:52:25 UTC (rev 10462) +++ trunk/octave-forge/extra/control-devel/devel/LakeErie.m 2012-05-18 21:59:47 UTC (rev 10463) @@ -68,7 +68,13 @@ Y = {Y_erie; Y_erie_n10; Y_erie_n20; Y_erie_n30}; U = {U_erie; U_erie_n10; U_erie_n20; U_erie_n30}; -dat = iddata (Y, U) +dat = iddata (Y, U, [], 'inname', {'a. water temperature'; + 'b. water conductivity'; + 'c. water alkalinity'; + 'd. NO3'; + 'e. total hardness'}, \ + 'outname', {'a. dissolved oxygen'; + 'b. algae'}) [sys, x0] = ident (dat, 5, 4) % s=5, n=4 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-05-18 20:51:45
|
Revision: 10461 http://octave.svn.sourceforge.net/octave/?rev=10461&view=rev Author: paramaniac Date: 2012-05-18 20:51:39 +0000 (Fri, 18 May 2012) Log Message: ----------- control-devel: multi-experiment identification seems to work :-) Added Paths: ----------- trunk/octave-forge/extra/control-devel/devel/DestillationME.m Added: trunk/octave-forge/extra/control-devel/devel/DestillationME.m =================================================================== --- trunk/octave-forge/extra/control-devel/devel/DestillationME.m (rev 0) +++ trunk/octave-forge/extra/control-devel/devel/DestillationME.m 2012-05-18 20:51:39 UTC (rev 10461) @@ -0,0 +1,88 @@ +%{ +This file describes the data in the destill.dat file. +1. Contributed by: + Peter Van Overschee + K.U.Leuven - ESAT - SISTA + K. Mercierlaan 94 + 3001 Heverlee + Pet...@es... +2. Process/Description: + Data of a simulation (not real !) related to the identification + of an ethane-ethylene destillationcolumn. The series consists of 4 + series: + U_dest, Y_dest: without noise (original series) + U_dest_n10, Y_dest_n10: 10 percent additive white noise + U_dest_n20, Y_dest_n20: 20 percent additive white noise + U_dest_n30, Y_dest_n30: 30 percent additive white noise +3. Sampling time + 15 min. +4. Number of samples: + 90 samples +5. Inputs: + a. ratio between the reboiler duty and the feed flow + b. ratio between the reflux rate and the feed flow + c. ratio between the distillate and the feed flow + d. input ethane composition + e. top pressure +6. Outputs: + a. top ethane composition + b. bottom ethylene composition + c. top-bottom differential pressure. +7. References: + R.P. Guidorzi, M.P. Losito, T. Muratori, The range error test in the + structural identification of linear multivariable systems, + IEEE transactions on automatic control, Vol AC-27, pp 1044-1054, oct. + 1982. +8. Known properties/peculiarities + +9. Some MATLAB-code to retrieve the data + !gunzip destill.dat.Z + load destill.dat + U=destill(:,1:20); + Y=destill(:,21:32); + U_dest=U(:,1:5); + U_dest_n10=U(:,6:10); + U_dest_n20=U(:,11:15); + U_dest_n30=U(:,16:20); + Y_dest=Y(:,1:3); + Y_dest_n10=Y(:,4:6); + Y_dest_n20=Y(:,7:9); + Y_dest_n30=Y(:,10:12); +%} + +clear all, close all, clc + +% DaISy code is wrong, +% first column is sample number +load destill.dat +U=destill(:,2:21); +Y=destill(:,22:33); +U_dest=U(:,1:5); +U_dest_n10=U(:,6:10); +U_dest_n20=U(:,11:15); +U_dest_n30=U(:,16:20); +Y_dest=Y(:,1:3); +Y_dest_n10=Y(:,4:6); +Y_dest_n20=Y(:,7:9); +Y_dest_n30=Y(:,10:12); + +Y = {Y_dest; Y_dest_n10; Y_dest_n20; Y_dest_n30}; +U = {U_dest; U_dest_n10; U_dest_n20; U_dest_n30}; + +dat = iddata (Y, U) + +[sys, x0] = ident (dat, 5, 4) % s=5, n=4 + +x0=x0{1}; + +[y, t] = lsim (sys, U_dest, [], x0); +%[y, t] = lsim (sys, U_dest); + +err = norm (Y_dest - y, 1) / norm (Y_dest, 1) + +figure (1) +%plot (t, Y_dest, 'b') +plot (t, Y_dest, 'b', t, y, 'r') +legend ('y measured', 'y simulated', 'location', 'southeast') + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-05-18 20:40:02
|
Revision: 10460 http://octave.svn.sourceforge.net/octave/?rev=10460&view=rev Author: paramaniac Date: 2012-05-18 20:39:56 +0000 (Fri, 18 May 2012) Log Message: ----------- control-devel: remove obsolete variables Modified Paths: -------------- trunk/octave-forge/extra/control-devel/devel/ident.m trunk/octave-forge/extra/control-devel/devel/ident_combinations.m trunk/octave-forge/extra/control-devel/inst/__slicot_identification__.m trunk/octave-forge/extra/control-devel/src/slident.cc Modified: trunk/octave-forge/extra/control-devel/devel/ident.m =================================================================== --- trunk/octave-forge/extra/control-devel/devel/ident.m 2012-05-18 20:25:34 UTC (rev 10459) +++ trunk/octave-forge/extra/control-devel/devel/ident.m 2012-05-18 20:39:56 UTC (rev 10460) @@ -5,7 +5,6 @@ %nobr = 15; meth = 2; % 2 % geht: meth/alg 1/1, alg = 0; % 0 % geht nicht: meth/alg 0/1 - batch = 3; conct = 1; ctrl = 0; %1; rcond = 0.0; @@ -46,7 +45,7 @@ % nsmp >= 2*(m+l+1)*nobr - 1 % nobr <= (nsmp+1)/(2*(m+l+1)) %nobr = 10 - [a, b, c, d, q, ry, s, k, x0] = slident (dat.y, dat.u, nobr, n, meth, alg, batch, conct, ctrl, rcond, tol); + [a, b, c, d, q, ry, s, k, x0] = slident (dat.y, dat.u, nobr, n, meth, alg, conct, ctrl, rcond, tol); sys = ss (a, b, c, d, dat.tsam{1}); Modified: trunk/octave-forge/extra/control-devel/devel/ident_combinations.m =================================================================== --- trunk/octave-forge/extra/control-devel/devel/ident_combinations.m 2012-05-18 20:25:34 UTC (rev 10459) +++ trunk/octave-forge/extra/control-devel/devel/ident_combinations.m 2012-05-18 20:39:56 UTC (rev 10460) @@ -5,7 +5,6 @@ %nobr = 15; % meth = 1; % 2 % geht: meth/alg 1/1, % alg = 2; % 0 % geht nicht: meth/alg 0/1 - batch = 3; conct = 1; ctrl = 0; %1; rcond = 0.0; @@ -41,13 +40,12 @@ ## TODO: specify n for IB01BD endif - %nsmp = ns(1) - %nobr = fix ((nsmp+1)/(2*(m+l+1))) - % nsmp >= 2*(m+l+1)*nobr - 1 - % nobr <= (nsmp+1)/(2*(m+l+1)) -%nobr = 10 - [a, b, c, d, q, ry, s, k, x0] = slident (dat.y{1}, dat.u{1}, nobr, n, meth, alg, batch, conct, ctrl, rcond, tol); + [a, b, c, d, q, ry, s, k, x0] = slident (dat.y, dat.u, nobr, n, meth, alg, conct, ctrl, rcond, tol); sys = ss (a, b, c, d, dat.tsam{1}); + + if (numel (x0) == 1) + x0 = x0{1}; + endif endfunction Modified: trunk/octave-forge/extra/control-devel/inst/__slicot_identification__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__slicot_identification__.m 2012-05-18 20:25:34 UTC (rev 10459) +++ trunk/octave-forge/extra/control-devel/inst/__slicot_identification__.m 2012-05-18 20:39:56 UTC (rev 10460) @@ -11,10 +11,7 @@ error ("ident: invalid method"); # should never happen endswitch -% meth = 2; % 2 % geht: meth/alg 1/1, - alg = 0; % 0 % geht nicht: meth/alg 0/1 - jobd = 1; - batch = 3; + alg = 0; conct = 1; ctrl = 0; %1; rcond = 0.0; @@ -50,8 +47,12 @@ ## TODO: specify n for IB01BD endif - [a, b, c, d, q, ry, s, k, x0] = slident (dat.y{1}, dat.u{1}, nobr, n, meth, alg, jobd, batch, conct, ctrl, rcond, tol); + [a, b, c, d, q, ry, s, k, x0] = slident (dat.y, dat.u, nobr, n, meth, alg, conct, ctrl, rcond, tol); sys = ss (a, b, c, d, dat.tsam{1}); + if (numel (x0) == 1) + x0 = x0{1}; + endif + endfunction Modified: trunk/octave-forge/extra/control-devel/src/slident.cc =================================================================== --- trunk/octave-forge/extra/control-devel/src/slident.cc 2012-05-18 20:25:34 UTC (rev 10459) +++ trunk/octave-forge/extra/control-devel/src/slident.cc 2012-05-18 20:39:56 UTC (rev 10460) @@ -96,7 +96,7 @@ int nargin = args.length (); octave_value_list retval; - if (nargin != 11) + if (nargin != 10) { print_usage (); } @@ -117,19 +117,16 @@ const Cell y_cell = args(0).cell_value (); const Cell u_cell = args(1).cell_value (); - //Matrix y = args(0).matrix_value (); - //Matrix u = args(1).matrix_value (); int nobr = args(2).int_value (); int nuser = args(3).int_value (); const int imeth = args(4).int_value (); const int ialg = args(5).int_value (); - // const int ibatch = args(6).int_value (); // löschen - const int iconct = args(7).int_value (); - const int ictrl = args(8).int_value (); + const int iconct = args(6).int_value (); + const int ictrl = args(7).int_value (); - double rcond = args(9).double_value (); - double tol_a = args(10).double_value (); + double rcond = args(8).double_value (); + double tol_a = args(9).double_value (); double tol_b = rcond; double tol_c = rcond; @@ -244,21 +241,7 @@ ldu = nsmp; int ldy = nsmp; -/* - // arguments out - int n; - int ldr; - - if (meth_a == 'M' && jobd == 'M') - ldr = max (2*(m+l)*nobr, 3*m*nobr); - else if (meth_a == 'N' || (meth_a == 'M' && jobd == 'N')) - ldr = 2*(m+l)*nobr; - else - error ("slib01ad: could not handle 'ldr' case"); - - Matrix r (ldr, 2*(m+l)*nobr); - ColumnVector sv (l*nobr); -*/ + // workspace int liwork_a; @@ -272,7 +255,6 @@ // TODO: Handle 'k' for DWORK int ldwork_a; - //int ns = nsmp - 2*nobr + 1; if (alg == 'C') { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-05-18 20:25:41
|
Revision: 10459 http://octave.svn.sourceforge.net/octave/?rev=10459&view=rev Author: paramaniac Date: 2012-05-18 20:25:34 +0000 (Fri, 18 May 2012) Log Message: ----------- control-devel: initial state vectors for multi-experiment identification Modified Paths: -------------- trunk/octave-forge/extra/control-devel/devel/ident.m trunk/octave-forge/extra/control-devel/src/slident.cc Modified: trunk/octave-forge/extra/control-devel/devel/ident.m =================================================================== --- trunk/octave-forge/extra/control-devel/devel/ident.m 2012-05-18 18:23:28 UTC (rev 10458) +++ trunk/octave-forge/extra/control-devel/devel/ident.m 2012-05-18 20:25:34 UTC (rev 10459) @@ -49,5 +49,9 @@ [a, b, c, d, q, ry, s, k, x0] = slident (dat.y, dat.u, nobr, n, meth, alg, batch, conct, ctrl, rcond, tol); sys = ss (a, b, c, d, dat.tsam{1}); + + if (numel (x0) == 1) + x0 = x0{1}; + endif endfunction Modified: trunk/octave-forge/extra/control-devel/src/slident.cc =================================================================== --- trunk/octave-forge/extra/control-devel/src/slident.cc 2012-05-18 18:23:28 UTC (rev 10458) +++ trunk/octave-forge/extra/control-devel/src/slident.cc 2012-05-18 20:25:34 UTC (rev 10459) @@ -621,87 +621,103 @@ // SLICOT IB01CD - estimating the initial state // //////////////////////////////////////////////////////////////////////////////////// -// TODO: use only one iwork and dwork for all three slicot routines -// ldwork = max (ldwork_a, ldwork_b, ldwork_c) - -/* // arguments in char jobx0 = 'X'; char comuse = 'U'; char jobbd = 'D'; // arguments out - int ldv = max (1, n); + Cell x0_cell (n_exp, 1); - ColumnVector x0 (n); - Matrix v (ldv, n); + for (int i = 0; i < n_exp; i++) + { + Matrix y = y_cell.elem(i).matrix_value (); + Matrix u = u_cell.elem(i).matrix_value (); + + int nsmp = y.rows (); // nsmp: number of samples + int ldv = max (1, n); + + int ldu; - // workspace - int liwork_c = n; // if JOBX0 = 'X' and COMUSE <> 'C' - int ldwork_c; - int t = nsmp; + if (m == 0) + ldu = 1; + else // m > 0 + ldu = nsmp; + + int ldy = nsmp; + + + ColumnVector x0 (n); + Matrix v (ldv, n); + + // workspace + int liwork_c = n; // if JOBX0 = 'X' and COMUSE <> 'C' + int ldwork_c; + int t = nsmp; - int ldw1_c = 2; - int ldw2_c = t*l*(n + 1) + 2*n + max (2*n*n, 4*n); - int ldw3_c = n*(n + 1) + 2*n + max (n*l*(n + 1) + 2*n*n + l*n, 4*n); + int ldw1_c = 2; + int ldw2_c = t*l*(n + 1) + 2*n + max (2*n*n, 4*n); + int ldw3_c = n*(n + 1) + 2*n + max (n*l*(n + 1) + 2*n*n + l*n, 4*n); - ldwork_c = ldw1_c + n*( n + m + l ) + max (5*n, ldw1_c, min (ldw2_c, ldw3_c)); - - OCTAVE_LOCAL_BUFFER (int, iwork_c, liwork_c); - OCTAVE_LOCAL_BUFFER (double, dwork_c, ldwork_c); + ldwork_c = ldw1_c + n*( n + m + l ) + max (5*n, ldw1_c, min (ldw2_c, ldw3_c)); - // error indicators - int iwarn_c = 0; - int info_c = 0; - + OCTAVE_LOCAL_BUFFER (int, iwork_c, liwork_c); + OCTAVE_LOCAL_BUFFER (double, dwork_c, ldwork_c); - // SLICOT routine IB01CD - F77_XFCN (ib01cd, IB01CD, - (jobx0, comuse, jobbd, - n, m, l, - nsmp, - a.fortran_vec (), lda, - b.fortran_vec (), ldb, - c.fortran_vec (), ldc, - d.fortran_vec (), ldd, - u.fortran_vec (), ldu, - y.fortran_vec (), ldy, - x0.fortran_vec (), - v.fortran_vec (), ldv, - tol_c, - iwork_c, - dwork_c, ldwork_c, - iwarn_c, info_c)); + // error indicators + int iwarn_c = 0; + int info_c = 0; + // SLICOT routine IB01CD + F77_XFCN (ib01cd, IB01CD, + (jobx0, comuse, jobbd, + n, m, l, + nsmp, + a.fortran_vec (), lda, + b.fortran_vec (), ldb, + c.fortran_vec (), ldc, + d.fortran_vec (), ldd, + u.fortran_vec (), ldu, + y.fortran_vec (), ldy, + x0.fortran_vec (), + v.fortran_vec (), ldv, + tol_c, + iwork_c, + dwork_c, ldwork_c, + iwarn_c, info_c)); - if (f77_exception_encountered) - error ("ident: exception in SLICOT subroutine IB01CD"); - static const char* err_msg_c[] = { - "0: OK", - "1: the QR algorithm failed to compute all the " - "eigenvalues of the matrix A (see LAPACK Library " - "routine DGEES); the locations DWORK(i), for " - "i = g+1:g+N*N, contain the partially converged " - "Schur form", - "2: the singular value decomposition (SVD) algorithm did " - "not converge"}; + if (f77_exception_encountered) + error ("ident: exception in SLICOT subroutine IB01CD"); - static const char* warn_msg_c[] = { - "0: OK", - "1: warning message not specified", - "2: warning message not specified", - "3: warning message not specified", - "4: the least squares problem to be solved has a " - "rank-deficient coefficient matrix", - "5: warning message not specified", - "6: the matrix A is unstable; the estimated x(0) " - "and/or B and D could be inaccurate"}; + static const char* err_msg_c[] = { + "0: OK", + "1: the QR algorithm failed to compute all the " + "eigenvalues of the matrix A (see LAPACK Library " + "routine DGEES); the locations DWORK(i), for " + "i = g+1:g+N*N, contain the partially converged " + "Schur form", + "2: the singular value decomposition (SVD) algorithm did " + "not converge"}; + static const char* warn_msg_c[] = { + "0: OK", + "1: warning message not specified", + "2: warning message not specified", + "3: warning message not specified", + "4: the least squares problem to be solved has a " + "rank-deficient coefficient matrix", + "5: warning message not specified", + "6: the matrix A is unstable; the estimated x(0) " + "and/or B and D could be inaccurate"}; - error_msg ("ident: IB01CD", info_c, 2, err_msg_c); - warning_msg ("ident: IB01CD", iwarn_c, 6, warn_msg_c); -*/ + + error_msg ("ident: IB01CD", info_c, 2, err_msg_c); + warning_msg ("ident: IB01CD", iwarn_c, 6, warn_msg_c); + + x0_cell.elem(i) = x0; + } + // return values retval(0) = a; @@ -714,8 +730,7 @@ retval(6) = s; retval(7) = k; - // retval(8) = x0; - retval(8) = octave_value (0); + retval(8) = x0_cell; } return retval; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-05-18 18:23:34
|
Revision: 10458 http://octave.svn.sourceforge.net/octave/?rev=10458&view=rev Author: paramaniac Date: 2012-05-18 18:23:28 +0000 (Fri, 18 May 2012) Log Message: ----------- control-devel: get multi-experiment identification working (fingers crossed) Modified Paths: -------------- trunk/octave-forge/extra/control-devel/devel/ident.m trunk/octave-forge/extra/control-devel/src/slident.cc Modified: trunk/octave-forge/extra/control-devel/devel/ident.m =================================================================== --- trunk/octave-forge/extra/control-devel/devel/ident.m 2012-05-18 16:04:20 UTC (rev 10457) +++ trunk/octave-forge/extra/control-devel/devel/ident.m 2012-05-18 18:23:28 UTC (rev 10458) @@ -46,7 +46,7 @@ % nsmp >= 2*(m+l+1)*nobr - 1 % nobr <= (nsmp+1)/(2*(m+l+1)) %nobr = 10 - [a, b, c, d, q, ry, s, k, x0] = slident (dat.y{1}, dat.u{1}, nobr, n, meth, alg, batch, conct, ctrl, rcond, tol); + [a, b, c, d, q, ry, s, k, x0] = slident (dat.y, dat.u, nobr, n, meth, alg, batch, conct, ctrl, rcond, tol); sys = ss (a, b, c, d, dat.tsam{1}); Modified: trunk/octave-forge/extra/control-devel/src/slident.cc =================================================================== --- trunk/octave-forge/extra/control-devel/src/slident.cc 2012-05-18 16:04:20 UTC (rev 10457) +++ trunk/octave-forge/extra/control-devel/src/slident.cc 2012-05-18 18:23:28 UTC (rev 10458) @@ -184,10 +184,10 @@ ctrl = 'N'; - int n_exp = y_cell.nelem (); // number of experiments - - int m = u_cell.elem(0).columns (); // m: number of inputs - int l = y_cell.elem(0).columns (); // l: number of outputs + int n_exp = y_cell.nelem (); // number of experiments + int m = u_cell.elem(0).columns (); // m: number of inputs + int l = y_cell.elem(0).columns (); // l: number of outputs + int nsmpl = 0; // total number of samples // arguments out int n; @@ -221,6 +221,7 @@ //int m = u.columns (); // m: number of inputs //int l = y.columns (); // l: number of outputs int nsmp = y.rows (); // nsmp: number of samples + nsmpl += nsmp; // y.rows == u.rows is checked by iddata class // TODO: check minimal nsmp size @@ -448,7 +449,7 @@ char job = 'A'; char jobck = 'K'; - int nsmpl = nsmp; + //int nsmpl = nsmp; if (nsmpl < 2*(m+l)*nobr) error ("slident: nsmpl (%d) < 2*(m+l)*nobr (%d)", nsmpl, nobr); @@ -623,7 +624,7 @@ // TODO: use only one iwork and dwork for all three slicot routines // ldwork = max (ldwork_a, ldwork_b, ldwork_c) - +/* // arguments in char jobx0 = 'X'; char comuse = 'U'; @@ -700,7 +701,7 @@ error_msg ("ident: IB01CD", info_c, 2, err_msg_c); warning_msg ("ident: IB01CD", iwarn_c, 6, warn_msg_c); - +*/ // return values retval(0) = a; @@ -713,7 +714,8 @@ retval(6) = s; retval(7) = k; - retval(8) = x0; + // retval(8) = x0; + retval(8) = octave_value (0); } return retval; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-05-18 16:04:27
|
Revision: 10457 http://octave.svn.sourceforge.net/octave/?rev=10457&view=rev Author: paramaniac Date: 2012-05-18 16:04:20 +0000 (Fri, 18 May 2012) Log Message: ----------- control-devel: work on multi-experiment identification Modified Paths: -------------- trunk/octave-forge/extra/control-devel/src/slident.cc Modified: trunk/octave-forge/extra/control-devel/src/slident.cc =================================================================== --- trunk/octave-forge/extra/control-devel/src/slident.cc 2012-05-18 15:01:56 UTC (rev 10456) +++ trunk/octave-forge/extra/control-devel/src/slident.cc 2012-05-18 16:04:20 UTC (rev 10457) @@ -28,7 +28,8 @@ */ #include <octave/oct.h> -#include <f77-fcn.h> +#include <octave/f77-fcn.h> +#include <octave/Cell.h> #include "common.h" extern "C" @@ -114,14 +115,16 @@ char conct; char ctrl; - Matrix y = args(0).matrix_value (); - Matrix u = args(1).matrix_value (); + const Cell y_cell = args(0).cell_value (); + const Cell u_cell = args(1).cell_value (); + //Matrix y = args(0).matrix_value (); + //Matrix u = args(1).matrix_value (); int nobr = args(2).int_value (); int nuser = args(3).int_value (); const int imeth = args(4).int_value (); const int ialg = args(5).int_value (); - const int ibatch = args(6).int_value (); + // const int ibatch = args(6).int_value (); // löschen const int iconct = args(7).int_value (); const int ictrl = args(8).int_value (); @@ -169,24 +172,6 @@ jobd = 'M'; else // meth_a == 'N' jobd = 'N'; // IB01AD.f says: This parameter is not relevant for METH = 'N' - - switch (ibatch) - { - case 0: - batch = 'F'; - break; - case 1: - batch = 'I'; - break; - case 2: - batch = 'L'; - break; - case 3: - batch = 'O'; - break; - default: - error ("slib01ad: argument 'batch' invalid"); - } if (iconct == 0) conct = 'C'; @@ -199,32 +184,66 @@ ctrl = 'N'; - int m = u.columns (); // m: number of inputs - int l = y.columns (); // l: number of outputs - int nsmp = y.rows (); // nsmp: number of samples - // y.rows == u.rows is checked by iddata class - // TODO: check minimal nsmp size + int n_exp = y_cell.nelem (); // number of experiments - if (batch == 'O') - { - if (nsmp < 2*(m+l+1)*nobr - 1) - error ("slident: require NSMP >= 2*(M+L+1)*NOBR - 1"); - } + int m = u_cell.elem(0).columns (); // m: number of inputs + int l = y_cell.elem(0).columns (); // l: number of outputs + + // arguments out + int n; + int ldr; + + if (meth_a == 'M' && jobd == 'M') + ldr = max (2*(m+l)*nobr, 3*m*nobr); + else if (meth_a == 'N' || (meth_a == 'M' && jobd == 'N')) + ldr = 2*(m+l)*nobr; else + error ("slib01ad: could not handle 'ldr' case"); + + Matrix r (ldr, 2*(m+l)*nobr); + ColumnVector sv (l*nobr); + + + for (int i = 0; i < n_exp; i++) { - if (nsmp < 2*nobr) - error ("slident: require NSMP >= 2*NOBR"); - } + if (n_exp == 1) + batch = 'O'; // one block only + else if (i == 0) + batch = 'F'; // first block + else if (i == n_exp-1) + batch = 'L'; // last block + else + batch = 'I'; // intermediate block + + Matrix y = y_cell.elem(i).matrix_value (); + Matrix u = u_cell.elem(i).matrix_value (); + + //int m = u.columns (); // m: number of inputs + //int l = y.columns (); // l: number of outputs + int nsmp = y.rows (); // nsmp: number of samples + // y.rows == u.rows is checked by iddata class + // TODO: check minimal nsmp size - int ldu; + if (batch == 'O') + { + if (nsmp < 2*(m+l+1)*nobr - 1) + error ("slident: require NSMP >= 2*(M+L+1)*NOBR - 1"); + } + else + { + if (nsmp < 2*nobr) + error ("slident: require NSMP >= 2*NOBR"); + } - if (m == 0) - ldu = 1; - else // m > 0 - ldu = nsmp; + int ldu; + + if (m == 0) + ldu = 1; + else // m > 0 + ldu = nsmp; - int ldy = nsmp; - + int ldy = nsmp; +/* // arguments out int n; int ldr; @@ -238,78 +257,78 @@ Matrix r (ldr, 2*(m+l)*nobr); ColumnVector sv (l*nobr); +*/ + // workspace + int liwork_a; - // workspace - int liwork_a; + if (meth_a == 'N') // if METH = 'N' + liwork_a = (m+l)*nobr; + else if (alg == 'F') // if METH = 'M' and ALG = 'F' + liwork_a = m+l; + else // if METH = 'M' and ALG = 'C' or 'Q' + liwork_a = 0; - if (meth_a == 'N') // if METH = 'N' - liwork_a = (m+l)*nobr; - else if (alg == 'F') // if METH = 'M' and ALG = 'F' - liwork_a = m+l; - else // if METH = 'M' and ALG = 'C' or 'Q' - liwork_a = 0; + // TODO: Handle 'k' for DWORK - // TODO: Handle 'k' for DWORK - - int ldwork_a; - int ns = nsmp - 2*nobr + 1; + int ldwork_a; + //int ns = nsmp - 2*nobr + 1; - if (alg == 'C') - { - if (batch == 'F' || batch == 'I') + if (alg == 'C') { - if (conct == 'C') - ldwork_a = (4*nobr-2)*(m+l); - else // (conct == 'N') - ldwork_a = 1; - } - else if (meth_a == 'M') // && (batch == 'L' || batch == 'O') - { - if (conct == 'C' && batch == 'L') - ldwork_a = max ((4*nobr-2)*(m+l), 5*l*nobr); - else if (jobd == 'M') - ldwork_a = max ((2*m-1)*nobr, (m+l)*nobr, 5*l*nobr); - else // (jobd == 'N') - ldwork_a = 5*l*nobr; - } - else // meth_b == 'N' && (batch == 'L' || batch == 'O') - { - ldwork_a = 5*(m+l)*nobr + 1; - } - } - else if (alg == 'F') - { - if (batch != 'O' && conct == 'C') - ldwork_a = (m+l)*2*nobr*(m+l+3); - else if (batch == 'F' || batch == 'I') // && conct == 'N' - ldwork_a = (m+l)*2*nobr*(m+l+1); - else // (batch == 'L' || '0' && conct == 'N') - ldwork_a = (m+l)*4*nobr*(m+l+1)+(m+l)*2*nobr; - } - else // (alg == 'Q') - { - // int ns = nsmp - 2*nobr + 1; - - if (ldr >= ns && batch == 'F') - { - ldwork_a = 4*(m+l)*nobr; - } - else if (ldr >= ns && batch == 'O') - { - if (meth_a == 'M') - ldwork_a = max (4*(m+l)*nobr, 5*l*nobr); - else // (meth == 'N') + if (batch == 'F' || batch == 'I') + { + if (conct == 'C') + ldwork_a = (4*nobr-2)*(m+l); + else // (conct == 'N') + ldwork_a = 1; + } + else if (meth_a == 'M') // && (batch == 'L' || batch == 'O') + { + if (conct == 'C' && batch == 'L') + ldwork_a = max ((4*nobr-2)*(m+l), 5*l*nobr); + else if (jobd == 'M') + ldwork_a = max ((2*m-1)*nobr, (m+l)*nobr, 5*l*nobr); + else // (jobd == 'N') + ldwork_a = 5*l*nobr; + } + else // meth_b == 'N' && (batch == 'L' || batch == 'O') + { ldwork_a = 5*(m+l)*nobr + 1; + } } - else if (conct == 'C' && (batch == 'I' || batch == 'L')) + else if (alg == 'F') { - ldwork_a = 4*(nobr+1)*(m+l)*nobr; + if (batch != 'O' && conct == 'C') + ldwork_a = (m+l)*2*nobr*(m+l+3); + else if (batch == 'F' || batch == 'I') // && conct == 'N' + ldwork_a = (m+l)*2*nobr*(m+l+1); + else // (batch == 'L' || '0' && conct == 'N') + ldwork_a = (m+l)*4*nobr*(m+l+1)+(m+l)*2*nobr; } - else // if ALG = 'Q', (BATCH = 'F' or 'O', and LDR < NS), or (BATCH = 'I' or 'L' and CONCT = 'N') + else // (alg == 'Q') { - ldwork_a = 6*(m+l)*nobr; + int ns = nsmp - 2*nobr + 1; + + if (ldr >= ns && batch == 'F') + { + ldwork_a = 4*(m+l)*nobr; + } + else if (ldr >= ns && batch == 'O') + { + if (meth_a == 'M') + ldwork_a = max (4*(m+l)*nobr, 5*l*nobr); + else // (meth == 'N') + ldwork_a = 5*(m+l)*nobr + 1; + } + else if (conct == 'C' && (batch == 'I' || batch == 'L')) + { + ldwork_a = 4*(nobr+1)*(m+l)*nobr; + } + else // if ALG = 'Q', (BATCH = 'F' or 'O', and LDR < NS), or (BATCH = 'I' or 'L' and CONCT = 'N') + { + ldwork_a = 6*(m+l)*nobr; + } } - } /* IB01AD.f Lines 438-445 @@ -343,66 +362,67 @@ */ - OCTAVE_LOCAL_BUFFER (int, iwork_a, liwork_a); - OCTAVE_LOCAL_BUFFER (double, dwork_a, ldwork_a); + OCTAVE_LOCAL_BUFFER (int, iwork_a, liwork_a); + OCTAVE_LOCAL_BUFFER (double, dwork_a, ldwork_a); - // error indicators - int iwarn_a = 0; - int info_a = 0; + // error indicators + int iwarn_a = 0; + int info_a = 0; - // SLICOT routine IB01AD - F77_XFCN (ib01ad, IB01AD, - (meth_a, alg, jobd, - batch, conct, ctrl, - nobr, m, l, - nsmp, - u.fortran_vec (), ldu, - y.fortran_vec (), ldy, - n, - r.fortran_vec (), ldr, - sv.fortran_vec (), - rcond, tol_a, - iwork_a, - dwork_a, ldwork_a, - iwarn_a, info_a)); + // SLICOT routine IB01AD + F77_XFCN (ib01ad, IB01AD, + (meth_a, alg, jobd, + batch, conct, ctrl, + nobr, m, l, + nsmp, + u.fortran_vec (), ldu, + y.fortran_vec (), ldy, + n, + r.fortran_vec (), ldr, + sv.fortran_vec (), + rcond, tol_a, + iwork_a, + dwork_a, ldwork_a, + iwarn_a, info_a)); - if (f77_exception_encountered) - error ("ident: exception in SLICOT subroutine IB01AD"); + if (f77_exception_encountered) + error ("ident: exception in SLICOT subroutine IB01AD"); - static const char* err_msg[] = { - "0: OK", - "1: a fast algorithm was requested (ALG = 'C', or 'F') " - "in sequential data processing, but it failed; the " - "routine can be repeatedly called again using the " - "standard QR algorithm", - "2: the singular value decomposition (SVD) algorithm did " - "not converge"}; + static const char* err_msg[] = { + "0: OK", + "1: a fast algorithm was requested (ALG = 'C', or 'F') " + "in sequential data processing, but it failed; the " + "routine can be repeatedly called again using the " + "standard QR algorithm", + "2: the singular value decomposition (SVD) algorithm did " + "not converge"}; - static const char* warn_msg[] = { - "0: OK", - "1: the number of 100 cycles in sequential data " - "processing has been exhausted without signaling " - "that the last block of data was get; the cycle " - "counter was reinitialized", - "2: a fast algorithm was requested (ALG = 'C' or 'F'), " - "but it failed, and the QR algorithm was then used " - "(non-sequential data processing)", - "3: all singular values were exactly zero, hence N = 0 " - "(both input and output were identically zero)", - "4: the least squares problems with coefficient matrix " - "U_f, used for computing the weighted oblique " - "projection (for METH = 'N'), have a rank-deficient " - "coefficient matrix", - "5: the least squares problem with coefficient matrix " - "r_1 [6], used for computing the weighted oblique " - "projection (for METH = 'N'), has a rank-deficient " - "coefficient matrix"}; + static const char* warn_msg[] = { + "0: OK", + "1: the number of 100 cycles in sequential data " + "processing has been exhausted without signaling " + "that the last block of data was get; the cycle " + "counter was reinitialized", + "2: a fast algorithm was requested (ALG = 'C' or 'F'), " + "but it failed, and the QR algorithm was then used " + "(non-sequential data processing)", + "3: all singular values were exactly zero, hence N = 0 " + "(both input and output were identically zero)", + "4: the least squares problems with coefficient matrix " + "U_f, used for computing the weighted oblique " + "projection (for METH = 'N'), have a rank-deficient " + "coefficient matrix", + "5: the least squares problem with coefficient matrix " + "r_1 [6], used for computing the weighted oblique " + "projection (for METH = 'N'), has a rank-deficient " + "coefficient matrix"}; - error_msg ("ident: IB01AD", info_a, 2, err_msg); - warning_msg ("ident: IB01AD", iwarn_a, 5, warn_msg); + error_msg ("ident: IB01AD", info_a, 2, err_msg); + warning_msg ("ident: IB01AD", iwarn_a, 5, warn_msg); + } // resize This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-05-18 15:02:07
|
Revision: 10456 http://octave.svn.sourceforge.net/octave/?rev=10456&view=rev Author: paramaniac Date: 2012-05-18 15:01:56 +0000 (Fri, 18 May 2012) Log Message: ----------- control-devel: remove parameter jobd Modified Paths: -------------- trunk/octave-forge/extra/control-devel/devel/ident.m trunk/octave-forge/extra/control-devel/devel/ident_combinations.m trunk/octave-forge/extra/control-devel/devel/makefile_devel.m trunk/octave-forge/extra/control-devel/inst/moesp.m trunk/octave-forge/extra/control-devel/inst/n4sid.m trunk/octave-forge/extra/control-devel/src/slident.cc Modified: trunk/octave-forge/extra/control-devel/devel/ident.m =================================================================== --- trunk/octave-forge/extra/control-devel/devel/ident.m 2012-05-18 14:23:03 UTC (rev 10455) +++ trunk/octave-forge/extra/control-devel/devel/ident.m 2012-05-18 15:01:56 UTC (rev 10456) @@ -5,7 +5,6 @@ %nobr = 15; meth = 2; % 2 % geht: meth/alg 1/1, alg = 0; % 0 % geht nicht: meth/alg 0/1 - jobd = 1; batch = 3; conct = 1; ctrl = 0; %1; @@ -47,7 +46,7 @@ % nsmp >= 2*(m+l+1)*nobr - 1 % nobr <= (nsmp+1)/(2*(m+l+1)) %nobr = 10 - [a, b, c, d, q, ry, s, k, x0] = slident (dat.y{1}, dat.u{1}, nobr, n, meth, alg, jobd, batch, conct, ctrl, rcond, tol); + [a, b, c, d, q, ry, s, k, x0] = slident (dat.y{1}, dat.u{1}, nobr, n, meth, alg, batch, conct, ctrl, rcond, tol); sys = ss (a, b, c, d, dat.tsam{1}); Modified: trunk/octave-forge/extra/control-devel/devel/ident_combinations.m =================================================================== --- trunk/octave-forge/extra/control-devel/devel/ident_combinations.m 2012-05-18 14:23:03 UTC (rev 10455) +++ trunk/octave-forge/extra/control-devel/devel/ident_combinations.m 2012-05-18 15:01:56 UTC (rev 10456) @@ -5,7 +5,6 @@ %nobr = 15; % meth = 1; % 2 % geht: meth/alg 1/1, % alg = 2; % 0 % geht nicht: meth/alg 0/1 - jobd = 1; batch = 3; conct = 1; ctrl = 0; %1; @@ -47,7 +46,7 @@ % nsmp >= 2*(m+l+1)*nobr - 1 % nobr <= (nsmp+1)/(2*(m+l+1)) %nobr = 10 - [a, b, c, d, q, ry, s, k, x0] = slident (dat.y{1}, dat.u{1}, nobr, n, meth, alg, jobd, batch, conct, ctrl, rcond, tol); + [a, b, c, d, q, ry, s, k, x0] = slident (dat.y{1}, dat.u{1}, nobr, n, meth, alg, batch, conct, ctrl, rcond, tol); sys = ss (a, b, c, d, dat.tsam{1}); Modified: trunk/octave-forge/extra/control-devel/devel/makefile_devel.m =================================================================== --- trunk/octave-forge/extra/control-devel/devel/makefile_devel.m 2012-05-18 14:23:03 UTC (rev 10455) +++ trunk/octave-forge/extra/control-devel/devel/makefile_devel.m 2012-05-18 15:01:56 UTC (rev 10456) @@ -14,7 +14,7 @@ ## system ("make realclean"); # recompile slicotlibrary.a system ("make clean"); -system ("make -j4 all"); +system ("make -j1 all"); system ("rm *.o"); cd (homedir); \ No newline at end of file Modified: trunk/octave-forge/extra/control-devel/inst/moesp.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/moesp.m 2012-05-18 14:23:03 UTC (rev 10455) +++ trunk/octave-forge/extra/control-devel/inst/moesp.m 2012-05-18 15:01:56 UTC (rev 10456) @@ -17,7 +17,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {@var{dat} =} moesp (@var{dat}, @var{s}, @var{n}) -## MOESP. +## MOESP: Multivariable Output Error State sPace. ## @end deftypefn ## Author: Lukas Reichlin <luk...@gm...> Modified: trunk/octave-forge/extra/control-devel/inst/n4sid.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/n4sid.m 2012-05-18 14:23:03 UTC (rev 10455) +++ trunk/octave-forge/extra/control-devel/inst/n4sid.m 2012-05-18 15:01:56 UTC (rev 10456) @@ -17,7 +17,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {@var{dat} =} n4sid (@var{dat}, @var{s}, @var{n}) -## N4SID. +## N4SID: Numerical algorithm for Subspace State Space System IDentification. ## @end deftypefn ## Author: Lukas Reichlin <luk...@gm...> Modified: trunk/octave-forge/extra/control-devel/src/slident.cc =================================================================== --- trunk/octave-forge/extra/control-devel/src/slident.cc 2012-05-18 14:23:03 UTC (rev 10455) +++ trunk/octave-forge/extra/control-devel/src/slident.cc 2012-05-18 15:01:56 UTC (rev 10456) @@ -95,7 +95,7 @@ int nargin = args.length (); octave_value_list retval; - if (nargin != 12) + if (nargin != 11) { print_usage (); } @@ -121,18 +121,16 @@ const int imeth = args(4).int_value (); const int ialg = args(5).int_value (); - const int ijobd = args(6).int_value (); - const int ibatch = args(7).int_value (); - const int iconct = args(8).int_value (); - const int ictrl = args(9).int_value (); + const int ibatch = args(6).int_value (); + const int iconct = args(7).int_value (); + const int ictrl = args(8).int_value (); - double rcond = args(10).double_value (); - double tol_a = args(11).double_value (); + double rcond = args(9).double_value (); + double tol_a = args(10).double_value (); double tol_b = rcond; double tol_c = rcond; - //double tol_b = args(10).double_value (); // tol_b = rcond - + switch (imeth) { @@ -166,14 +164,12 @@ default: error ("slib01ad: argument 'alg' invalid"); } - - if (meth_b == 'C') - jobd = 'N'; - else if (ijobd == 0) + + if (meth_a == 'M') jobd = 'M'; - else - jobd = 'N'; - + else // meth_a == 'N' + jobd = 'N'; // IB01AD.f says: This parameter is not relevant for METH = 'N' + switch (ibatch) { case 0: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nir...@us...> - 2012-05-18 14:23:11
|
Revision: 10455 http://octave.svn.sourceforge.net/octave/?rev=10455&view=rev Author: nir-krakauer Date: 2012-05-18 14:23:03 +0000 (Fri, 18 May 2012) Log Message: ----------- added a new function csaps_sel Modified Paths: -------------- trunk/octave-forge/main/splines/INDEX Added Paths: ----------- trunk/octave-forge/main/splines/inst/csaps_sel.m Modified: trunk/octave-forge/main/splines/INDEX =================================================================== --- trunk/octave-forge/main/splines/INDEX 2012-05-18 04:42:55 UTC (rev 10454) +++ trunk/octave-forge/main/splines/INDEX 2012-05-18 14:23:03 UTC (rev 10455) @@ -3,6 +3,7 @@ csapi csape csaps + csaps_sel fnplt fnder fnval Added: trunk/octave-forge/main/splines/inst/csaps_sel.m =================================================================== --- trunk/octave-forge/main/splines/inst/csaps_sel.m (rev 0) +++ trunk/octave-forge/main/splines/inst/csaps_sel.m 2012-05-18 14:23:03 UTC (rev 10455) @@ -0,0 +1,163 @@ +## Copyright (C) 2012 Nir Krakauer +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn{Function File}{[@var{yi} @var{p} @var{sigma2},@var{unc_y}] =} csaps_sel(@var{x}, @var{y}, @var{xi}, @var{w}=[], @var{crit}=[]) +## @deftypefnx{Function File}{[@var{pp} @var{p} @var{sigma2},@var{unc_y}] =} csaps_sel(@var{x}, @var{y}, [], @var{w}=[], @var{crit}=[]) +## +## Cubic spline approximation with smoothing parameter estimation @* +## approximate [@var{x},@var{y}], weighted by @var{w} (inverse variance; if not given, equal weighting is assumed), at @var{xi}. +## +## The chosen cubic spline with natural boundary conditions @var{pp}(@var{x}) minimizes @var{p} Sum_i @var{w}_i*(@var{y}_i - @var{pp}(@var{x}_i))^2 + (1-@var{p}) Int @var{pp}''(@var{x}) d@var{x}. +## A selection criterion @var{crit} is used to find a suitable value for @var{p} (between 0 and 1); possible values for @var{crit} are `aicc' (corrected Akaike information criterion, the default); `aic' (original Akaike information criterion); `gcv' (generalized cross validation) +## +## @var{x} and @var{w} should be @var{n} by 1 in size; @var{y} should be @var{n} by @var{m}; @var{xi} should be @var{k} by 1; the values in @var{x} should be distinct; the values in @var{w} should be nonzero. +## +## returns the selected @var{p}, the estimated data scatter (variance from the smooth trend) @var{sigma2}, and the estimated uncertainty (SD) of the smoothing spline fit at each @var{x} value, @var{unc_y}. +## +## Note: The current evaluation of the effective number of model parameters uses singular value decomposition of an @var{n} by @var{n} matrix and is not computation or storage efficient for large @var{n} (thousands or greater). See Hutchinson (1985) for a more efficient method. +## +## References: +## +## Carl de Boor (1978), A Practical Guide to Splines, Springer, Chapter XIV +## +## Clifford M. Hurvich, Jeffrey S. Simonoff, Chih-Ling Tsai (1998), Smoothing parameter selection in nonparametric regression using an improved Akaike information criterion, J. Royal Statistical Society, 60B:271-293 +## +## M. F. Hutchinson and F. R. de Hoog (1985), Smoothing noisy data with spline functions, Numerische Mathematik, 47:99-106 +## +## M. F. Hutchinson (1986), Algorithm 642: A fast procedure for calculating minimum cross-validation cubic smoothing splines, ACM Transactions on Mathematical Software, 12:150-153 +## +## Grace Wahba (1983), Bayesian ``confidence intervals'' for the cross-validated smoothing spline, J Royal Statistical Society, 45B:133-150 +## +## @end deftypefn +## @seealso{csaps, spline, csapi, ppval, gcvspl} + +## Author: Nir Krakauer <nkr...@cc...> + +function [ret,p,sigma2,unc_y]=csaps_sel(x,y,xi,w,crit) + + if (nargin < 5) + crit = []; + if(nargin < 4) + w = []; + if(nargin < 3) + xi = []; + endif + endif + endif + + if(columns(x) > 1) + x = x.'; + y = y.'; + w = w.'; + endif + + [x,i] = sort(x); + y = y(i, :); + + n = numel(x); + + if isempty(w) + w = ones(n, 1); + end + + if isempty(crit) + crit = 'aicc'; + end + + h = diff(x); + + R = spdiags([h(1:end-1) 2*(h(1:end-1) + h(2:end)) h(2:end)], [-1 0 1], n-2, n-2); + + QT = spdiags([1 ./ h(1:end-1) -(1 ./ h(1:end-1) + 1 ./ h(2:end)) 1 ./ h(2:end)], [0 1 2], n-2, n); + +##determine influence matrix for different p without repeated inversion + [U D V] = svd(diag(1 ./ sqrt(w))*QT'*sqrtm(inv(R)), 0); D = diag(D).^2; + + +##choose p by minimizing the penalty function + penalty_function = @(p) penalty_compute(p, U, D, y, w, n, crit); + + p = fminbnd(penalty_function, 0, 1); + + + + H = influence_matrix(p, U, D, n); + [MSR, Ht] = penalty_terms(H, y, w); + sigma2 = MSR * (n / (n-Ht)); #estimated data error variance (wahba83) + unc_y = sqrt(sigma2 * diag(H) ./ w); #uncertainty (SD) of fitted curve at each input x-value (hutchinson86) + + +## solve for the scaled second derivatives u and for the function values a at the knots (if p = 1, a = y) + u = (6*(1-p)*QT*diag(1 ./ w)*QT' + p*R) \ (QT*y); + a = y - 6*(1-p)*diag(1 ./ w)*QT'*u; + +## derivatives at all but the last knot for the piecewise cubic spline + aa = a(1:(end-1), :); + cc = zeros(size(y)); + cc(2:(n-1), :) = 6*p*u; #cc([1 n], :) = 0 [natural spline] + dd = diff(cc) ./ h; + cc = cc(1:(end-1), :); + bb = diff(a) ./ h - (cc/2).*h - (dd/6).*(h.^2); + + ret = mkpp (x, cat (2, dd'(:)/6, cc'(:)/2, bb'(:), aa'(:)), size(y, 2)); + + if ~isempty(xi) + ret = ppval (ret, xi); + endif + +endfunction + + + +function H = influence_matrix(p, U, D, n) #returns influence matrix for given p + H = speye(n) - U * diag(D ./ (D + (p / (6*(1-p))))) * U'; +endfunction + +function [MSR, Ht] = penalty_terms(H, y, w) + MSR = mean(w .* (y - H*y) .^ 2); #mean square residual + Ht = trace(H); #effective number of fitted parameters +endfunction + +function J = aicc(MSR, Ht, n) + J = mean(log(MSR)(:)) + 2 * (Ht + 1) / max(n - Ht - 2, 0); #hurvich98, taking the average if there are multiple data sets as in woltring86 +endfunction + +function J = aic(MSR, Ht, n) + J = mean(log(MSR)(:)) + 2 * Ht / n; +endfunction + +function J = gcv(MSR, Ht, n) + J = mean(log(MSR)(:)) - 2 * log(1 - Ht / n); +endfunction + +function J = penalty_compute(p, U, D, y, w, n, crit) #evaluates a user-supplied penalty function at given p + H = influence_matrix(p, U, D, n); + [MSR, Ht] = penalty_terms(H, y, w); + J = feval(crit, MSR, Ht, n); + if ~isfinite(J) + J = Inf; + endif +endfunction + + +%!shared x,y,ret,p,sigma2,unc_y +%! x = [0:0.01:1]'; y = sin(x); +%! [ret,p,sigma2,unc_y]=csaps_sel(x,y,x); +%!assert (1-p, 0, 1E-6); +%!assert (sigma2, 0, 1E-10); +%!assert (ret-y, zeros(size(y)), 1E-4); +%!assert (unc_y, zeros(size(unc_y)), 1E-5); + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <be...@us...> - 2012-05-18 04:43:03
|
Revision: 10454 http://octave.svn.sourceforge.net/octave/?rev=10454&view=rev Author: benjf5 Date: 2012-05-18 04:42:55 +0000 (Fri, 18 May 2012) Log Message: ----------- Adding lssa folder to extra Added Paths: ----------- trunk/octave-forge/extra/lssa/ trunk/octave-forge/extra/lssa/COPYING Added: trunk/octave-forge/extra/lssa/COPYING =================================================================== --- trunk/octave-forge/extra/lssa/COPYING (rev 0) +++ trunk/octave-forge/extra/lssa/COPYING 2012-05-18 04:42:55 UTC (rev 10454) @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2012-05-17 03:49:42
|
Revision: 10453 http://octave.svn.sourceforge.net/octave/?rev=10453&view=rev Author: jordigh Date: 2012-05-17 03:49:35 +0000 (Thu, 17 May 2012) Log Message: ----------- Unindent (and thus re-enable) some tests in comm package Modified Paths: -------------- trunk/octave-forge/main/comm/inst/awgn.m trunk/octave-forge/main/comm/inst/bi2de.m trunk/octave-forge/main/comm/inst/de2bi.m trunk/octave-forge/main/comm/inst/egolaydec.m Modified: trunk/octave-forge/main/comm/inst/awgn.m =================================================================== --- trunk/octave-forge/main/comm/inst/awgn.m 2012-05-16 16:26:13 UTC (rev 10452) +++ trunk/octave-forge/main/comm/inst/awgn.m 2012-05-17 03:49:35 UTC (rev 10453) @@ -133,15 +133,15 @@ endfunction - %!shared x, y, noisy - %! x = [0:0.01:2*pi]; y = sin (x); - %! noisy = awgn (y, 20, "dB", "measured"); +%!shared x, y, noisy +%! x = [0:0.01:2*pi]; y = sin (x); +%! noisy = awgn (y, 20, "dB", "measured"); ## Test of noisy is pretty arbitrary, but should pickup most errors - %!error awgn (); - %!error awgn (1); - %!error awgn (1,1,1,1,1); - %!assert (isreal(noisy)); - %!assert (iscomplex(awgn(y+1i,20,"dB","measured"))); - %!assert (size(y) == size(noisy)) - %!assert (abs(10*log10(mean(y.^2)/mean((y-noisy).^ 2)) - 20) < 1); +%!error awgn (); +%!error awgn (1); +%!error awgn (1,1,1,1,1); +%!assert (isreal(noisy)); +%!assert (iscomplex(awgn(y+1i,20,"dB","measured"))); +%!assert (size(y) == size(noisy)) +%!assert (abs(10*log10(mean(y.^2)/mean((y-noisy).^ 2)) - 20) < 1); Modified: trunk/octave-forge/main/comm/inst/bi2de.m =================================================================== --- trunk/octave-forge/main/comm/inst/bi2de.m 2012-05-16 16:26:13 UTC (rev 10452) +++ trunk/octave-forge/main/comm/inst/bi2de.m 2012-05-17 03:49:35 UTC (rev 10453) @@ -75,22 +75,22 @@ endfunction - %!shared x - %! x = randi ([0 1], 100, 16); - %!assert (bi2de (0), 0) - %!assert (bi2de (1), 1) - %!assert (bi2de (ones (1, 8)), 255) - %!assert (bi2de ([7 7 7 7], 8), 4095) - %!assert (size (bi2de (x)), [100 1]) - %!assert (bi2de (x, "right-msb"), bi2de (x)) - %!assert (bi2de (x, "left-msb"), bi2de (fliplr (x))) +%!shared x +%! x = randi ([0 1], 100, 16); +%!assert (bi2de (0), 0) +%!assert (bi2de (1), 1) +%!assert (bi2de (ones (1, 8)), 255) +%!assert (bi2de ([7 7 7 7], 8), 4095) +%!assert (size (bi2de (x)), [100 1]) +%!assert (bi2de (x, "right-msb"), bi2de (x)) +%!assert (bi2de (x, "left-msb"), bi2de (fliplr (x))) %% Test input validation - %!error bi2de () - %!error bi2de (1, 2, 3, 4) - %!error bi2de (1, 2, 3) - %!error bi2de (1, 2, "invalid") - %!error bi2de (0.1) - %!error bi2de (-1) - %!error bi2de (2) - %!error bi2de (7, 6) +%!error bi2de () +%!error bi2de (1, 2, 3, 4) +%!error bi2de (1, 2, 3) +%!error bi2de (1, 2, "invalid") +%!error bi2de (0.1) +%!error bi2de (-1) +%!error bi2de (2) +%!error bi2de (7, 6) Modified: trunk/octave-forge/main/comm/inst/de2bi.m =================================================================== --- trunk/octave-forge/main/comm/inst/de2bi.m 2012-05-16 16:26:13 UTC (rev 10452) +++ trunk/octave-forge/main/comm/inst/de2bi.m 2012-05-17 03:49:35 UTC (rev 10453) @@ -87,21 +87,21 @@ endfunction - %!shared x - %! x = randi ([0 2^16-1], 100, 1); - %!assert (de2bi (0), 0) - %!assert (de2bi (1), 1) - %!assert (de2bi (255), ones (1, 8)) - %!assert (de2bi (255, [], 256), 255) - %!assert (de2bi (1023, 8, 8), [7 7 7 1 0 0 0 0]) - %!assert (size (de2bi (x, 16)), [100 16]) - %!assert (de2bi (x, 16, "right-msb"), de2bi (x, 16)) - %!assert (de2bi (x, 16, "left-msb"), fliplr (de2bi (x, 16))) +%!shared x +%! x = randi ([0 2^16-1], 100, 1); +%!assert (de2bi (0), 0) +%!assert (de2bi (1), 1) +%!assert (de2bi (255), ones (1, 8)) +%!assert (de2bi (255, [], 256), 255) +%!assert (de2bi (1023, 8, 8), [7 7 7 1 0 0 0 0]) +%!assert (size (de2bi (x, 16)), [100 16]) +%!assert (de2bi (x, 16, "right-msb"), de2bi (x, 16)) +%!assert (de2bi (x, 16, "left-msb"), fliplr (de2bi (x, 16))) %% Test input validation - %!error de2bi () - %!error de2bi (1, 2, 3, 4, 5) - %!error de2bi (1, 2, 3, 4) - %!error de2bi (1, 2, 3, "invalid") - %!error de2bi (0.1) - %!error de2bi (-1) +%!error de2bi () +%!error de2bi (1, 2, 3, 4, 5) +%!error de2bi (1, 2, 3, 4) +%!error de2bi (1, 2, 3, "invalid") +%!error de2bi (0.1) +%!error de2bi (-1) Modified: trunk/octave-forge/main/comm/inst/egolaydec.m =================================================================== --- trunk/octave-forge/main/comm/inst/egolaydec.m 2012-05-16 16:26:13 UTC (rev 10452) +++ trunk/octave-forge/main/comm/inst/egolaydec.m 2012-05-17 03:49:35 UTC (rev 10453) @@ -118,9 +118,9 @@ return; end - %! - %!assert(egolaydec([1 1 1 zeros(1,21)]),zeros(1,24)) - %!assert(egolaydec([1 0 1 zeros(1,20) 1]),zeros(1,24)) - %! +%! +%!assert(egolaydec([1 1 1 zeros(1,21)]),zeros(1,24)) +%!assert(egolaydec([1 0 1 zeros(1,20) 1]),zeros(1,24)) +%! This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-05-16 16:26:22
|
Revision: 10452 http://octave.svn.sourceforge.net/octave/?rev=10452&view=rev Author: jpicarbajal Date: 2012-05-16 16:26:13 +0000 (Wed, 16 May 2012) Log Message: ----------- geometry: little formasting of license Modified Paths: -------------- trunk/octave-forge/main/geometry/inst/geom2d/closed_path.m Modified: trunk/octave-forge/main/geometry/inst/geom2d/closed_path.m =================================================================== --- trunk/octave-forge/main/geometry/inst/geom2d/closed_path.m 2012-05-16 16:15:59 UTC (rev 10451) +++ trunk/octave-forge/main/geometry/inst/geom2d/closed_path.m 2012-05-16 16:26:13 UTC (rev 10452) @@ -1,18 +1,19 @@ %% Copyright (C) 2012 Simeon Simeonov <sim...@gm...> %% -%% This program is free software; you can redistribute it and/or modify -%% it under the terms of the GNU General Public License as published by -%% the Free Software Foundation; either version 3 of the License, or -%% (at your option) any later version. +%% This program is free software: you can redistribute it and/or modify +%% it under the terms of the GNU General Public License as published by +%% the Free Software Foundation, either version 3 of the License, or +%% any later version. %% -%% This program is distributed in the hope that it will be useful, -%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -%% GNU General Public License for more details. +%% This program is distributed in the hope that it will be useful, +%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%% GNU General Public License for more details. %% -%% You should have received a copy of the GNU General Public License -%% along with this program; if not, see <http://www.gnu.org/licenses/>. +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see <http://www.gnu.org/licenses/>. + %% -*- texinfo -*- %% @deftypefn {Function File} {@var{y} =} polygon (@var{x}) %% Returns a simple closed path that passes through all the points in @var{x}. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-05-16 16:16:08
|
Revision: 10451 http://octave.svn.sourceforge.net/octave/?rev=10451&view=rev Author: carandraug Date: 2012-05-16 16:15:59 +0000 (Wed, 16 May 2012) Log Message: ----------- closed_path: empty line between copyright and help text or octave won't parse it correctly Modified Paths: -------------- trunk/octave-forge/main/geometry/inst/geom2d/closed_path.m Modified: trunk/octave-forge/main/geometry/inst/geom2d/closed_path.m =================================================================== --- trunk/octave-forge/main/geometry/inst/geom2d/closed_path.m 2012-05-16 09:37:15 UTC (rev 10450) +++ trunk/octave-forge/main/geometry/inst/geom2d/closed_path.m 2012-05-16 16:15:59 UTC (rev 10451) @@ -12,11 +12,11 @@ %% %% You should have received a copy of the GNU General Public License %% along with this program; if not, see <http://www.gnu.org/licenses/>. -%% + %% -*- texinfo -*- %% @deftypefn {Function File} {@var{y} =} polygon (@var{x}) -%% Returns a simple closed path that passes through all the points in x. -%% x is a vector containing 2D coordinates of the points. +%% Returns a simple closed path that passes through all the points in @var{x}. +%% @var{x} is a vector containing 2D coordinates of the points. %% %% @end deftypefn This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-05-16 09:37:27
|
Revision: 10450 http://octave.svn.sourceforge.net/octave/?rev=10450&view=rev Author: paramaniac Date: 2012-05-16 09:37:15 +0000 (Wed, 16 May 2012) Log Message: ----------- control: fix typo bug Modified Paths: -------------- trunk/octave-forge/main/control/inst/@lti/mconnect.m Modified: trunk/octave-forge/main/control/inst/@lti/mconnect.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/mconnect.m 2012-05-16 09:02:41 UTC (rev 10449) +++ trunk/octave-forge/main/control/inst/@lti/mconnect.m 2012-05-16 09:37:15 UTC (rev 10450) @@ -73,7 +73,7 @@ [mrows, mcols] = size (M); if (p != mcols || m != mrows) - error ("mconnect: second argument must be a (%dx&d) matrix", m, p); + error ("mconnect: second argument must be a (%dx%d) matrix", m, p); endif if (! is_real_matrix (M)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-05-16 09:02:51
|
Revision: 10449 http://octave.svn.sourceforge.net/octave/?rev=10449&view=rev Author: paramaniac Date: 2012-05-16 09:02:41 +0000 (Wed, 16 May 2012) Log Message: ----------- control-devel: add fixme comments to arx Modified Paths: -------------- trunk/octave-forge/extra/control-devel/inst/arx.m Modified: trunk/octave-forge/extra/control-devel/inst/arx.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/arx.m 2012-05-16 08:00:43 UTC (rev 10448) +++ trunk/octave-forge/extra/control-devel/inst/arx.m 2012-05-16 09:02:41 UTC (rev 10449) @@ -27,6 +27,13 @@ function sys = arx (dat, na, nb) ## TODO: delays + + ## FIXME: MIMO models have p error inputs, not just 1 + + ## FIXME: Unlike SISO or MISO models, the transfer function + ## B(z) over A(z) is wrong for MIMO models. + ## We need a Matrix Fraction Description (MFD) + ## y = A^-1(q) B(q) u(t) + A^-1(q) e(t) if (nargin != 3) print_usage (); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |