GTK+ IOStream  Beta
<< GTK+ >> add C++ IOStream operators to GTK+. Now with extra abilities ... like network serialisation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
Octave Class Reference

#include <Octave.H>

Public Member Functions

 Octave (const vector< string > &args)
 
virtual ~Octave ()
 Destructor. More...
 
template<class TYPE >
vector< Eigen::Matrix< TYPE,
Eigen::Dynamic, Eigen::Dynamic > > 
runM (const char *commandName, vector< Eigen::Matrix< TYPE, Eigen::Dynamic, Eigen::Dynamic > > &in)
 

Detailed Description

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<string> args(3); args[0]=string("--silent"); args[1]=string("--path"); args[2]=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

The Octave.C file must be compiled like so : g++ mkoctfile -p CFLAGS mkoctfile -p INCFLAGS pkg-config --cflags eigen3 -fPIC -c Octave.C

Alternatively, if you are using autotools, do the following (note if you link -lfftw3f elsewhere, you may need to comment out the -p FFTW_LIBS line to stop conflicts) :

lib_LTLIBRARIES = libGTKIOStream.la
libGTKIOStream_la_SOURCES = gtkiostream/Octave.C
libGTKIOStream_la_CPPFLAGS = $(EIGEN_CFLAGS) $(MKOCTFILE_CFLAGS)
Where the following are in your configure.ac :
# eigen3
PKG_CHECK_MODULES(EIGEN, eigen3 >= 3.0.0)
AC_SUBST(EIGEN_CFLAGS)
AC_SUBST(EIGEN_LIBS)
# user supplied mkoctfile program
AC_ARG_WITH([mkoctfile],
[ --with-mkoctfile=PATHTOMKOCTFILE The 'mkoctfile' program.],
[mkoctfile="$withval"],[mkoctfile="no"])
# get mkoctfile program
if test "$mkoctfile" == "no"; then
AC_PATH_PROG([mkoctfile],[mkoctfile],[no],[$prefix/bin:$PATH])
fi
test $mkoctfile = "no" && AC_MSG_ERROR([mkoctfile not found])
AC_SUBST([MKOCTFILE],[$mkoctfile])
# get mkoctfile compiler flags
CAT="cat"
MKOCTFILE_CFLAGS="$(echo $($MKOCTFILE -p INCFLAGS | $CAT) | sed -re 's|\\|/|g')"
MKOCTFILE_LIBS="$(echo \
$(unset RLD_FLAG; $MKOCTFILE -p RLD_FLAG | $CAT) \
$(unset LFLAGS; $MKOCTFILE -p LFLAGS | $CAT) \
$(unset LIBOCTINTERP; $MKOCTFILE -p LIBOCTINTERP | $CAT) \
$(unset LIBOCTAVE; $MKOCTFILE -p LIBOCTAVE | $CAT) \
$(unset LIBCRUFT; $MKOCTFILE -p LIBCRUFT | $CAT) \
$(unset FFTW_LIBS; $MKOCTFILE -p FFTW_LIBS | $CAT) \
$(unset BLAS_LIBS; $MKOCTFILE -p BLAS_LIBS | $CAT) \
$(unset FLIBS; $MKOCTFILE -p FLIBS | $CAT) \
$(unset LIBS; $MKOCTFILE -p LIBS | $CAT) \
| sed -re 's|\\|/|g')"
AC_SUBST([MKOCTFILE_CFLAGS])
AC_SUBST([MKOCTFILE_LIBS])
Finally, to link your program :
INCLUDES = $(FFTW_CFLAGS) $(EIGEN_CFLAGS) $(GTKDATABOX_CFLAGS) -I$(top_srcdir)/test/gtkiostream
LDADD = $(EIGEN_LIBS) $(GTKDATABOX_LIBS) libGTKIOStream.la

Definition at line 105 of file Octave.H.

Constructor & Destructor Documentation

Octave::Octave ( const vector< string > &  args)
Constructor starts an octave instance using args to pass to octave
Parameters
argsArguments to pass into octave

Definition at line 33 of file Octave.C.

Octave::~Octave ( )
virtual

Destructor.

Definition at line 45 of file Octave.C.

Member Function Documentation

template<class TYPE >
template vector< Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > > Octave::runM ( const char *  commandName,
vector< Eigen::Matrix< TYPE, Eigen::Dynamic, Eigen::Dynamic > > &  in 
)
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.

< Input variables to pass to Octave

< Output variables returned from Octave

Definition at line 50 of file Octave.C.

Here is the call graph for this function:


The documentation for this class was generated from the following files: