i'm converting a MATLAB program in c++ using Armadillo for matrix algebra.
i'm stuck on cell type. someone has some hints?
A = cell2mat( C ) converts a cell array into an ordinary array. The elements of the cell array must all contain the same data type, and the resulting array is of that data type. The contents of C must support concatenation into an N-dimensional rectangle.
T = cell2table( C ) converts the contents of an m -by- n cell array, C , to an m -by- n table, T . Each column of C provides the data contained in a variable of T . To create variable names in the output table, cell2table appends column numbers to the input array name.
X = str2double( str ) converts the text in string str to a double-precision value. In a chart that uses MATLAB® as the action language, str2double returns a complex value.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With