[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Calling octave from within an external program
From: |
John W. Eaton |
Subject: |
Re: Calling octave from within an external program |
Date: |
Tue, 8 Feb 2000 02:42:33 -0600 (CST) |
On 8-Feb-2000, Steven G. Johnson <address@hidden> wrote:
| > Maybe i just haven't looked at the right places but i'd like to call
| > some of the octave functions from C/C++ programs i have written. I can
| > do this in matlab using their math libraries. Does octave have an
| > equivalent. If not, how would i do this?
|
| I don't think Octave is designed for this (if it exists, that functionality
| is not documented).
You are right that it is not really documented, but it would not be
impossible to compile all of Octave except the main program into a
set of libraries (this is already done, octave.cc is the main program)
and then write a program that calls eval() or feval() from the library
to execute arbitrary Octave code. I haven't actually tried doing this
myself, except with the main program for the Octave interpreter that
is defined in octave.cc.
| If you just want to use the matrix operations
| (multiply, invert, eigenvalues, etcetera), you might consider directly
| calling the same (free) libraries that Octave uses to implement its
| operations: BLAS and LAPACK. See www.netlib.org/lapack for more info.
I find some advantage to having the C++ classes instead of calling
Lapack (for example) directly. To me, something like
Matrix A;
// initialize elements of A somehow...
SVD svd_of_A (A);
cout << "U: " << svd_of_A.left_singular_matrix ();
...
is much simpler than the corresponding Fortran, which involves setting
up a workspace array of the right size, and calling a function
(dgesvd) that takes 14 parameters.
jwe
-----------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.che.wisc.edu/octave/octave.html
How to fund new projects: http://www.che.wisc.edu/octave/funding.html
Subscription information: http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------