Commit 5c2b1f98 authored by Davis King's avatar Davis King

Fixed an error where some assignments to matrix output variables would result

in an exception getting thrown.
parent 060e876b
...@@ -1044,9 +1044,20 @@ namespace mex_binding ...@@ -1044,9 +1044,20 @@ namespace mex_binding
matrix_colmajor& item matrix_colmajor& item
) )
{ {
// Don't need to do a copy if it's this kind of matrix since we can just if(!item._private_is_persistent())
// pull the underlying mxArray out directly and thus avoid a copy. {
plhs = item._private_release_mxArray(); // Don't need to do a copy if it's this kind of matrix since we can just
// pull the underlying mxArray out directly and thus avoid a copy.
plhs = item._private_release_mxArray();
}
else
{
plhs = mxCreateDoubleMatrix(item.nr(),
item.nc(),
mxREAL);
if (item.size() != 0)
memcpy(mxGetPr(plhs), &item(0,0), item.size()*sizeof(double));
}
} }
void assign_to_matlab( void assign_to_matlab(
...@@ -1054,9 +1065,21 @@ namespace mex_binding ...@@ -1054,9 +1065,21 @@ namespace mex_binding
fmatrix_colmajor& item fmatrix_colmajor& item
) )
{ {
// Don't need to do a copy if it's this kind of matrix since we can just if(!item._private_is_persistent())
// pull the underlying mxArray out directly and thus avoid a copy. {
plhs = item._private_release_mxArray(); // Don't need to do a copy if it's this kind of matrix since we can just
// pull the underlying mxArray out directly and thus avoid a copy.
plhs = item._private_release_mxArray();
}
else
{
plhs = mxCreateNumericMatrix(item.nr(),
item.nc(),
mxSINGLE_CLASS,
mxREAL);
if (item.size() != 0)
memcpy(mxGetPr(plhs), &item(0,0), item.size()*sizeof(float));
}
} }
void assign_to_matlab( void assign_to_matlab(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment