Convert MATLAB cell type to C ++

I am converting a MATLAB program to c ++ using Armadillo for matrix algebra.

I am stuck on a cell type. Does anyone have any hints?

+5
source share
3 answers

Armadillo has a field class!

+1
source

This is because "cell" is not really a type - it is a placeholder for everything you want to place in it. The closest thing I can think of in languages ​​like C # and Python is the "tuple", which essentially 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 almost everything you need in C ++. Under Boost, browse the Fusion library, or if you need something no more simple, on Tuple .

EDIT , as Matt, pulled below, like TR1, tuples are part of the C ++ standard library. See Matt Link here .

+3
source

Your cell data is likely to be fairly well translated into a C ++ object. I would recommend that you examine what your cells contain and see if you can represent it as a class. Then you can create vectors / arrays / matrices of your objects and process them similar to cells in MATLAB.

+1
source

Source: https://habr.com/ru/post/1395824/


All Articles