The quadc function of the integration package, version 1.0.7 fails against
Octave 3.0.5 on my Debian sid system like this:

$ cd inst
$ octave -q
octave:1> addpath ("./test", "-begin")
octave:2> addpath ("./testfun", "-begin")
octave:3> quadc ('gxy1', -1, 1)
warning: value of local variable `cb4' may have changed to match global
warning: value of local variable `cw4' may have changed to match global
error: product: nonconformant arguments (op1 is 0x0, op2 is 0x1)
error: evaluating binary operator `.*' near line 2, column 12
error: evaluating argument list element number 1
error: evaluating binary operator `*' near line 2, column 16
error: evaluating assignment expression near line 2, column 4
error: evaluating for command near line 61, column 1
error: called from `quadc' in file
`/home/rafael/devel/debian/PKGS/octave-forge-pkgs/octave-integration/octave-integration/inst/quadc.m'
error: evaluating assignment expression near line 3, column 2

It seems that there are wrong assumptions in the code about the way global
variables work.  A patch that fixes the bug is attached below.  Please, tell
me whether I should SVN commit it.

-- 
Rafael Laboissiere
The "global" statement in Octave 3.0.5 initializes the variable with
an empty vector.  Hence, the exist() will always succeed for variables
declared global.  Also, global statements should always come before
the variables are assigned values.

This patch fixes both problems in function quadc.

 -- Rafael Laboissiere <[email protected]>  Fri, 22 May 2009 20:49:52 +0200

--- a/inst/quadc.m
+++ b/inst/quadc.m
@@ -45,7 +45,7 @@
 jacob=(xhigh-xlow)/2;
 
 %generate the first two sets of integration points and weights
-if ( exist('cb2') != 1 )
+if ( exist('cb2') != 1 || isempty (cb2) )
   [cb2,cw2]=crule(2);
 endif
 
@@ -62,10 +62,10 @@
   gnum=int2str(2^(i+1));
   vname = ['cb',gnum];
   if ( exist(vname) == 0 )
-    estr =['[cb',gnum,',cw',gnum,']=crule(',gnum,');'];
-    eval(estr);
     estr =['global cb' gnum,' cw',gnum,';'];
     eval(estr);
+    estr =['[cb',gnum,',cw',gnum,']=crule(',gnum,');'];
+    eval(estr);
   endif
   estr = ['x=(cb',gnum,'+1)*jacob+xlow;'];
   eval(estr);
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
_______________________________________________
Octave-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to