[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: use octave library in program stand alone
From: |
Jordi Gutiérrez Hermoso |
Subject: |
Re: use octave library in program stand alone |
Date: |
Tue, 6 Sep 2011 16:14:34 -0500 |
On 5 September 2011 12:15, address@hidden <address@hidden> wrote:
> where is possible to find the examples for the use of library in c++
> program?
The Octave manual has an explanation about this:
http://www.gnu.org/software/octave/doc/interpreter/Getting-Started-with-Oct_002dFiles.html
The following is also a classic reference, which may help you, but
note that it is very old and inaccurate in many places:
http://octave.sourceforge.net/coda/index.html
> I would like to use the deviation standard in my software, but I
> don't find this function in API C++.
The std.m function isn't in C++, so you have to call the Octave
interpreter from C++. Here is an example:
#include <iostream>
#include <string>
#include <octave/oct.h>
#include <octave/parse.h>
int main()
{
using namespace std;
//Define a matrix, give it some values
octave_idx_type n = 10, m = 10;
Matrix x(n,m);
for(octave_idx_type i = 0; i < n; i++)
for(octave_idx_type j = 0; j < n; j++)
x(i,j) = cos(i+2*j);
//Read the function
octave_function* f = load_fcn_from_file("std.m");
//Evaluate the std function on this matrix
cout << feval(f, octave_value(x))(0).matrix_value() << endl;
}
Compile it with
mkoctfile myoct.cc --link-stand-alone -o myoct
HTH,
- Jordi G. H.