suppose mex function called way
ret = amexfunction(foo, foo); % same data both inputs and in mex function:
void mexfunction( int nlhs, mxarray *plhs[], int nrhs, const mxarray *prhs[]) { bar(mxgetdata(prhs[0]), mxgetdata(prhs[1])); } but bar defined as:
bar(type *restrict ptr1, type *restrict ptr2) { ^^^^^^^^ ^^^^^^^^ // problem? dosomething(); }
you need restricted pointers when pointers not const, when 1 written aliasing become issue. inputs mex functions const, , constness should passed on calling functions. input data arrays not guaranteed point unaliased memory locations, because matlab assumes inputs won't changed, shouldn't be.
Comments
Post a Comment