bugGNU Octave - Bugs: bug #32040, ppval fails after use of fnder

 
 

bug #32040: ppval fails after use of fnder

Submitter:  None
Submitted:  Mon 03 Jan 2011 07:05:35 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  kahacjde
Originator Name:  JuanPi Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 15 Apr 2011 09:27:24 AM UTC, comment #8: 

Hello,

I have finally pushed this changeset. Since it changes the interpolations functions as well, there is a risk that something does not work as expected. I have applied it to the default branch only.

Kai

Kai Habel <kahacjde>
Group Member
Wed 16 Mar 2011 11:37:18 PM UTC, comment #7: 

I tried the tests and demos for interp1, mkpp, pchip, ppval, and spline.

Everything work as expected.


Ben Abbott <bpabbott>
Group Member
Wed 16 Mar 2011 09:09:51 PM UTC, comment #6: 

Hello,

this took longer than expected. I have a working changeset, which fixes the incompatibilities with matlab, like the structure filed names and the handling of ND arguments. So, please give it a try and report any problems you observe. Since I have touched interp1 as well, there is a risk that I have broken code that depends on interpolation. I have run  a lot of tests, but there might me some hidden issues.

The script of JuanPi works if ppder is called instead of fnder. 

Kai

(file #22940)

Kai Habel <kahacjde>
Group Member
Wed 09 Feb 2011 07:59:37 PM UTC, comment #5: 

Just an intermediate comment. I have decided to change the pp structures to be compatible with matlab. Until now we were incompatible to large degree with the current matlab versions with respect to the shape of the coefs matrix and other things.

The good news is that I have now compatible mkpp, unmkpp, ppval functions. Currently I am working on spline, pchip, and interp1 to make them also compatible.

After that I have to work on the demos and tests. So this might take some more time.

Kai

Kai Habel <kahacjde>
Group Member
Thu 06 Jan 2011 01:45:22 PM UTC, comment #4: 

I don't have answers to the questions raised, but I will have a look at the problem described by Juan.

Kai

Kai Habel <kahacjde>
Group Member
Thu 06 Jan 2011 12:45:54 PM UTC, comment #3: 

I noticed the difference in fields as well. Perhaps ...

  1. Change the structures to that used by ML.
  2. Write a simple function do convert between the current structure and the ML one, and call it when needed.


Regarding the size change, I'me not certain, but I suspect it is/was intended to allow more than one piecewise polynomial (see "demo mkpp").

My spare time for Octave is directed to fixing printing on WIndows (MinGW). Once that is done, I can take a look at this. However, it would better if someone more familiar with how this work and where it is used took a look.




Ben Abbott <bpabbott>
Group Member
Thu 06 Jan 2011 07:26:15 AM UTC, comment #2: 

It appears the Matlab spline and fnder functions create structures with the fields 'form', 'breaks', 'coefs', 'pieces', 'order', and 'dim', but Octave produces structures with the fields 'x', 'd', 'P', and 'orient' (for both) and also 'k' for fnder.  What's the reason for the difference?  Is this something that we should try to fix before the release?  I imagine someone somewhere depending on these fieldnames, so they might as well be the same...

Also, it seems the orientation of the P field has changed.  For the example below, pp.P is 1x9x4 now, but in 3.2.4 it is 9x4.  Why has this changed?  In Matlab, it is apparently 9x4 (and called coefs instead of P).

John W. Eaton <jwe>
Group administrator
Tue 04 Jan 2011 02:50:55 PM UTC, comment #1: 

I noticed the demo for mkpp no longer runs. Perhaps the changeset which improved the compatibility with ML has resulted in breaking some older code. The changeset is linked to below.

http://hg.savannah.gnu.org/hgweb/octave/rev/31900e17b5f5

However, it doesn't look to me like the problem is with mkpp, but with fnder. Looking at ppd, there are 9 different regions for which polynomials must be specified. However, ppd.P only includes coefficients for 8 regions. Thus when the evaluating within the last region an error occurs.


dyi = ppval(ppd,ppd.x(1:end-2));
dyi = ppval(ppd,ppd.x(1:end-1)-eps);
dyi = ppval(ppd,ppd.x(1:end-1));
error: ppval: A(I,J,...): index to dimension 2 out of bounds; value 9 out of bound 8


I've cc'd Kai Habel.

Ben Abbott <bpabbott>
Group Member
Mon 03 Jan 2011 07:05:35 PM UTC, original submission:  

The following lines where giving no errors in Octave 3.2.4 (Ubuntu 10.10)


x = linspace(0,1,10);
y = sin(2*pi*3*x);
pp = spline(x, y);
xi = 0:0.3:1;
yi = ppval(pp,xi);
ppd = fnder(pp,1);
dyi = ppval(ppd,xi);


In 3.3.54 and the repository version the last line gives the following error


error: ppval: A(I,J,...): index to dimension 2 out of bounds; value 9 out of bound 8
error: called from:
error:   ppval.m at line 69, column 4


If I change xi for


xi=linspace(0,8/9-eps,10);


then

dyi = ppval(ppd,xi);


works fine

output of

> pkg list
Package Name       | Version | Installation directory
-------------------+---------+-----------------------
   communications *|  1.0.10 | /home/juanpi/octave/communications-1.0.10
              fpl  |   1.2.0 | /home/juanpi/octave/fpl-1.2.0
          general *|   1.2.1 | /home/juanpi/octave/general-1.2.1
               io *|  1.0.13 | /home/juanpi/octave/io-1.0.13
   linear-algebra *|   2.0.0 | /home/juanpi/octave/linear-algebra-2.0.0
    miscellaneous *|  1.0.10 | /home/juanpi/octave/miscellaneous-1.0.10
missing-functions *|   1.0.2 | /home/juanpi/octave/missing-functions-1.0.2
              msh  |   1.0.1 | /home/juanpi/octave/msh-1.0.1
              nan  |   2.3.1 | /home/juanpi/octave/nan-2.3.1
           odepkg *|  0.6.10 | /home/juanpi/octave/odepkg-0.6.10
            optim *|  1.0.15 | /home/juanpi/octave/optim-1.0.15
      optiminterp *|   0.3.2 | /home/juanpi/octave/optiminterp-0.3.2
             plot *|   1.0.8 | /home/juanpi/octave/plot-1.0.8
           signal *|  1.0.11 | /home/juanpi/octave/signal-1.0.11
          specfun *|   1.0.9 | /home/juanpi/octave/specfun-1.0.9
          splines *|   1.0.7 | /home/juanpi/octave/splines-1.0.7
       statistics *|  1.0.10 | /home/juanpi/octave/statistics-1.0.10
           struct *|   1.0.8 | /home/juanpi/octave/struct-1.0.8


Checked in the dev compiled for Ubuntu 10.10

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #22940:  Changeset.pp added by kahacjde (29KiB - application/octet-stream)
file #22340:  config.status added by None (132KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by siko1056 (Updated the item)
  • -email is unavailable- added by kahacjde (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by bpabbott (Posted a comment)
  • -email is unavailable- added by bpabbott
  • -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
    2015-09-28 siko1056 StatusPatch Submitted Fixed
    2011-04-15 kahacjde Open/ClosedOpen Closed
    2011-03-16 kahacjde Attached File- Added Changeset.pp, #22940
        StatusIn Progress Patch Submitted
    2011-01-16 kahacjde StatusNone In Progress
    2011-01-16 kahacjde Assigned toNone kahacjde
    2011-01-04 bpabbott Carbon-Copy- Added -email is unavailable-
    2011-01-03 None Attached File- Added config.status, #22340

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code