bugGNU Octave - Bugs: bug #30295, interpN input validation needs...

 
 

bug #30295: interpN input validation needs improvement

Submitter:  None
Submitted:  Tue 29 Jun 2010 07:26:44 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Matěj Týč Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.4.2
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 19 Sep 2011 12:31:35 PM UTC, comment #8: 

Good suggestion!

I've pushed a change.

http://hg.savannah.gnu.org/hgweb/octave/rev/6b6d0e51bd2f

Ben Abbott <bpabbott>
Group Member
Mon 19 Sep 2011 03:01:25 AM UTC, comment #7: 

My only comment would be to check for an integer using


m == fix (m)

rather than

round (m) == m


One can use any of the chopping functions (fix, floor, ceil, round) for this test.  I've benchmarked them all in prior work and fix() is the fastest.  I'm trying to get this convention established in the Octave code rather than the "x == round (x)" which is ubiquitous in Matlab code.

Rik <rik5>
Group administrator
Sun 18 Sep 2011 02:00:12 AM UTC, comment #6: 

The last changeset is below.

http://hg.savannah.gnu.org/hgweb/octave/rev/e173fda06fca

I'll leave this open for testing.

Ben Abbott <bpabbott>
Group Member
Sat 17 Sep 2011 08:17:54 PM UTC, comment #5: 

The problem with interp3 is trivial. The changeset is below.

http://hg.savannah.gnu.org/hgweb/octave/rev/621108cf81d1

The remaining problem is with interpn(). With Matlab ...


>> interpn ([1, 3;3, 5])

ans =

     1     2     3
     2     3     4
     3     4     5


... and Octave ...


>> interpn ([1 3; 3 5])
error: interpn: subscript indices must be either positive integers or logicals
error: called from:
error:   /Users/bpabbott/Development/mercurial/stable/scripts/general/interpn.m at line 77, column 3


If the interleave factor is explicitly set to one, the result is still incorrect.


>> interpn ([1 3; 3 5], 1)
ans =

   1   3   5


I'm changing the summary again to better represent the bug.

Ben Abbott <bpabbott>
Group Member
Sat 17 Sep 2011 07:24:19 PM UTC, comment #4: 

I've pushed a change to fix the problem with interp2.

http://hg.savannah.gnu.org/hgweb/octave/rev/ab17591254fc

Ben Abbott <bpabbott>
Group Member
Sat 17 Sep 2011 05:34:33 PM UTC, comment #3: 

I'm changing the release to 3.4.2 and modifying the summary to indicate both interp2 and interp3.

Ben Abbott <bpabbott>
Group Member
Sat 17 Sep 2011 05:32:59 PM UTC, comment #2: 

Both  bug #30121, and bug #29601 have been resolved. However, there remain some problems.

For example, with Matlab ...


>> z = rand (2)

z =

    0.9575    0.1576
    0.9649    0.9706

>> interp2 (z)

ans =

    0.9575    0.5576    0.1576
    0.9612    0.7627    0.5641
    0.9649    0.9677    0.9706


... and with Octave ...


>> z = rand (2)
z =

   0.41641   0.67924
   0.99412   0.22598

>> interp2 (z)
ans = [](0x0)


The 3D problems also persists. Matlab ...


>> z = rand (2,2,2)

z(:,:,1) =

    0.9572    0.8003
    0.4854    0.1419


z(:,:,2) =

    0.4218    0.7922
    0.9157    0.9595

>> interp3 (z)

ans(:,:,1) =

    0.9572    0.8787    0.8003
    0.7213    0.5962    0.4711
    0.4854    0.3136    0.1419


ans(:,:,2) =

    0.6895    0.7429    0.7962
    0.6950    0.6842    0.6735
    0.7006    0.6256    0.5507


ans(:,:,3) =

    0.4218    0.6070    0.7922
    0.6687    0.7723    0.8758
    0.9157    0.9376    0.9595


... and Octave ...


>> z = rand (2,2,2)
z =

ans(:,:,1) =

   0.11037   0.44427
   0.95039   0.84076

ans(:,:,2) =

   0.6432694   0.4045125
   0.0024695   0.4168376

>> interp3 (z)
error: interp3: subscript indices must be either positive integers or logicals
error: called from:
error:   /Users/bpabbott/Development/mercurial/default/scripts/general/interp3.m at line 76, column 3


Ben Abbott <bpabbott>
Group Member
Thu 01 Jul 2010 04:18:57 AM UTC, comment #1: 

This is confirmed on a recent hg tip (10736:14af8004945d) running on GNU/Linux.

In general, all of the interp functions need to be reworked as evidenced by this bug, bug #30121, and bug #29601.

Rik <rik5>
Group administrator
Tue 29 Jun 2010 07:26:44 PM UTC, original submission:  

Hello,
I am quite sure that there is something wrong with arguments parsing in interp3 (it is, among other things, done in quite different way than in interp2)
In short, see the output:

octave:30> interp2(rand(2,2));
octave:31> interp3(rand(2,2,2));
error: subscript indices must be either positive integers or logicals.
error: called from:
error:   /usr/share/octave/3.2.4/m/general/interp3.m at line 73, column 3
octave:32> interp3(rand(2,2,2), 'linear');
error: A(I): Index exceeds matrix dimension.
error: called from:
error:   /usr/share/octave/3.2.4/m/general/interp3.m at line 91, column 7

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bpabbott (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-09-27 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2011-09-18 bpabbott StatusConfirmed Ready For Test
    2011-09-17 bpabbott Summaryinterp2 / interp3 input validation needs improvement interpN input validation needs improvement
    2011-09-17 bpabbott Release3.2.4 3.4.2
        Summaryinterp3 input validation needs improvement interp2 / interp3 input validation needs improvement
    2010-07-01 rik5 StatusNone Confirmed
        Summaryinterp3 call fails interp3 input validation needs improvement

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code