# HG changeset patch # User Pantxo Diribarne # Date 1506597750 -7200 # Node ID 392afc740749c0adeab3bef9a24c2e56efe8277a # Parent 1945585422037388d8f029567cf0101c0815d367 lsccov.m: ensure all necessary variables are defined (bug #52131) * lscov.m: make sure necessary intermediate variables are defined even when not requested as output. diff -r 194558542203 -r 392afc740749 scripts/statistics/base/lscov.m --- a/scripts/statistics/base/lscov.m Thu Sep 28 11:04:02 2017 +0200 +++ b/scripts/statistics/base/lscov.m Thu Sep 28 13:22:30 2017 +0200 @@ -76,10 +76,10 @@ else ## n-by-n covariance matrix try - ## ordinarily V will be positive definite + ## Ordinarily V will be positive definite B = chol (V)'; catch - ## if V is only positive semidefinite, use its + ## If V is only positive semidefinite, use its ## eigendecomposition to find a factor B such that V = B*B' [B, lambda] = eig (V); image_dims = (diag (lambda) > 0); @@ -90,28 +90,27 @@ endif endif - pinv_A = pinv (A); #pseudoinverse + pinv_A = pinv (A); x = pinv_A * b; - if (isargout (3)) - dof = n - p; #degrees of freedom remaining after fit + if (nargout > 1) + dof = n - p; # degrees of freedom remaining after fit SSE = sumsq (b - A * x); mse = SSE / dof; - endif - - s = pinv_A * pinv_A'; - - stdx = sqrt (diag (s) * mse); - - if (isargout (4)) - if (k == 1) - S = mse * s; - else - S = NaN (p, p, k); - for i = 1:k - S(:, :, i) = mse(i) * s; - endfor + + s = pinv_A * pinv_A'; + stdx = sqrt (diag (s) * mse); + + if (nargout > 3) + if (k == 1) + S = mse * s; + else + S = NaN (p, p, k); + for i = 1:k + S(:, :, i) = mse(i) * s; + endfor + endif endif endif