help-octave
[Top][All Lists]
Advanced

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

Re: How to call existing .oct files from C++?


From: Søren Hauberg
Subject: Re: How to call existing .oct files from C++?
Date: Mon, 31 Mar 2008 08:40:29 +0200

man, 31 03 2008 kl. 15:37 +1100, skrev Charles David Hill:
> I'm writing C++ code for Octave 2.9. I wanted to use the existing
> function "kron" on two matrices, but I can't see how to do that. It
> doesn't seem to be defined in a .h file anywhere. Is it possible to
> call existing .oct files? How do I call kron from within C++?
You can always use the 'feval' function which invokes the intepreter. Of
the top of my head, it would look something like this

#include <octave/parse.h>

Matrix somefun (Matrix &m)
{
  octave_value_list result = feval ("somefun", octave_value (m));
  return result(0).matrix_value ();
}

You would need to do some error checking as well here since you're
invoking the interpreter. But something like this above, might be
useful. It should be said that the Octave manual has a quite good
appendix on writing oct-files, that you really should read.

Søren



reply via email to

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