From: <car...@us...> - 2012-04-19 10:14:22
|
Revision: 10295 http://octave.svn.sourceforge.net/octave/?rev=10295&view=rev Author: carandraug Date: 2012-04-19 10:14:15 +0000 (Thu, 19 Apr 2012) Log Message: ----------- circulant_eig: set warning of broadcasting in a unwind_protect block Modified Paths: -------------- trunk/octave-forge/main/linear-algebra/inst/circulant_eig.m Modified: trunk/octave-forge/main/linear-algebra/inst/circulant_eig.m =================================================================== --- trunk/octave-forge/main/linear-algebra/inst/circulant_eig.m 2012-04-19 10:01:50 UTC (rev 10294) +++ trunk/octave-forge/main/linear-algebra/inst/circulant_eig.m 2012-04-19 10:14:15 UTC (rev 10295) @@ -29,23 +29,34 @@ function [a, b] = circulant_eig (v) - warning ("off", "Octave:broadcast"); #the code below uses broadcasting + ## FIXME when warning for broadcastin is turned off by default, this + ## unwind_protect block could be removed - #find the eigenvalues - n = numel(v); - lambda = ones(n, 1); - s = (0:(n-1)); - lambda = sum(v .* exp(-2*pi*i*s'*s/n))'; + ## we are using broadcasting on the code below so we turn off the + ## warnings but will restore to previous state at the end + bc_warn = warning ("query", "Octave:broadcast"); + unwind_protect + warning ("off", "Octave:broadcast"); - if nargout < 2 - a = lambda; - return - endif + #find the eigenvalues + n = numel(v); + lambda = ones(n, 1); + s = (0:(n-1)); + lambda = sum(v .* exp(-2*pi*i*s'*s/n))'; - #find the eigenvectors (which in fact do not depend on v) - a = exp(-2*i*pi*s'*s/n) / sqrt(n); - b = diag(lambda); + if nargout < 2 + a = lambda; + return + endif + #find the eigenvectors (which in fact do not depend on v) + a = exp(-2*i*pi*s'*s/n) / sqrt(n); + b = diag(lambda); + unwind_protect_cleanup + ## restore broadcats warning status + warning (bc_warn.state, "Octave:broadcast"); + end_unwind_protect + endfunction %!shared v,C,vs,lambda This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |