Open splendiduser opened 1 year ago
Thank you for reporting the issue.
The problem is related to the function __max_nargin_optim__.oct
form the optim package. It is assumed that all functions should be user defined functions. But it is not the case because there are other function types like builtin functions, .oct functions , .mex functions or functions that are created by Coder. I attached a zip file containing the modified version of __max_nargin_optim__.cc
that you can compile using mkoctfile and replace the created .oct file with one that is installed by Octave.
Thank you for reporting the issue.
Short answer: It cannot be fixed!
Long answer:
There are multiple problems. The first is related to the function __max_nargin_optim__.oct
form the optim package. It is assumed that all functions should be user defined functions. But it is not the case because there are other function types like builtin functions, .oct functions , .mex functions or functions that are created by Coder. I attached a zip file containing the modified version of __max_nargin_optim__.cc
that you can compile using mkoctfile and replace the created .oct file with one that is installed by Octave.
max_nargin_optim.zip
Another issude is related to locked functions that in the readme is mentioned that it the .oct file that is created by coder should be called from a function file like this:
function test testfnc_oct end
However the main issue is that in the package optim functions are called by their names instead of calling by their handles. Those names are converted to functions by str2func
. Unfortunately Coder cannot resolve those functions and cannot generate C++ code. Something like eval. They should be function handles.
Ok. Thank you for the quick and detailed response. I understand the reason. I'll consider reporting this to the Octave community.
Thanks for this promising project! I had hopes to use it to circumvent a problem I have with an optimization function which uses lsqnonlin from the optim package to optimize parameters from another function which itself must call lsqnonlin. However, lsqnonlin defines persistent variables which interfere with each other. When using coder to create an oct file, I get errors though. This can be reproduced with the following minimal example:
I'm using the latest Octave 8.4.0 and Coder 1.8.4