Mxarray is the structure of the matlab c function library, while mwarray is the packaging of mxarray In the matlab c ++ function library.
Class.
Second, the two memory management methods are different. Mxarray's memory management method is loose, because it is a C function library, there is no data
Encapsulation, the concept of the temporary array and the constraint array must be extremely explicit, and the memory leakage must be carefully prevented (multiple generations need to be written)
Code ). Although there is an automatic memory management mechanism (mlfenternewcontext, mlfreleasepreviouscontext ),
Calling mlfassign is troublesome. However, mwarray is much better, and everything is handled by the C ++ object. You just need to use it with confidence.
You can. However, the matlab c ++ function library has rewritten functions such as memory allocation and release to prevent frequent memory allocation and release.
You will find that for mwarray a, B; A = B; in fact, two identical data blocks are not generated, only pointers, but only data changes
Complete data is copied only when the data changes.
Again, each of these two items has a set of corresponding functions. The return values of a function are of different types.
Finally, mxarray uses pointers, while mwarray uses them directly as class objects. If you are not a hardcore-level cool man
It is strongly recommended that the latter be used for potential talents with hardcore preferences! Mwarray can be considered as a basic type similar to int, float in programming languages.
The process is converted to the type you want. From the perspective of object-oriented programming, mwarray is actually a base class for all data types, similar
Object. In the development of Matlab, all data objects are treated as mwarray first, and the function return value is also
The mwarray type or the mwarray array is returned. In the secondary development, you can convert it to the required data type as needed,
I usually convert mwarray into a string first, and then parse the string into a value!
Mwarray feels like the object class in the object-oriented language, because such MATLAB variables and general programming languages are not
Same, it does not distinguish int, float, and so on. If you are familiar with C #, you can have a deeper understanding of this estimate. Using MATLAB,
Mwarray is its base data type. It applies to a single variable and array. It can be converted to the corresponding data when needed.
Type. For more information, see the Help File of Matlab.
Statement
Mxarray:
Mxarray *;
Mwarray:
Mwarray;
Destroy
Mxarray
Mxdestroyarray;
Mwarray
The destructor of the mwarray class automatically destroys objects.
Variable assignment
Mxarray
Memcpy (dest_ptr, source_ptr, max_size );
Mwarray
mwArray in1(3, 3, mxDOUBLE_CLASS, mxREAL);mwArray in2(3, 3, mxDOUBLE_CLASS, mxREAL);in1.SetData(data, 9);in2.SetData(data, 9);