Package: octave-statistics Version: 1.2.2-1 Severity: normal Tags: upstream patch
The princomp function as included in octave-statistics always throws an error in context where only first return value is expected: hyper% octave -q --no-init-file warning: function /usr/share/octave/packages/statistics-1.2.2/fstat.m shadows a core library function octave:1> princomp(rand(10,2)) error: 'r' undefined near line 103 column 48 error: invalid limit value in colon expression error: evaluating argument list element number 1 error: called from: error: /usr/share/octave/packages/statistics-1.2.2/princomp.m at line 103, column 9 octave:1> As far as I can tell this is a trivial bug caused by the fact that 'r' is only calculated if nargout > 1 and not needed otherwise so it can be fixed with the simple patch attached. -- System Information: Debian Release: jessie/sid APT prefers testing APT policy: (900, 'testing'), (700, 'unstable') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 3.2.0-4-amd64 (SMP w/4 CPU cores) Locale: LANG=pl_PL.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages octave-statistics depends on: ii octave 3.6.4-4 ii octave-io 1.2.5-1 octave-statistics recommends no packages. octave-statistics suggests no packages. -- no debconf information
diff --git a/inst/princomp.m b/inst/princomp.m index 786d07d..3bbc3cb 100644 --- a/inst/princomp.m +++ b/inst/princomp.m @@ -99,10 +99,11 @@ function [COEFF,SCORE,latent,tsquare] = princomp(X,varargin) endif - # This is the same as the eigenvalues of the covariance matrix of X - latent = (diag(S'*S)/(size(Xcentered,1)-1))(1:r); - if nargout > 2 + + # This is the same as the eigenvalues of the covariance matrix of X + latent = (diag(S'*S)/(size(Xcentered,1)-1))(1:r); + if !(nargin == 2 && strcmpi ( varargin{:} , "econ")) latent= [latent;zeros(nvars-r,1)]; endif