convert MATLAB cell type to c++

我怕爱的太早我们不能终老 提交于 2019-12-13 12:08:48

问题


i'm converting a MATLAB program in c++ using Armadillo for matrix algebra.

i'm stuck on cell type. someone has some hints?


回答1:


That's because 'cell' is not really a type - it is a placeholder for anything you want to place in it. The closest thing I can think of in languages such as C# and Python is a 'tuple', which intrinsically can contain anonymous types.

Since C++ does not have a built-in tuple type, I suggest you take a look at Boost, which is a very comprehensive, mature and open-source library for practically anything you need in C++. Under Boost, take a look at the Fusion library, or if you require something not simpler, at the Tuple library.

EDIT as Matt mensioned below, as of TR1, tuples are part of the C++ standard library. See Matt's link here.




回答2:


Your cell data will likely translate fairly well into a C++ object. I would recommend you examine what your cells contain and see if you could represent it as a class. Then you would be able to create vectors/arrays/matrices of your objects and have them treated similar to cells in MATLAB.




回答3:


Armadillo has field class!



来源:https://stackoverflow.com/questions/9233039/convert-matlab-cell-type-to-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!