Calling Octave built in functions from C, not C++

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Calling Octave built in functions from C, not C++

Allan Branscomb
Hello;

Searching the Octave user manual, the email archives, and the Web, I can
find examples in which Octave built-in functions are called from C++ but
none from C.

There is mention that it can be done but I haven't been able to find any
examples in which C is the calling language.

The task is to call the polyfit and polyval functions from a C
function.  I've implemented this from C to Matlab but don't see how it
is done with Octave.

I want to call these functions directly, without use of the Octave
interpreter.  I found a discussion on the Web in which it is stated that
built-in functions can be called without use of the interpreter and for
performance reasons would prefer this approach if possible.

Thanks for your help;
Allan





Reply | Threaded
Open this post in threaded view
|

Re: Calling Octave built in functions from C, not C++

Carlo de Falco-2


> On 26 Jan 2019, at 03:29, Allan Branscomb <[hidden email]> wrote:
>
> There is mention that it can be done but I haven't been able to find any examples in which C is the calling language.

Where did you find mention of that? builtin functions are declared as :

extern OCTINTERP_API octave_value_list
Fnorm (const octave_value_list& = octave_value_list (), int = 0);

and "octave_value_list" is definitely not a C compatible type ...

c.

Reply | Threaded
Open this post in threaded view
|

Re: Calling Octave built in functions from C, not C++

Andreas Weber-6
In reply to this post by Allan Branscomb
Am 26.01.19 um 03:29 schrieb Allan Branscomb:
> The task is to call the polyfit and polyval functions from a C
> function ... I want to call these functions directly, without use of the Octave
> interpreter.

Have you had a look how these functions are implemented in GNU Octave?
You won't be able to run these without interpreter.

I think the best option for you is to pick one of the many C libraries
which can do that, for example GSL - GNU Scientific Library

-- Andy


Reply | Threaded
Open this post in threaded view
|

Re: Calling Octave built in functions from C, not C++

Carlo de Falco-2
In reply to this post by Carlo de Falco-2
Please keep the mailing list in

> On 1/26/19 3:02 AM, Carlo De Falco wrote:
>>
>>> On 26 Jan 2019, at 03:29, Allan Branscomb <[hidden email]>
>>>  wrote:
>>>
>>> There is mention that it can be done but I haven't been able to find any examples in which C is the calling language.
>>>
>> Where did you find mention of that? builtin functions are declared as :
>>
>> extern OCTINTERP_API octave_value_list
>> Fnorm (const octave_value_list& = octave_value_list (), int = 0);
>>
>> and "octave_value_list" is definitely not a C compatible type ...
>>
>> c.
>
>
> On 27 Jan 2019, at 17:15, Allan Branscomb <[hidden email]> wrote:
>
> Hello;
>
> The reference is found here:  http://www.obihiro.ac.jp/~suzukim/masuda/octave/html3/octave_193.html 

that is a very old version of the Octave manual from more tha 10 years ago!
The updated manual is here :

http://octave.org/doc/interpreter
http://octave.org/doc/interpreter/External-Code-Interface.html

> " These are highly optimized and many do not carry the overhead of being interpreted."


Where does that say you can call builtins from a C standalone program?
It does say you can call C code from Octave, but that is not what you want, right?


> However, I was concerned with calling Octave just two commonly used functions from standalone C, not calling C functions from within Octave and was trying to determine if it also would be possible to avoid use of the interpreter by calling them from C outside of the Octave environment.

That is definitely possible for C++. I don't think it is easy to do from C.

On the other hand, many Octave built-in functions are not implemented from scratch but rather use backend libraries.
Many such libraries are written in C or F77 so, if you specify what functions you want to use we might direct you to the libraries that Octave uses to implement them.


> Allan

c.