functions_wrapper.cpp
Go to the documentation of this file.
1 #include <gtwrap/matlab.h>
2 #include <map>
3 
4 
5 
6 
7 
8 
9 
11 {
12  mstream mout;
13  std::streambuf *outbuf = std::cout.rdbuf(&mout);
14 
15  bool anyDeleted = false;
16 
17  if(anyDeleted)
18  cout <<
19  "WARNING: Wrap modules with variables in the workspace have been reloaded due to\n"
20  "calling destructors, call 'clear all' again if you plan to now recompile a wrap\n"
21  "module, so that your recompiled module is used instead of the old one." << endl;
22  std::cout.rdbuf(outbuf);
23 }
24 
26  const mxArray *alreadyCreated = mexGetVariablePtr("global", "gtsam_functions_rttiRegistry_created");
27  if(!alreadyCreated) {
28  std::map<std::string, std::string> types;
29 
30 
31 
32  mxArray *registry = mexGetVariable("global", "gtsamwrap_rttiRegistry");
33  if(!registry)
34  registry = mxCreateStructMatrix(1, 1, 0, NULL);
35  typedef std::pair<std::string, std::string> StringPair;
36  for(const StringPair& rtti_matlab: types) {
37  int fieldId = mxAddField(registry, rtti_matlab.first.c_str());
38  if(fieldId < 0) {
39  mexErrMsgTxt("gtsam wrap: Error indexing RTTI types, inheritance will not work correctly");
40  }
41  mxArray *matlabName = mxCreateString(rtti_matlab.second.c_str());
42  mxSetFieldByNumber(registry, 0, fieldId, matlabName);
43  }
44  if(mexPutVariable("global", "gtsamwrap_rttiRegistry", registry) != 0) {
45  mexErrMsgTxt("gtsam wrap: Error indexing RTTI types, inheritance will not work correctly");
46  }
47  mxDestroyArray(registry);
48 
49  mxArray *newAlreadyCreated = mxCreateNumericMatrix(0, 0, mxINT8_CLASS, mxREAL);
50  if(mexPutVariable("global", "gtsam_functions_rttiRegistry_created", newAlreadyCreated) != 0) {
51  mexErrMsgTxt("gtsam wrap: Error indexing RTTI types, inheritance will not work correctly");
52  }
53  mxDestroyArray(newAlreadyCreated);
54  }
55 }
56 
57 void load2D_0(int nargout, mxArray *out[], int nargin, const mxArray *in[])
58 {
59  checkArguments("load2D",nargout,nargin,5);
60  string filename = unwrap< string >(in[0]);
61  std::shared_ptr<Test> model = unwrap_shared_ptr< Test >(in[1], "ptr_Test");
62  int maxID = unwrap< int >(in[2]);
63  bool addNoise = unwrap< bool >(in[3]);
64  bool smart = unwrap< bool >(in[4]);
65  auto pairResult = load2D(filename,model,maxID,addNoise,smart);
66  out[0] = wrap_shared_ptr(pairResult.first,"gtsam.NonlinearFactorGraph", false);
67  out[1] = wrap_shared_ptr(pairResult.second,"gtsam.Values", false);
68 }
69 void load2D_1(int nargout, mxArray *out[], int nargin, const mxArray *in[])
70 {
71  checkArguments("load2D",nargout,nargin,5);
72  string filename = unwrap< string >(in[0]);
73  std::shared_ptr<gtsam::noiseModel::Diagonal> model = unwrap_shared_ptr< gtsam::noiseModel::Diagonal >(in[1], "ptr_gtsamnoiseModelDiagonal");
74  int maxID = unwrap< int >(in[2]);
75  bool addNoise = unwrap< bool >(in[3]);
76  bool smart = unwrap< bool >(in[4]);
77  auto pairResult = load2D(filename,model,maxID,addNoise,smart);
78  out[0] = wrap_shared_ptr(pairResult.first,"gtsam.NonlinearFactorGraph", false);
79  out[1] = wrap_shared_ptr(pairResult.second,"gtsam.Values", false);
80 }
81 void load2D_2(int nargout, mxArray *out[], int nargin, const mxArray *in[])
82 {
83  checkArguments("load2D",nargout,nargin,2);
84  string filename = unwrap< string >(in[0]);
85  gtsam::noiseModel::Diagonal* model = unwrap_ptr< gtsam::noiseModel::Diagonal >(in[1], "ptr_gtsamnoiseModelDiagonal");
86  auto pairResult = load2D(filename,model);
87  out[0] = wrap_shared_ptr(pairResult.first,"gtsam.NonlinearFactorGraph", false);
88  out[1] = wrap_shared_ptr(pairResult.second,"gtsam.Values", false);
89 }
90 void aGlobalFunction_3(int nargout, mxArray *out[], int nargin, const mxArray *in[])
91 {
92  checkArguments("aGlobalFunction",nargout,nargin,0);
93  out[0] = wrap< Vector >(aGlobalFunction());
94 }
95 void overloadedGlobalFunction_4(int nargout, mxArray *out[], int nargin, const mxArray *in[])
96 {
97  checkArguments("overloadedGlobalFunction",nargout,nargin,1);
98  int a = unwrap< int >(in[0]);
99  out[0] = wrap< Vector >(overloadedGlobalFunction(a));
100 }
101 void overloadedGlobalFunction_5(int nargout, mxArray *out[], int nargin, const mxArray *in[])
102 {
103  checkArguments("overloadedGlobalFunction",nargout,nargin,2);
104  int a = unwrap< int >(in[0]);
105  double b = unwrap< double >(in[1]);
106  out[0] = wrap< Vector >(overloadedGlobalFunction(a,b));
107 }
108 void MultiTemplatedFunctionStringSize_tDouble_6(int nargout, mxArray *out[], int nargin, const mxArray *in[])
109 {
110  checkArguments("MultiTemplatedFunctionStringSize_tDouble",nargout,nargin,2);
111  T& x = *unwrap_shared_ptr< T >(in[0], "ptr_T");
112  size_t y = unwrap< size_t >(in[1]);
113  out[0] = wrap< double >(MultiTemplatedFunctionStringSize_tDouble(x,y));
114 }
115 void MultiTemplatedFunctionDoubleSize_tDouble_7(int nargout, mxArray *out[], int nargin, const mxArray *in[])
116 {
117  checkArguments("MultiTemplatedFunctionDoubleSize_tDouble",nargout,nargin,2);
118  T& x = *unwrap_shared_ptr< T >(in[0], "ptr_T");
119  size_t y = unwrap< size_t >(in[1]);
120  out[0] = wrap< double >(MultiTemplatedFunctionDoubleSize_tDouble(x,y));
121 }
122 void DefaultFuncInt_8(int nargout, mxArray *out[], int nargin, const mxArray *in[])
123 {
124  checkArguments("DefaultFuncInt",nargout,nargin,2);
125  int a = unwrap< int >(in[0]);
126  int b = unwrap< int >(in[1]);
127  DefaultFuncInt(a,b);
128 }
129 void DefaultFuncInt_9(int nargout, mxArray *out[], int nargin, const mxArray *in[])
130 {
131  checkArguments("DefaultFuncInt",nargout,nargin,1);
132  int a = unwrap< int >(in[0]);
133  DefaultFuncInt(a,0);
134 }
135 void DefaultFuncInt_10(int nargout, mxArray *out[], int nargin, const mxArray *in[])
136 {
137  checkArguments("DefaultFuncInt",nargout,nargin,0);
138  DefaultFuncInt(123,0);
139 }
140 void DefaultFuncString_11(int nargout, mxArray *out[], int nargin, const mxArray *in[])
141 {
142  checkArguments("DefaultFuncString",nargout,nargin,2);
143  string& s = *unwrap_shared_ptr< string >(in[0], "ptr_string");
144  string& name = *unwrap_shared_ptr< string >(in[1], "ptr_string");
145  DefaultFuncString(s,name);
146 }
147 void DefaultFuncString_12(int nargout, mxArray *out[], int nargin, const mxArray *in[])
148 {
149  checkArguments("DefaultFuncString",nargout,nargin,1);
150  string& s = *unwrap_shared_ptr< string >(in[0], "ptr_string");
151  DefaultFuncString(s,"");
152 }
153 void DefaultFuncString_13(int nargout, mxArray *out[], int nargin, const mxArray *in[])
154 {
155  checkArguments("DefaultFuncString",nargout,nargin,0);
156  DefaultFuncString("hello","");
157 }
158 void DefaultFuncObj_14(int nargout, mxArray *out[], int nargin, const mxArray *in[])
159 {
160  checkArguments("DefaultFuncObj",nargout,nargin,1);
161  gtsam::KeyFormatter& keyFormatter = *unwrap_shared_ptr< gtsam::KeyFormatter >(in[0], "ptr_gtsamKeyFormatter");
162  DefaultFuncObj(keyFormatter);
163 }
164 void DefaultFuncObj_15(int nargout, mxArray *out[], int nargin, const mxArray *in[])
165 {
166  checkArguments("DefaultFuncObj",nargout,nargin,0);
167  DefaultFuncObj(gtsam::DefaultKeyFormatter);
168 }
169 void DefaultFuncZero_16(int nargout, mxArray *out[], int nargin, const mxArray *in[])
170 {
171  checkArguments("DefaultFuncZero",nargout,nargin,5);
172  int a = unwrap< int >(in[0]);
173  int b = unwrap< int >(in[1]);
174  double c = unwrap< double >(in[2]);
175  int d = unwrap< int >(in[3]);
176  bool e = unwrap< bool >(in[4]);
177  DefaultFuncZero(a,b,c,d,e);
178 }
179 void DefaultFuncZero_17(int nargout, mxArray *out[], int nargin, const mxArray *in[])
180 {
181  checkArguments("DefaultFuncZero",nargout,nargin,4);
182  int a = unwrap< int >(in[0]);
183  int b = unwrap< int >(in[1]);
184  double c = unwrap< double >(in[2]);
185  int d = unwrap< int >(in[3]);
186  DefaultFuncZero(a,b,c,d,false);
187 }
188 void DefaultFuncZero_18(int nargout, mxArray *out[], int nargin, const mxArray *in[])
189 {
190  checkArguments("DefaultFuncZero",nargout,nargin,3);
191  int a = unwrap< int >(in[0]);
192  int b = unwrap< int >(in[1]);
193  double c = unwrap< double >(in[2]);
194  DefaultFuncZero(a,b,c,0,false);
195 }
196 void DefaultFuncZero_19(int nargout, mxArray *out[], int nargin, const mxArray *in[])
197 {
198  checkArguments("DefaultFuncZero",nargout,nargin,2);
199  int a = unwrap< int >(in[0]);
200  int b = unwrap< int >(in[1]);
201  DefaultFuncZero(a,b,0.0,0,false);
202 }
203 void DefaultFuncVector_20(int nargout, mxArray *out[], int nargin, const mxArray *in[])
204 {
205  checkArguments("DefaultFuncVector",nargout,nargin,2);
206  std::vector<int>& i = *unwrap_shared_ptr< std::vector<int> >(in[0], "ptr_stdvectorint");
207  std::vector<string>& s = *unwrap_shared_ptr< std::vector<string> >(in[1], "ptr_stdvectorstring");
208  DefaultFuncVector(i,s);
209 }
210 void DefaultFuncVector_21(int nargout, mxArray *out[], int nargin, const mxArray *in[])
211 {
212  checkArguments("DefaultFuncVector",nargout,nargin,1);
213  std::vector<int>& i = *unwrap_shared_ptr< std::vector<int> >(in[0], "ptr_stdvectorint");
214  DefaultFuncVector(i,{"borglab", "gtsam"});
215 }
216 void DefaultFuncVector_22(int nargout, mxArray *out[], int nargin, const mxArray *in[])
217 {
218  checkArguments("DefaultFuncVector",nargout,nargin,0);
219  DefaultFuncVector({1, 2, 3},{"borglab", "gtsam"});
220 }
221 void setPose_23(int nargout, mxArray *out[], int nargin, const mxArray *in[])
222 {
223  checkArguments("setPose",nargout,nargin,1);
224  gtsam::Pose3& pose = *unwrap_shared_ptr< gtsam::Pose3 >(in[0], "ptr_gtsamPose3");
225  setPose(pose);
226 }
227 void setPose_24(int nargout, mxArray *out[], int nargin, const mxArray *in[])
228 {
229  checkArguments("setPose",nargout,nargin,0);
230  setPose(gtsam::Pose3());
231 }
232 void TemplatedFunctionRot3_25(int nargout, mxArray *out[], int nargin, const mxArray *in[])
233 {
234  checkArguments("TemplatedFunctionRot3",nargout,nargin,1);
235  gtsam::Rot3& t = *unwrap_shared_ptr< gtsam::Rot3 >(in[0], "ptr_gtsamRot3");
236  TemplatedFunctionRot3(t);
237 }
238 
239 void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
240 {
241  mstream mout;
242  std::streambuf *outbuf = std::cout.rdbuf(&mout);
243 
245 
246  int id = unwrap<int>(in[0]);
247 
248  try {
249  switch(id) {
250  case 0:
251  load2D_0(nargout, out, nargin-1, in+1);
252  break;
253  case 1:
254  load2D_1(nargout, out, nargin-1, in+1);
255  break;
256  case 2:
257  load2D_2(nargout, out, nargin-1, in+1);
258  break;
259  case 3:
260  aGlobalFunction_3(nargout, out, nargin-1, in+1);
261  break;
262  case 4:
263  overloadedGlobalFunction_4(nargout, out, nargin-1, in+1);
264  break;
265  case 5:
266  overloadedGlobalFunction_5(nargout, out, nargin-1, in+1);
267  break;
268  case 6:
269  MultiTemplatedFunctionStringSize_tDouble_6(nargout, out, nargin-1, in+1);
270  break;
271  case 7:
272  MultiTemplatedFunctionDoubleSize_tDouble_7(nargout, out, nargin-1, in+1);
273  break;
274  case 8:
275  DefaultFuncInt_8(nargout, out, nargin-1, in+1);
276  break;
277  case 9:
278  DefaultFuncInt_9(nargout, out, nargin-1, in+1);
279  break;
280  case 10:
281  DefaultFuncInt_10(nargout, out, nargin-1, in+1);
282  break;
283  case 11:
284  DefaultFuncString_11(nargout, out, nargin-1, in+1);
285  break;
286  case 12:
287  DefaultFuncString_12(nargout, out, nargin-1, in+1);
288  break;
289  case 13:
290  DefaultFuncString_13(nargout, out, nargin-1, in+1);
291  break;
292  case 14:
293  DefaultFuncObj_14(nargout, out, nargin-1, in+1);
294  break;
295  case 15:
296  DefaultFuncObj_15(nargout, out, nargin-1, in+1);
297  break;
298  case 16:
299  DefaultFuncZero_16(nargout, out, nargin-1, in+1);
300  break;
301  case 17:
302  DefaultFuncZero_17(nargout, out, nargin-1, in+1);
303  break;
304  case 18:
305  DefaultFuncZero_18(nargout, out, nargin-1, in+1);
306  break;
307  case 19:
308  DefaultFuncZero_19(nargout, out, nargin-1, in+1);
309  break;
310  case 20:
311  DefaultFuncVector_20(nargout, out, nargin-1, in+1);
312  break;
313  case 21:
314  DefaultFuncVector_21(nargout, out, nargin-1, in+1);
315  break;
316  case 22:
317  DefaultFuncVector_22(nargout, out, nargin-1, in+1);
318  break;
319  case 23:
320  setPose_23(nargout, out, nargin-1, in+1);
321  break;
322  case 24:
323  setPose_24(nargout, out, nargin-1, in+1);
324  break;
325  case 25:
326  TemplatedFunctionRot3_25(nargout, out, nargin-1, in+1);
327  break;
328  }
329  } catch(const std::exception& e) {
330  mexErrMsgTxt(("Exception from gtsam:\n" + std::string(e.what()) + "\n").c_str());
331  }
332 
333  std::cout.rdbuf(outbuf);
334 }
int unwrap< int >(const mxArray *array)
Definition: matlab.h:328
mxArray * wrap_shared_ptr(std::shared_ptr< Class > shared_ptr, const std::string &matlabName, bool isVirtual)
Definition: matlab.h:487
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Scalar * y
void DefaultFuncZero_16(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Scalar * b
Definition: benchVecAdd.cpp:17
void DefaultFuncObj_14(int nargout, mxArray *out[], int nargin, const mxArray *in[])
noiseModel::Diagonal::shared_ptr model
std::ofstream out("Result.txt")
void checkArguments(const string &name, int nargout, int nargin, int expected)
Definition: matlab.h:113
void TemplatedFunctionRot3_25(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void DefaultFuncZero_17(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void _functions_RTTIRegister()
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
void DefaultFuncString_12(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void DefaultFuncString_13(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void overloadedGlobalFunction_4(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void DefaultFuncVector_20(int nargout, mxArray *out[], int nargin, const mxArray *in[])
string unwrap< string >(const mxArray *array)
Definition: matlab.h:283
size_t unwrap< size_t >(const mxArray *array)
Definition: matlab.h:335
static const KeyFormatter DefaultKeyFormatter
Definition: Key.h:43
Rot3 is a 3D rotation represented as a rotation matrix if the preprocessor symbol GTSAM_USE_QUATERNIO...
Definition: Rot3.h:58
void load2D_1(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void aGlobalFunction_3(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void DefaultFuncZero_19(int nargout, mxArray *out[], int nargin, const mxArray *in[])
double unwrap< double >(const mxArray *array)
Definition: matlab.h:342
void load2D_2(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void _deleteAllObjects()
void DefaultFuncVector_21(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void DefaultFuncInt_10(int nargout, mxArray *out[], int nargin, const mxArray *in[])
GraphAndValues load2D(const std::string &filename, SharedNoiseModel model, size_t maxIndex, bool addNoise, bool smart, NoiseFormat noiseFormat, KernelFunctionType kernelFunctionType)
Definition: dataset.cpp:505
Array< double, 1, 3 > e(1./3., 0.5, 2.)
RealScalar s
#define NULL
Definition: ccolamd.c:609
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:35
void overloadedGlobalFunction_5(int nargout, mxArray *out[], int nargin, const mxArray *in[])
mxArray * wrap< double >(const double &value)
Definition: matlab.h:180
void MultiTemplatedFunctionStringSize_tDouble_6(int nargout, mxArray *out[], int nargin, const mxArray *in[])
static const Pose3 pose(Rot3(Vector3(1, -1, -1).asDiagonal()), Point3(0, 0, 0.5))
void DefaultFuncVector_22(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void setPose_24(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void DefaultFuncInt_8(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void load2D_0(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void DefaultFuncString_11(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void MultiTemplatedFunctionDoubleSize_tDouble_7(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Annotation for function names.
Definition: attr.h:48
void DefaultFuncObj_15(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void setPose_23(int nargout, mxArray *out[], int nargin, const mxArray *in[])
bool unwrap< bool >(const mxArray *array)
Definition: matlab.h:307
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
void DefaultFuncInt_9(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: matlab.h:95
void DefaultFuncZero_18(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Point2 t(10, 10)


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:15