mxGetPropertyPtr & mxSetPropertySDC C-mex functions

버전 4.1.0.1 (327 KB) 작성자: James Tursa
Fast memory efficient alternative to API functions mxGetProperty & mxSetProperty.
다운로드 수: 1.1K
업데이트 날짜: 2019/6/18

라이선스 보기

When The Mathworks® introduced MATLAB® version R2008a they included a new object oriented format called classdef. This addition greatly expanded the object oriented capabilities of MATLAB® at the m-file level. There were also two new mex API functions introduced at that same time: mxGetProperty and mxSetProperty. Unfortunately, both of these functions work with copies of the properties and not the actual properties themselves. So whereas the old-style class variables can easily and efficiently be accessed with the mex API functions mxGetField, mxGetFieldByNumber, mxSetField, and mxSetFieldByNumber since they use pointers to the original properties, there were no equivalent mex API functions provided for the newer classdef classes. This presents a problem for the mex programmer, particularly if the properties in question are large. Using mxGetProperty will significantly slow the routine down and also risk using up valuable heap memory. The same is true for mxSetProperty.
The new mxGetPropertyPtr C-mex function provided in this package solves half of the problem. It returns a pointer to the original property rather than a pointer to a copy of the property. Thus the property can be accessed efficiently inside a mex routine. The other half of the problem is solved by the new mxSetPropertySDC function, which sets a property to a shared data copy of an mxArray.
These functions have been tested on various Win32 and Win64 versions of MATLAB R2009a - R2019a. For R2018a and later you are expected to use the -R2018a option when compiling your mex code with this submission.

인용 양식

James Tursa (2024). mxGetPropertyPtr & mxSetPropertySDC C-mex functions (https://www.mathworks.com/matlabcentral/fileexchange/30672-mxgetpropertyptr-mxsetpropertysdc-c-mex-functions), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2008a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 C Matrix API에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
4.1.0.1

Added missing matlab_version.c file

4.1.0.0

Updated for R2019a

4.0.0.0

Updated the doc for 4.00 and R2018a

3.99.0.0

Updated code for R2018a. (The doc will be updated soon to reflect this)

3.0.0.0

mxSetPropertySDC now available.

2.0.0.0

Updated for later versions of MATLAB (which have a different mex input argument passing convention) and tested for various 64-bit versions.

1.0.0.0