bugGNU Octave - Bugs: bug #50192, ode15s does not work when the...

 
 

bug #50192: ode15s does not work when the initial value is a row

Submitter:  Marco Caliari <caliari>
Submitted:  Tue 31 Jan 2017 10:15:12 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Fixed Assigned to:  None
Originator Name:  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

Wed 06 Sep 2017 04:09:18 PM UTC, comment #10: 

Thanks for the review.  I changed the text in this cset (http://hg.savannah.gnu.org/hgweb/octave/rev/3d65720cd68a).

Rik <rik5>
Group administrator
Wed 06 Sep 2017 03:26:30 PM UTC, comment #9: 

@Rik: in the second testif you added in ode15s.m (or, last line of ode15s.m) YP0 should be replaced by Y0.

Marco Caliari <caliari>
Group Member
Tue 05 Sep 2017 06:50:11 PM UTC, comment #8: 

@Marco: I committed a modified version of your patch here (http://hg.savannah.gnu.org/hgweb/octave/rev/6e7bb85e32b8).  I decided not to rename y0 and yp0 since those are the names that Matlab uses and many users may be familiar with them.

Thus, the change was principally to check_default_input which now validates y0 and yp0 more carefully, and then transforms them to column vectors.

Perhaps you could pull and then run


test ode15i
test ode15s


and see if everything still passes.  I don't have SUNDIALS so these tests are all skipped on my computer.


Rik <rik5>
Group administrator
Thu 09 Feb 2017 10:37:55 AM UTC, comment #7: 

The new patch for check_default_input.m now checks for nonnumeric or nonvector init or initp and transform them into columns. I changed y0 into init and y0p into initp everywhere (or should I have changed init into y0 in both ode45 and ode23?). I added tests for initial row vectors (now allowed) and nonvector initial values (an initial value as a square matrix produces a segfault, without this patch).

Should be ode23 and ode45 modified in order to use check_dafault_input?

(file #39709)

Marco Caliari <caliari>
Group Member
Wed 08 Feb 2017 05:25:14 PM UTC, comment #6: 

Good point, I will modify the patch.

Marco Caliari <caliari>
Group Member
Wed 08 Feb 2017 04:42:17 PM UTC, comment #5: 

This time the patch uploaded correctly.  I have a question, would it not be better to check that the initial conditions are vectors, and then force them to be column vectors?  This is what is doen in ode23.m as shown below:


  if (! isnumeric (init) || ! isvector (init))
    error ("Octave:invalid-input-arg",
           "ode23: INIT must be a numeric vector");
  endif
  init = init(:);


The current patch changes private/check_default_input.m


-    n = numel (feval (fun, trange(1), y0, yp0));
+    n = numel (feval (fun, trange(1), y0(:), yp0(:)));


This will allow matrices through because they will be turned into column vectors, when in fact the user has probably made some mistake by using a matrix as input.

Rik <rik5>
Group administrator
Wed 08 Feb 2017 07:47:24 AM UTC, comment #4: 

I try again to upload the patch.

(file #39702)

Marco Caliari <caliari>
Group Member
Wed 08 Feb 2017 05:18:55 AM UTC, comment #3: 

I'm unable to download the patch you attached.  This might be something wrong with Savannah, or it might be that your upload was corrupted.  Could you try putting the file on Savannah again?

Rik <rik5>
Group administrator
Sun 05 Feb 2017 05:20:08 PM UTC, comment #2: 

Done. I allowed ode15i to work with both y0 and y0p row vectors, as written in the documentation, although the following


A=eye(2);,[tout, yout] = ode15i (@(t, y, yp) A * y - A * yp, [0, 1], [1, 1], [1, 1]);


does not work in Matlab R2014b.
Moreover, in all the integrators I see a sentence like


@var{init} contains the initial value for the unknowns.  If it is a row vector then the solution @var{y} will be a matrix in which each column is the solution for the corresponding initial value in @var{init}.


This is true, but it is true also if @var{init} is a column vector.

(file #39673)

Marco Caliari <caliari>
Group Member
Sun 05 Feb 2017 03:37:55 PM UTC, comment #1: 

Can you prepare a cset for this with a few BIST tests?  The solution seems quite simple.

Rik <rik5>
Group administrator
Tue 31 Jan 2017 10:15:12 AM UTC, original submission:  

The following code


A=eye(2);,f=@(t,y) A*y;,ode15s(f,[0,1],[1,1])


does not work, while it works in Matlab and works in Octave with ode23 and ode45 instead of ode15s. I guess it is enough to change y0 to y0(:) around lines 56 and 59 of check_default_input.m (probably the same with yp0).

Marco Caliari <caliari>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #39709:  ode15s.diff added by caliari (14KiB - application/x-tex)
file #39702:  ode15s.diff added by caliari (5KiB - application/x-tex)
file #39673:  ode15s.diff added by caliari (5KiB - application/x-tex)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by caliari (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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-09-06 rik5 StatusPatch Reviewed Fixed
    2017-09-06 caliari StatusFixed Patch Reviewed
    2017-09-05 rik5 StatusNone Fixed
        Open/ClosedOpen Closed
    2017-02-09 caliari Attached File- Added ode15s.diff, #39709
    2017-02-08 caliari Attached File- Added ode15s.diff, #39702
    2017-02-05 caliari Attached File- Added ode15s.diff, #39673

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code