octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #59477] __ode15__.cc does not consider the num


From: Hg200
Subject: [Octave-bug-tracker] [bug #59477] __ode15__.cc does not consider the number of arguments in the event function
Date: Tue, 17 Nov 2020 18:15:39 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:82.0) Gecko/20100101 Firefox/82.0

URL:
  <https://savannah.gnu.org/bugs/?59477>

                 Summary: __ode15__.cc does not consider the number of
arguments in the event function
                 Project: GNU Octave
            Submitted by: hg200
            Submitted on: Tue 17 Nov 2020 11:15:37 PM UTC
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Regression
                  Status: None
             Assigned to: None
         Originator Name: Hg200
        Originator Email: 
             Open/Closed: Open
                 Release: dev
         Discussion Lock: Any
        Operating System: Any

    _______________________________________________________

Details:

This is an interface problem in the function ode15s(), which manifests since
cset 28562:b0b80efecea1 "error for functions called with too many inputs or
outputs". The attached minimal example for ode15s() runs fine with Matlab
R2018 and also with Octave 6.0.9x, but it fails on the development branch. The
reason for the error is the following:

According to Matlab and its documentation the event function of ode15s() has
two input parameters:

++
ode_events (t, y)
--

But the event function of ode15i() has three input parameters:

++
ode_events (t, y, yp)
--

ode15s() and ode15i() are both implemented in the file ___ode15___.cc. In
___ode15___.cc around line 766 (IDA::event), however, the event function is
evaluated with three input parameters:

++
octave_value_list args = ovl (tsol, y, yp);
...
octave_value_list output = feval (event_fcn, args, 3);
--

In the case of ode15s(), however, the event callback has only two parameters.
Therefore you get following error when running the attached example on default
branch:

++
error: ode_events: function called with too many inputs
error: called from
    ode15sfun>ode_events
    ode15s at line 315 column 22
    ode15sfun at line 14 column 22
--

The relation to cset b0b80efecea1 is, that before b0b80efecea1 the number of
arguments was not checked when calling a function. But now they are checked
and if they do not match, the error is thrown. Furthermore b0b80efecea1 is not
merged to stable and therefore this problem does not yet manifest on stable.

Fixing ideas: If we want to maintain the use of "yp" in ode15s() we need to
determine the number of input arguments of "event_fcn" and based on this we
could compute different sized "args" in IDA::event. In pseudo code something
like this:

++
if (nargin(@event_fcn) == 2)
  octave_value_list args = ovl (tsol, y);
else
  octave_value_list args = ovl (tsol, y, yp);
...
octave_value_list output = feval (event_fcn, args, 3);
--

Typically in Octave C code the number of input arguments "nargin" of a
function is taken from the argument list "args.length ()". But we only have
the function handle. Is it possible to determine the number of input arguments
also from a pure function handle?

Other ideas to fix this issue?




    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Tue 17 Nov 2020 11:15:37 PM UTC  Name: ode15sfun.m  Size: 612B   By:
hg200

<http://savannah.gnu.org/bugs/download.php?file_id=50293>

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?59477>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]