help-octave
[Top][All Lists]
Advanced

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

Re: standalone application (octave to c++): define anonymous function fo


From: Kai Torben Ohlhus
Subject: Re: standalone application (octave to c++): define anonymous function for nonlin_curvefit()
Date: Mon, 28 Jan 2019 14:20:52 +0100

On Mon, Jan 28, 2019 at 2:16 PM Doug Stewart <address@hidden> wrote:
On Mon, Jan 28, 2019 at 7:53 AM ola <address@hidden> wrote:
I have tried to declare:
octave_user_function f = @(p,x) 1-exp(p*x);
but I've got 1) error: stray address@hidden in program and 2) error: ‘p, x’ was not
declared in this scope

Why the octave interpreter doesn't understand @ sign?
How to properly declare an anonymous function or how to write a function
that will return an object octave_user_function?
Should I provide any additional headers (include <???>) when declaring
anonymous functions?
Maybe there is another way to transfer user function (@(p,x) 1-exp(p*x)) as
an argument for octave::feval?

It would be really great if I could use this function. My ideas for a
solution are exhausted. I need your help.



-----
ola
--

does this help

>>str1='@(p,x) 1-exp(p*x);'
     str1 = @(p,x) 1-exp(p*x);
>>fh=str2func(str1)
      fh = @(p, x) 1 - exp (p * x)
>> fh(2,4)
       ans = -2980.0

start with a string  use octave to convert it to a function handle and the use feval  from c++





--
DASCertificate for 206392

To my understanding, ola wants to entirely work on C++-level to avoid any usage of the Octave interpreter.  Maybe you need to give us (at least me) a more complete example to help you.  Can you for example upload your C++-standalone-application to https://pastebin.com/ or alike?

Kai

reply via email to

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