On Sun, Jan 16, 2011 at 05:47:34PM +0100, Michael Creel wrote:
> On Sun, Jan 16, 2011 at 2:18 PM, Olaf Till <[email protected]> wrote:
> 
> > I'm about to cleanup some warnings "possible Matlab-style
> > short-circuit operator" by new Octave in the optim package. A few of
> > them are in bfgsmin.m. Micheal, may I clean these up, too?
> >
> > Olaf
> >
> 
> 
> Hi Olaf,
> Sure, please do. Just please check that bfgsmin_example.m keeps on working
> as it should. Out of curiosity, could you give me an example of the code
> that causes the problem and what the replacement would be?
> Cheers,
> Michael

The warnings were:

warning: /usr/local/share/octave/packages/optim-1.0.16/bfgsmin.m: possible 
Matlab-style short-circuit operator at line 90, column 34
warning: /usr/local/share/octave/packages/optim-1.0.16/bfgsmin.m: possible 
Matlab-style short-circuit operator at line 90, column 19
warning: /usr/local/share/octave/packages/optim-1.0.16/bfgsmin.m: possible 
Matlab-style short-circuit operator at line 90, column 45
warning: /usr/local/share/octave/packages/optim-1.0.16/bfgsmin.m: possible 
Matlab-style short-circuit operator at line 98, column 17

so the lines

        if (((tmp !=Inf) & (tmp != -1)) & (tmp > 0 & (mod(tmp,1) != 0)))

and

        if ((tmp != 0) & (tmp != 1))

have to be changed to

        if (((tmp !=Inf) && (tmp != -1)) && (tmp > 0 && (mod(tmp,1) != 0)))

and

        if ((tmp != 0) && (tmp != 1))

to convince new Octave that circuiting logic is really applicable
here. It obviously is. And the change does not change behavior of new
Octave during execution, it just avoids the warnings.

I also checked bfgsmin_example. The output is the same before and
after the change (except random differences in "Elapsed time" and that
with new Octave the warnings are gone after the change, as intended).

The change is committed to the repository.

Thanks for the prompt reply on Sunday :-)

Olaf

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Octave-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to