MCPcopy Create free account
hub / github.com/davisking/dlib / assign_to_matlab

Function assign_to_matlab

dlib/matlab/mex_wrapper.cpp:976–1111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

974
975 template <typename T>
976 typename dlib::enable_if<is_matrix<T> >::type assign_to_matlab(
977 mxArray*& plhs,
978 const T& item
979 )
980 {
981 typedef typename T::type type;
982
983 type* mat = 0;
984
985 if (is_same_type<double, type>::value)
986 {
987 plhs = mxCreateDoubleMatrix(item.nr(),
988 item.nc(),
989 mxREAL);
990
991 mat = (type*)mxGetPr(plhs);
992 }
993 else if (is_same_type<float, type>::value )
994 {
995 plhs = mxCreateNumericMatrix(item.nr(),
996 item.nc(),
997 mxSINGLE_CLASS,
998 mxREAL);
999
1000 mat = (type*)mxGetData(plhs);
1001 }
1002 else if (is_same_type<bool, type>::value )
1003 {
1004 plhs = mxCreateLogicalMatrix(item.nr(),
1005 item.nc());
1006
1007 mat = (type*)mxGetData(plhs);
1008 }
1009 else if (is_same_type<dlib::uint8, type>::value )
1010 {
1011 plhs = mxCreateNumericMatrix(item.nr(),
1012 item.nc(),
1013 mxUINT8_CLASS,
1014 mxREAL);
1015
1016 mat = (type*)mxGetData(plhs);
1017 }
1018 else if (is_same_type<dlib::int8, type>::value )
1019 {
1020 plhs = mxCreateNumericMatrix(item.nr(),
1021 item.nc(),
1022 mxINT8_CLASS,
1023 mxREAL);
1024
1025 mat = (type*)mxGetData(plhs);
1026 }
1027 else if (is_same_type<dlib::int16, type>::value ||
1028 (is_same_type<short,type>::value && sizeof(short) == sizeof(dlib::int16)))
1029 {
1030 plhs = mxCreateNumericMatrix(item.nr(),
1031 item.nc(),
1032 mxINT16_CLASS,
1033 mxREAL);

Callers 15

callitMethod · 0.85
callitMethod · 0.85
callitMethod · 0.85
callitMethod · 0.85
callitMethod · 0.85
callitMethod · 0.85
callitMethod · 0.85
callitMethod · 0.85
callitMethod · 0.85
callitMethod · 0.85
callitMethod · 0.85
callitMethod · 0.85

Calls 10

assign_image_to_matlabFunction · 0.85
array_to_matrixFunction · 0.85
memcpyFunction · 0.50
nrMethod · 0.45
ncMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected