help-octave
[Top][All Lists]
Advanced

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

Re: Calling fsolve from C++


From: tmacchant
Subject: Re: Calling fsolve from C++
Date: Sat, 3 May 2014 04:32:32 -0700 (PDT)

>Hello, 
>
>I'm a Computer Engineering undergrad student from Brazil and saw a reply in
a thread about using fsolve >function inside a C++ program. The post
contained this hints: 
>
>1a. prepare your objective function as a C++ function, using Octave's 
>Array classes as inputs/outputs 
>1b. wrap it in an octave_builtin object 
>OR 
>1ab. prepare your objective as an m-file function 
>2. initialize Octave interpreter 
>3. call fsolve through the feval interface (parse.h) 
>
>Could you present me a working example in this case? How can I define a
non-linear function just using >Array classes? I managed to use feval
interface to run fzero function, but passing an inline function handle >and
it works. But how can I represent this set of functions in C++? 
>
>function y = f (x) 
>  y = zeros (2, 1); 
>  y(1) = x(1)^2 + x(2)^2 - 36; 
>  y(2) = x(1)^2 - x(2)^2 - 1; 
>endfunction 
>
>[xy, fval] = fsolve ('f', [-5; 5]); 
>
>King regards, 
>Victor Nascimento

The fsolve function is implemented by m file.
You could call its functionality from C++.
I cannot show you the working example but show a clue. 
See octave documentation:

http://www.gnu.org/software/octave/doc/interpreter/Standalone-Programs.html#Standalone-Programs

Example of calling build-in function gcd will give you a hint.

Good luck!

Tatsuro 




--
View this message in context: 
http://octave.1599824.n4.nabble.com/Calling-fsolve-from-C-tp4663888p4663890.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

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