[Top][All Lists]

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

Re: Using expm in C++

From: c.
Subject: Re: Using expm in C++
Date: Tue, 7 Feb 2012 17:25:18 +0100

On 7 Feb 2012, at 03:07, loisp wrote:

> I need to call just expm() and I don't know how to write a C++ API for 
> expm.m. I have also tried Mathias Michel's guide without any success. 

If I understand correctly what you want to do is write a stand-alone C++ 
program that can call functions defined as m-files.
What you want to do is usually referred to as "embedding" the Octave 
interpreter in your C++ application, if you google that phrase
you'll find more info and examples, but to get started you can just have a look 
at this example in the Octave source tree:

the essential parts of the example are:

1) the call to "octave_main" on line 13: 

  octave_main (2, argv.c_str_vec(), 1);

 which initializes the Octave intepreter

2) lines 29 and 30 that set up an "octave_value_list" object with the inputs 
for the m-file function,
   call the function via "feval" and collect the output in another 
"octave_value_list" object.

Beware that using this feature the performance of the code will be limited by 
the interpreter speed,
so if you use this a lot you might be better off writing your whole code in the 
Octave interpreter language
rather than in C++ as using the C++ API will not give you any speed-up.


reply via email to

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