From cd2c687b54c2785ba7a33596481ae1ed2e739425 Mon Sep 17 00:00:00 2001 From: Frank Dellaert Date: Fri, 14 Oct 2011 04:42:31 +0000 Subject: [PATCH] Fixed mex compile issues (but many problems remain to run stuff) --- wrap/Makefile.am | 2 +- wrap/matlab.h | 28 ++++++++++++++++++---------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/wrap/Makefile.am b/wrap/Makefile.am index bc00425fc..e7474f7e2 100644 --- a/wrap/Makefile.am +++ b/wrap/Makefile.am @@ -53,7 +53,7 @@ interfacePath = $(top_srcdir) moduleName = gtsam toolboxpath = ../toolbox nameSpace = "gtsam" -mexFlags = "${BOOST_CPPFLAGS} -I${prefix}/include -I${prefix}/include/gtsam/linear -I${prefix}/include/gtsam/nonlinear -I${prefix}/include/gtsam/base -I${prefix}/include/gtsam/wrap -I${prefix}/include/gtsam/slam -L${exec_prefix}/lib -lgtsam" +mexFlags = "${BOOST_CPPFLAGS} -I${prefix}/include -I${prefix}/include/gtsam -I${prefix}/include/gtsam/base -I${prefix}/include/gtsam/geometry -I${prefix}/include/gtsam/linear -I${prefix}/include/gtsam/nonlinear -I${prefix}/include/gtsam/slam -L${exec_prefix}/lib -lgtsam" all: ./wrap ${interfacePath} ${moduleName} ${toolboxpath} ${nameSpace} ${mexFlags} diff --git a/wrap/matlab.h b/wrap/matlab.h index 6f203be9b..c9b550c1a 100644 --- a/wrap/matlab.h +++ b/wrap/matlab.h @@ -9,27 +9,35 @@ * -------------------------------------------------------------------------- */ -// header file to be included in MATLAB wrappers -// Copyright (c) 2008 Frank Dellaert, All Rights reserved -// wrapping and unwrapping is done using specialized templates, see -// http://www.cplusplus.com/doc/tutorial/templates.html +/** + * @file matlab.h + * @brief header file to be included in MATLAB wrappers + * @date 2008 + * @author Frank Dellaert + * + * wrapping and unwrapping is done using specialized templates, see + * http://www.cplusplus.com/doc/tutorial/templates.html + */ + +#include +#include extern "C" { #include } +#include + #include #include #include -#include -#include using namespace std; using namespace boost; // not usual, but for conciseness of generated code // start GTSAM Specifics ///////////////////////////////////////////////// -typedef Eigen::VectorXd Vector; // NOTE: outside of gtsam namespace -typedef Eigen::MatrixXd Matrix; +typedef gtsam::Vector Vector; // NOTE: outside of gtsam namespace +typedef gtsam::Matrix Matrix; // to make keys be constructed from strings: #define GTSAM_MAGIC_KEY @@ -144,7 +152,7 @@ mxArray* wrap(const Vector& v) { // wrap a const BOOST MATRIX into a double matrix mxArray* wrap_Matrix(const Matrix& A) { - int m = A.size1(), n = A.size2(); + int m = A.rows(), n = A.cols(); mxArray *result = mxCreateDoubleMatrix(m, n, mxREAL); double *data = mxGetPr(result); // converts from column-major to row-major @@ -222,7 +230,7 @@ Vector unwrap< Vector >(const mxArray* array) { if (mxIsDouble(array)==false || n!=1) error("unwrap: not a vector"); double* data = (double*)mxGetData(array); Vector v(m); - copy(data,data+m,v.begin()); + for (int i=0;i