Open taiwuchiang opened 7 years ago
I used your /dev branch. But I have seen it and the previous bug #125 when using the master branch.
Oh, this crash only happens when I set "dRdm1" : "mat", # mat in the test.m.py file
If leave it blank, like "dRdm1" : "", # mat then it won't crash.
However, the generated code will compile with errors.
Generated code:
int main(int argc, char** argv)
{
TYPE dRdm1;
rowvec _aux_rowvec_1;
dRdm1 = arma::zeros
Try to change TYPE to mat:
int main(int argc, char** argv)
{
mat dRdm1;
rowvec _aux_rowvec_1;
dRdm1 = arma::zeros
Get the following compiler errors:
1>test.m.cpp
1>......\samples\cpp\tutorial_code\ImgTrans\test.m.cpp(14): error C2664: 'const arma::subview_row
Manually to fix the compile error and get the following correct C++ code:
int main(int argc, char** argv)
{
mat dRdm1;
uvec _aux_uvec_1;
dRdm1 = arma::zeros
return 0;
}
I am using Armadillo v8. So there may be new syntax for doing subview and it's actually simpler.
For example, mat M; uvec a; urowvec b; // initialize M, a, b ... // then subview of M can be M(a, b);
two issues here:
1) the generated code line dRdm1(arma::strans(_aux_urowvec_1) - 1, 0 ) should be dRdm1(arma::strans(_aux_urowvec_1) - 1, urowvec({ 0 }))
2) if it's possible to declare the aux variable as 'vec' rather than 'rowvec' and the transpose to 'vec'? Usually Armadillo uses column vector for 1st argument indexing, row vector for second argument indexing. Will this provide a clue for the converter? Thanks.
well, if transpose column vector to row vector doesn't require data movement, then please ignore the second request. Thanks.
Matlab:
dRdm1 = zeros(9,21); dRdm1([1 5 9],1) = ones(3,1);
Errors: Traceback (most recent call last): File "/usr/local/bin/m2cpp", line 9, in
load_entry_point('matlab2cpp==2.0.1', 'console_scripts', 'm2cpp')()
File "/Library/Python/2.7/site-packages/matlab2cpp-2.0.1-py2.7.egg/matlab2cpp/init.py", line 62, in m2cpp
execute_parser(args)
File "/Library/Python/2.7/site-packages/matlab2cpp-2.0.1-py2.7.egg/matlab2cpp/frontend.py", line 180, in execute_parser
builder.project.translate(args)
File "/Library/Python/2.7/site-packages/matlab2cpp-2.0.1-py2.7.egg/matlab2cpp/node/frontend.py", line 190, in translate
backend.translate(self, opt)
File "/Library/Python/2.7/site-packages/matlab2cpp-2.0.1-py2.7.egg/matlab2cpp/node/backend.py", line 481, in translate
map(translate, node)
File "/Library/Python/2.7/site-packages/matlab2cpp-2.0.1-py2.7.egg/matlab2cpp/node/backend.py", line 495, in translate
translate_one(node, opt)
File "/Library/Python/2.7/site-packages/matlab2cpp-2.0.1-py2.7.egg/matlab2cpp/node/backend.py", line 565, in translate_one
value = value(node)
File "/Library/Python/2.7/site-packages/matlab2cpp-2.0.1-py2.7.egg/matlab2cpp/rules/mat.py", line 198, in Set
index = node[0].str.index('(')
ValueError: substring not found