Evaluation of binary expression

Ben Abbott bpabbott at mac.com
Mon Apr 7 13:05:41 CDT 2008


On Monday, April 07, 2008, at 01:16PM, "Michael Hiegemann" <michael.hiegemann at gmx.ch> wrote:
>Hello,
>
>first of all: Thanks for providing such an exciting system to us!
>
>I am using octave-3.0.0 on a Windows XP computer and tried to use the bug_report command, but it failed for some reason I was unable to find out. Thus, I will provide you with a hand-written bug report.
>
>My goal was to execute some functions in .m-files from an old MatlabR12 installation that we purchased some years ago. These are dealing with the iterative solution of linear equation systems. There are four files attached to this email, which I have all put in the same folder. After having typed the respective addpath command I succeeded to call the functions themselves, but got stuck with the execution of the function.
>
>
>Here is the sequence of commands in detail:
>
>octave-3.0.0.exe:1> addpath('D:/Data/Michael/octave/sparfun')
>octave-3.0.0.exe:2> A = [1,1;-1,1];
>octave-3.0.0.exe:3> b = [3;1];
>octave-3.0.0.exe:4> tol = 1.0e-6;
>octave-3.0.0.exe:5> maxit = 1000;
>octave-3.0.0.exe:6> x = cgs(A, b, tol, maxit)
>error: `M1' undefined near line 90 column 30
>error: evaluating argument list element number 1
>error: evaluating prefix operator `!' near line 90, column 21
>error: evaluating binary operator `&' near line 90, column 19
>error: if: error evaluating conditional expression
>error: evaluating if command near line 90, column1
>error: called from `cgs' in file `D:/Data/Michael/octave/sparfun\cgs.m'
>error evaluating assignment expression near line 21, column 3
>octave-3.0.0.exe:7>
>
>
>
>The problem obviously is in line 90 of cgs.m (my version of it), which is
>
>if ((nargin >= 5) & ~isempty(M1))
>
>I tend to say that the evaluation of the second expression of the binary operator `&' should be suppressed in case the evaluation of the first expression did already provide a negative result. This is my understanding of the treatment of respective expressions in C language, i.e. by e.g. the VC8 compiler, and this seems to be the treatment of the (old) Matlab engine as well.
>
>Best regards,
>

The behavior you've encountered reflects how my matlab works.

>> nargin = 4

nargin =

     4

>> ((nargin >= 5) & ~isempty(M1))
??? Undefined function or variable 'M1'.

Thus, in this instance, it appears that Octave works in a manner consistent/compatible with Matlab.

Perhaps the parser might be modified to respect the behavior you'd prefer, but I have no knowledge of that.

Ben







More information about the Bug-octave mailing list