Attempting to convert fgap.m (not my code, it was written by Vitor Piro and is available here:
https://github.com/pirovc/fgap
) to cpp using matlab2.cpp. After installing the latter using whatever version was downloading on Feb 18, 2018 at 22:18 PST
m2cpp fgap.m
didn't like code like this:
blah.part(a==b) = 1;
so those all had to be converted manually to
if (a==b)
blah.part = 1;
end
It also seemed to become confused on some complex [ ] strings, where spaces between variables/strings
had to be replaced with commas. Once all that was done, m2cpp no longer issued any warnings, instead it crashed on a run like so:
m2cpp fgap.m
Traceback (most recent call last):
File "/usr/local/bin/m2cpp", line 11, in <module>
sys.exit(m2cpp())
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/__init__.py", line 62, in m2cpp
execute_parser(args)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/frontend.py", line 126, in execute_parser
builder.load(filename, code)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/builder.py", line 165, in load
self.create_program(name)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/builder.py", line 375, in create_program
return functions.program(self, name)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/functions.py", line 95, in program
cur = self.create_function(funcs, cur)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/builder.py", line 401, in create_function
return functions.function(self, parent, cur)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/functions.py", line 313, in function
cur = self.create_codeblock(func, cur)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/builder.py", line 520, in create_codeblock
return codeblock.codeblock(self, parent, cur)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/codeblock.py", line 132, in codeblock
cur = self.create_for(block, cur)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/builder.py", line 615, in create_for
return branches.forloop(self, parent, cur)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/branches.py", line 463, in forloop
end = self.create_codeblock(for_loop, cur)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/builder.py", line 520, in create_codeblock
return codeblock.codeblock(self, parent, cur)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/codeblock.py", line 186, in codeblock
cur = self.create_assign(block, cur, eq_loc)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/builder.py", line 570, in create_assign
return assign.single(self, parent, cur, eq_loc)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/assign.py", line 137, in single
end = findend.expression(self, j)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/findend.py", line 58, in expression
k = matrix(self, k)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/findend.py", line 197, in matrix
k = matrix(self, k)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/findend.py", line 197, in matrix
k = matrix(self, k)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/findend.py", line 197, in matrix
k = matrix(self, k)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/findend.py", line 197, in matrix
k = matrix(self, k)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/findend.py", line 197, in matrix
k = matrix(self, k)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/findend.py", line 197, in matrix
k = matrix(self, k)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/findend.py", line 197, in matrix
k = matrix(self, k)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/findend.py", line 197, in matrix
k = matrix(self, k)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/findend.py", line 197, in matrix
k = matrix(self, k)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/findend.py", line 197, in matrix
k = matrix(self, k)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/findend.py", line 197, in matrix
k = matrix(self, k)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/findend.py", line 197, in matrix
k = matrix(self, k)
File "/usr/local/lib/python2.7/site-packages/matlab2cpp/tree/findend.py", line 196, in matrix
if self.code[k] == "[":
IndexError: string index out of range
The toxic form of fgap.m, compressed to allow the upload, should be available at the following link:
Greetings.
Attempting to convert fgap.m (not my code, it was written by Vitor Piro and is available here: https://github.com/pirovc/fgap ) to cpp using matlab2.cpp. After installing the latter using whatever version was downloading on Feb 18, 2018 at 22:18 PST
m2cpp fgap.m
didn't like code like this:
blah.part(a==b) = 1;
so those all had to be converted manually to
It also seemed to become confused on some complex [ ] strings, where spaces between variables/strings had to be replaced with commas. Once all that was done, m2cpp no longer issued any warnings, instead it crashed on a run like so:
The toxic form of fgap.m, compressed to allow the upload, should be available at the following link:
fgap.m.gz
The original form, before the modifications above, just in case V.P. updated the version on github, was here:
fgap.m.dist.gz