[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: How to call existing .oct files from C++?
From: |
Charles David Hill |
Subject: |
RE: How to call existing .oct files from C++? |
Date: |
Mon, 31 Mar 2008 20:10:04 +1100 |
Thankyou to Soren and everyone who replied to my post,
Yes, I've read the appendix and it's definitely good for me to get started, and that is what I want to do - however if possible I don't want to have the extra overhead of calling feval() and invoking the interpreter. Is there any way that I can link directly from C++ to existing .oct files? At the moment I have used the octave source code to compile it to a .o file, and linked to that in but that seems like a kludge on my part.
My code wants to look something like this (with type checking and error checking to come):
======
DEFUN_DLD (tensor, args, nargout, "Tensor product")
{
// Create a tensor product of many possible values
// Return value
octave_value_list retvalue;
// Get the number of arguments
int numMatrices = args.length();
// Get the first argument
ComplexMatrix a (args(0).complex_matrix_value());
numMatrices--;
ComplexMatrix b, c;
// Loop over the inputs
while (numMatrices > 0) {
b = (ComplexMatrix) args(numMatrices).complex_matrix_value();
if (!error_state) {
ComplexMatrix c;
kron (a, b, c);
a = c;
numMatrices--;
}
}
retvalue(0) = a;
return retvalue;
}
======
My system is Ubuntu 7.10, using gcc 4.1.3, octave 2.9.12 (using the same version of mkoctfile to C++ compile files for use with octave). Everything so far is going pretty well - I'm just wondering if linking against .oct files is possible.
Thanks again for all your help,
Charles.