From: <tho...@us...> - 2012-04-04 08:46:04
|
Revision: 10141 http://octave.svn.sourceforge.net/octave/?rev=10141&view=rev Author: thomas-weber Date: 2012-04-04 08:45:53 +0000 (Wed, 04 Apr 2012) Log Message: ----------- Fix the short-circuit boolean operators Patch from Rafael Laboissiere <ra...@la...> Modified Paths: -------------- trunk/octave-forge/main/nnet/inst/__newnetwork.m trunk/octave-forge/main/nnet/inst/__trainlm.m trunk/octave-forge/main/nnet/inst/isposint.m trunk/octave-forge/main/nnet/inst/newff.m Modified: trunk/octave-forge/main/nnet/inst/__newnetwork.m =================================================================== --- trunk/octave-forge/main/nnet/inst/__newnetwork.m 2012-04-04 08:36:18 UTC (rev 10140) +++ trunk/octave-forge/main/nnet/inst/__newnetwork.m 2012-04-04 08:45:53 UTC (rev 10141) @@ -143,7 +143,7 @@ error(nargchk(2,2,nargin)) ## check type of arguments - if ( !isscalar(numLayers) | !isposint(numLayers) ) + if ( !isscalar(numLayers) || !isposint(numLayers) ) error("second argument must be a positive integer scalar value!") endif if ( !__checknetstruct(net) ) @@ -169,7 +169,7 @@ error(nargchk(2,2,nargin)) ## check type of arguments - if ( !isscalar(numLayers) | !isposint(numLayers) ) + if ( !isscalar(numLayers) || !isposint(numLayers) ) error("second argument must be a positive integer scalar value!") endif if ( !isstruct(net) ) Modified: trunk/octave-forge/main/nnet/inst/__trainlm.m =================================================================== --- trunk/octave-forge/main/nnet/inst/__trainlm.m 2012-04-04 08:36:18 UTC (rev 10140) +++ trunk/octave-forge/main/nnet/inst/__trainlm.m 2012-04-04 08:45:53 UTC (rev 10141) @@ -231,7 +231,7 @@ endif ## goal can be zero or a positive double - if ( (goal<0) | !(isa(goal,"double")) ) + if ( (goal<0) || !(isa(goal,"double")) ) error("Goal is not zero or a positive real value.") endif @@ -241,31 +241,31 @@ error("maxFail is not a positive integer.") endif - if (!isa(minGrad,"double")) | (!isreal(minGrad)) | (!isscalar(minGrad)) | \ + if (!isa(minGrad,"double")) || (!isreal(minGrad)) || (!isscalar(minGrad)) || \ (minGrad < 0) error("minGrad is not zero or a positive real value.") end ## mu must be a positive real value. this parameter is responsible ## for moving from stepest descent to quasi newton - if ((!isa(mu,"double")) | (!isreal(mu)) | (any(size(mu)) != 1) | (mu <= 0)) + if ((!isa(mu,"double")) || (!isreal(mu)) || (any(size(mu)) != 1) || (mu <= 0)) error("mu is not a positive real value.") endif ## muDec defines the decrement factor - if ((!isa(muDec,"double")) | (!isreal(muDec)) | (any(size(muDec)) != 1) | \ - (muDec < 0) | (muDec > 1)) + if ((!isa(muDec,"double")) || (!isreal(muDec)) || (any(size(muDec)) != 1) || \ + (muDec < 0) || (muDec > 1)) error("muDec is not a real value between 0 and 1.") endif ## muInc defines the increment factor - if (~isa(muInc,"double")) | (!isreal(muInc)) | (any(size(muInc)) != 1) | \ + if (~isa(muInc,"double")) || (!isreal(muInc)) || (any(size(muInc)) != 1) || \ (muInc < 1) error("muInc is not a real value greater than 1.") endif ## muMax is the upper boundary for the mu value - if (!isa(muMax,"double")) | (!isreal(muMax)) | (any(size(muMax)) != 1) | \ + if (!isa(muMax,"double")) || (!isreal(muMax)) || (any(size(muMax)) != 1) || \ (muMax <= 0) error("muMax is not a positive real value.") endif @@ -283,7 +283,7 @@ endif ## check at last the time argument, must be zero or a positive real value - if (!isa(time,"double")) | (!isreal(time)) | (any(size(time)) != 1) | \ + if (!isa(time,"double")) || (!isreal(time)) || (any(size(time)) != 1) || \ (time < 0) error("Time is not zero or a positive real value.") end @@ -301,7 +301,7 @@ error(nargchk(12,12,nargin)); ## show progress - if isfinite(show) & (!rem(iEpochs,show) | length(stop)) + if isfinite(show) && (!rem(iEpochs,show) || length(stop)) fprintf(shortStr); # outputs the training algorithm if isfinite(epochs) fprintf(", Epoch %g/%g",iEpochs, epochs); Modified: trunk/octave-forge/main/nnet/inst/isposint.m =================================================================== --- trunk/octave-forge/main/nnet/inst/isposint.m 2012-04-04 08:36:18 UTC (rev 10140) +++ trunk/octave-forge/main/nnet/inst/isposint.m 2012-04-04 08:45:53 UTC (rev 10141) @@ -42,7 +42,7 @@ endif f = 1; - if ( (!isreal(n)) | (n<=0) | (round(n) != n) ) + if ( (!isreal(n)) || (n<=0) || (round(n) != n) ) f = 0; endif Modified: trunk/octave-forge/main/nnet/inst/newff.m =================================================================== --- trunk/octave-forge/main/nnet/inst/newff.m 2012-04-04 08:36:18 UTC (rev 10140) +++ trunk/octave-forge/main/nnet/inst/newff.m 2012-04-04 08:45:53 UTC (rev 10141) @@ -176,7 +176,7 @@ function checkInputArgs(Pr,ss) ## check if Pr has correct format - if !isreal(Pr) | (size(Pr,2)!=2) + if !isreal(Pr) || (size(Pr,2)!=2) error("Input ranges must be a two column matrix!") endif if any(Pr(:,1) > Pr(:,2)) # check if numbers in the second column are larger as in the first one @@ -192,7 +192,7 @@ endif for k=1:length(ss) sk = ss(k); - if !isreal(sk) | any(sk<1) | any(round(sk)!=sk) + if !isreal(sk) || any(sk<1) || any(round(sk)!=sk) error("Layer sizes is not a row vector of positive integers.") endif endfor This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |