Does MATLAB split up large arrays in memory?

조회 수: 1 (최근 30일)
Eric Stevens
Eric Stevens 2020년 10월 26일
댓글: Walter Roberson 2020년 10월 29일
I am using a C library that expects type LPVOID. I am passing large arrays of uint8 objects. Somewhere around the 5 MB input mark the library function stops processing the array. It seems that this could happen if MATLAB has some optimization that splits large arrays up to avoid having to find large contiguous blocks of memory. My question is: does this happen? Does MATLAB split large arrays or, when I allocate a 10 MB numeric array is it gaurenteed to be contiguous?
  댓글 수: 2
James Tursa
James Tursa 2020년 10월 28일
편집: James Tursa 2020년 10월 28일
MATLAB does not split up numeric/logical/char array data memory. All such created array data areas are guaranteed to be contiguous. The non-zero values of sparse arrays are also guaranteed to be contiguous. The caveat to this is that in R2017b and earlier the real and imag data are in separate memory blocks, whereas in R2018a and later the real and imag data are interleaved in one memory block.
Eric Stevens
Eric Stevens 2020년 10월 28일
@James Tursa, thank you for your response. I'll proceed forward with this assumption.

댓글을 달려면 로그인하십시오.

답변 (1개)

Bruno Luong
Bruno Luong 2020년 10월 26일
No
  댓글 수: 7
Eric Stevens
Eric Stevens 2020년 10월 28일
편집: Eric Stevens 2020년 10월 28일
@Bruno Luong, I appreciate your explanation. I am new to the community and unfamiliar with your contributions, so I apologize if I misinterpreted your intent. Such a short answer is hard to take seriously (although I now believe you are correct). James Tursa's comment, while short, is explicit, specific, and inspires confidence.
Walter Roberson
Walter Roberson 2020년 10월 29일
[begin quote]
The most common data type in MATLAB is the complex double-precision, nonsparse matrix. These matrices are of type double and have dimensions m-by-n, where m is the number of rows and n is the number of columns. The data is stored as a vector of interleaved, double-precision numbers where the real and imaginary parts are stored next to each other. The pointer to this data is referred to as pa (pointer to array). To test for a noncomplex matrix, call mxIsComplex.
Before MATLAB Version 9.4 (R2018a), MATLAB used a separate storage representation. The data is stored as two vectors of double-precision numbers—one contains the real data and one contains the imaginary data. The pointers to this data are referred to as pr (pointer to real data) and pi (pointer to imaginary data), respectively. A noncomplex matrix is one whose pi is NULL. However, to test for a noncomplex matrix, call mxIsComplex.
[end quote]
This is explicit. Storage for numeric data is completely continguous now even for complex data; for R2017b and earlier, storage for the real part of numeric data was separated from the complex part (when the complex part existed at all.)
The answer is different for the structured data types such as struct and table and cell array.
Bruno's answer was correct

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by