gtkIOStream  1.6.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Octave Class Reference

Octave's octave_value_list class. More...

#include <Octave.H>

Public Member Functions

 Octave (const vector< std::string > &args)
 
void startOctave (const vector< std::string > &args)
 
 Octave (void)
 
virtual ~Octave ()
 Destructor. More...
 
bool isReady (void)
 
void stopOctaveAndExit ()
 
void stopOctave ()
 
template<class TYPE >
vector< vector< vector< TYPE > > > & runM (const char *commandName, const vector< vector< vector< TYPE > > > &in, vector< vector< vector< TYPE > > > &out)
 
template<class TYPE >
vector< Eigen::Matrix< TYPE,
Eigen::Dynamic, Eigen::Dynamic > > & 
runM (const char *commandName, const vector< Eigen::Matrix< TYPE, Eigen::Dynamic, Eigen::Dynamic > > &in, vector< Eigen::Matrix< TYPE, Eigen::Dynamic, Eigen::Dynamic > > &out)
 
octave_value_list runMWithInput (const char *commandName)
 
void runM (const char *commandName)
 
template<typename Derived >
int setGlobalVariable (const std::string &name, const Eigen::DenseBase< Derived > &var)
 
int setGlobalVariable (const std::string &name, Matrix &m)
 
Octave_map setGlobalSubVariable (const vector< std::string > &varNames, const Matrix &m, int index, octave_value &base)
 
Octave_map createGlobalSubVariable (const vector< std::string > &varNames, const Matrix &m, int index, Octave_map &base)
 
void clearAll (void)
 
template<typename TYPE >
Eigen::Matrix< TYPE,
Eigen::Dynamic, 1 > 
str2Mat (char *str)
 
template<typename TYPE >
Eigen::Matrix< TYPE,
Eigen::Dynamic, 1 > 
str2Mat (std::string str)
 
template<typename TYPE >
vector< TYPE > str2Vec (std::string str)
 

Public Attributes

octave_value_list * input
 The inputs to pass to the octave .m file. More...
 

Private Member Functions

Matrix * newMatrix (int r, int c)
 
void setMatrixElem (Matrix *m, int i, int j, double val)
 
void deleteMatrix (Matrix *m)
 
void init (void)
 Initialisation method common to all constructors. More...
 

Detailed Description

Octave's octave_value_list class.

Class to interface to GNU Octave (octave.org). Requires octave headers installed on the system.

First implementation is limited to matrix inputs and outputs to arbitrary .m files.

Usage like so :

// start octave
vector<std::string> args(3); args[0]=std::string("--silent"); args[1]=std::string("--path"); args[2]=std::string("/tmp");
Octave octave(args);
// create the input and output vectors. Load the input vector
vector<Eigen::Matrix<float, Dynamic, Dynamic> > input(1), output;
Eigen::Matrix<float, Dynamic, Dynamic> a(10,10); Eigen::Matrix<float, Dynamic, Dynamic>::Zero(10,10);
input[0]=a;
// run the file yourMFile.m with the input arguments
output = octave.runM("yourMFile", input); // where yourMFile.m is on the path say /tmp/yourMFile.m
// output now holds the results
Examples:
AudioMaskerExample.C, ComplexFFTExample.C, OctaveOpenCVTest.C, OctaveTest.C, Real2DFFTExample.C, and RealFFTExample.C.

Definition at line 95 of file Octave.H.

Constructor & Destructor Documentation

Octave::Octave ( const vector< std::string > &  args)

Constructor starts an octave instance using args to pass to octave

Parameters
argsArguments to pass into octave

Definition at line 74 of file Octave.C.

Here is the call graph for this function:

Octave::Octave ( void  )

Construct Octave, but don't start, make sure you call startOctave before you try to runM

Definition at line 55 of file Octave.C.

Here is the call graph for this function:

Octave::~Octave ( )
virtual

Destructor.

Definition at line 88 of file Octave.C.

Here is the call graph for this function:

Member Function Documentation

void Octave::clearAll ( void  )

Clear everything.

Definition at line 377 of file Octave.C.

Octave_map Octave::createGlobalSubVariable ( const vector< std::string > &  varNames,
const Matrix &  m,
int  index,
Octave_map base 
)

This method is used to construct the new branch from varNames[index] onwards.

Parameters
varNamesThe tokenised list of base names and find name from setGlobalVariable where the base1 name is stripped off.
mThe matrix to set the global variable to.
indexThe current index into the varNames vector.
baseThe octave_value to search for the varNames index+1 in.

Definition at line 352 of file Octave.C.

Here is the caller graph for this function:

void Octave::deleteMatrix ( Matrix *  m)
private

Delete a previously created octave matrix.

Parameters
mThe matrix to delete
See also
newMatrix, setMatrixElem

Definition at line 373 of file Octave.C.

void Octave::init ( void  )
private

Initialisation method common to all constructors.

Definition at line 63 of file Octave.C.

Here is the caller graph for this function:

bool Octave::isReady ( void  )

Check if octave is ready.

Returns
true if ready
Examples:
OctaveTest.C.

Definition at line 59 of file Octave.C.

Matrix * Octave::newMatrix ( int  r,
int  c 
)
private

Method to create an octave matrix of a particular size : Matrix(r,c).

See also
setMatrixElem, deleteMatrix
Parameters
rThe number of rows
cThe number of cols

Definition at line 366 of file Octave.C.

template<class TYPE >
vector< vector< vector< TYPE > > > & Octave::runM ( const char *  commandName,
const vector< vector< vector< TYPE > > > &  in,
vector< vector< vector< TYPE > > > &  out 
)

Runs the matlab script commandName+".m", passing in a vector of std matrices (a vector of a vector) and returning the out vector of matrices (vector of a vector). NOTE: All vector<vector<vector<TYPE> > > data types are vectors of matrices, where the vector.size() are the number of rows and vector[0].size() is the number of columns.

Template Parameters
TYPEThe data type to input and return, must be a scalar type such as int, float, double, etc.
Parameters
commandNameThe .m file name to run
inThe vector of matrices (the vector of vectors of vectors) to input to the .m file.
outThe vector of matrices (the vector of vectors of vectors) output from the .m file.
Returns
The a reference to the variable out.

< Output variables returned from Octave

Examples:
AudioMaskerExample.C, ComplexFFTExample.C, OctaveOpenCVTest.C, OctaveTest.C, Real2DFFTExample.C, and RealFFTExample.C.

Definition at line 104 of file Octave.C.

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TYPE >
vector< Eigen::Matrix< TYPE, Eigen::Dynamic, Eigen::Dynamic > > & Octave::runM ( const char *  commandName,
const vector< Eigen::Matrix< TYPE, Eigen::Dynamic, Eigen::Dynamic > > &  in,
vector< Eigen::Matrix< TYPE, Eigen::Dynamic, Eigen::Dynamic > > &  out 
)

Runs the matlab script commandName+".m", passing in a vector of eigen matrices and returning the out vector of matrices which contains the results.

Template Parameters
TYPEThe Eigen::Matrix types to input and return
Parameters
commandNameThe .m file name to run
inThe vector of Eigen::Matrix (the vector of matrices) to input to the .m file.
outThe vector of Eigen::Matrix (the vector of matrices) output from the .m file.
Returns
The a reference to the variable out.

< Output variables returned from Octave

Definition at line 169 of file Octave.C.

Here is the call graph for this function:

void Octave::runM ( const char *  commandName)

Runs the matlab script commandName+".m", this version takes no input and output and returns no output.

Parameters
commandNameThe .m file name to run

Definition at line 216 of file Octave.C.

Here is the call graph for this function:

octave_value_list Octave::runMWithInput ( const char *  commandName)

Runs the matlab script commandName+".m", this version takes no input (you can specify input by manually filling in the input class variable)

Parameters
commandNameThe .m file name to run
Returns
The output variables are returned in an Octave octave_value_list

< Output variables returned from Octave

Definition at line 210 of file Octave.C.

Here is the call graph for this function:

Octave_map Octave::setGlobalSubVariable ( const vector< std::string > &  varNames,
const Matrix &  m,
int  index,
octave_value &  base 
)

Method helpiing setGlobalVariable parse the global variabl structure at the base of name. This method searches an already existing octave_value class for the desired varName[index+1] path.

Parameters
varNamesThe tokenised list of base names and find name from setGlobalVariable where the base1 name is stripped off.
mThe matrix to set the global variable to.
indexThe current index into the varNames vector.
baseThe octave_value to search for the varNames index+1 in.

Definition at line 292 of file Octave.C.

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename Derived >
int Octave::setGlobalVariable ( const std::string &  name,
const Eigen::DenseBase< Derived > &  var 
)
inline

Method to set an Eigen3 matrix or array as a global variable.

Parameters
nameThe global variable name of the following format "base1.base2.name"
varAn Eigen3 Matrix, Vector or Array type.

Definition at line 211 of file Octave.H.

int Octave::setGlobalVariable ( const std::string &  name,
Matrix &  m 
)

Method to set an octave matrix as a global variable.

Parameters
nameThe global variable name of the following format "base1.base2.name"
mAn octave matrix to use for setting.

Definition at line 273 of file Octave.C.

Here is the call graph for this function:

void Octave::setMatrixElem ( Matrix *  m,
int  i,
int  j,
double  val 
)
private

Method to set an octave matrix : m.elem(i,j)=val;

See also
newMatrix, deleteMatrix
Parameters
mThe matrix
iThe row
jThe col
valThe value to set.

Definition at line 369 of file Octave.C.

void Octave::startOctave ( const vector< std::string > &  args)

Constructor starts an octave instance using args to pass to octave

Parameters
argsArguments to pass into octave

Definition at line 79 of file Octave.C.

Here is the caller graph for this function:

void Octave::stopOctave ( )

Stop the octave instance.

Definition at line 99 of file Octave.C.

void Octave::stopOctaveAndExit ( )

Stop the octave instance and exit.

Definition at line 95 of file Octave.C.

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename TYPE >
Eigen::Matrix<TYPE, Eigen::Dynamic, 1> Octave::str2Mat ( char *  str)
inline

Convert a std::string to a matrix.

Parameters
strThe std::string.
Returns
A matrix containing the ascii representation of the str.
Examples:
OctaveTest.C.

Definition at line 253 of file Octave.H.

template<typename TYPE >
Eigen::Matrix<TYPE, Eigen::Dynamic, 1> Octave::str2Mat ( std::string  str)
inline

Convert a std::string to a matrix.

Parameters
strThe std::string.
Returns
A matrix containing the ascii representation of the str.

Definition at line 262 of file Octave.H.

template<typename TYPE >
vector<TYPE> Octave::str2Vec ( std::string  str)
inline

Convert a std::string to a vector.

Parameters
strThe std::string.
Returns
A matrix containing the ascii representation of the str.
Examples:
OctaveTest.C.

Definition at line 271 of file Octave.H.

Member Data Documentation

octave_value_list* Octave::input

The inputs to pass to the octave .m file.

Definition at line 122 of file Octave.H.


The documentation for this class was generated from the following files:
gtkIOStream: Octave Class Reference
GTK+ IOStream  Beta
GTK+ << C++ IOStream operators for GTK+. Now with extra abilities ... like ORBing, numerical computation, audio clients and more...