30 #ifndef MEX_MATRIX_INTERLEAVED_HPP_INCLUDED
31 #define MEX_MATRIX_INTERLEAVED_HPP_INCLUDED
34 #include "../core/result_matrix.hpp"
40 #include <type_traits>
53 template <
class Scalar>
56 template <
class RealScalar>
65 static mxClassID
const value = mxINT32_CLASS;
71 static mxClassID
const value = mxUINT32_CLASS;
77 static mxClassID
const value = mxDOUBLE_CLASS;
83 static mxClassID
const value = mxSINGLE_CLASS;
89 template <
class Scalar>
92 static mxComplexity
const value = mxREAL;
95 template <
class RealScalar>
98 static mxComplexity
const value = mxCOMPLEX;
101 template <
class Scalar>
102 void *get_data_ptr(mxArray
const *pa);
104 template <
class Scalar>
105 Scalar *get_data_pointer(mxArray
const *pa)
108 mexErrMsgIdAndTxt(
"mex_matrix_interleaved::get_data_pointer",
109 "Mex tries to access complex array as real or vica versa");
110 return static_cast<Scalar *
>(get_data_ptr<Scalar>(pa));
114 void *get_data_ptr<double>(mxArray
const *pa)
116 return mxGetDoubles(pa);
120 void *get_data_ptr<float>(mxArray
const *pa)
122 return mxGetSingles(pa);
126 void *get_data_ptr<int>(mxArray
const *pa)
128 return mxGetInt32s(pa);
132 void *get_data_ptr<unsigned>(mxArray
const *pa)
134 return mxGetUint32s(pa);
138 void *get_data_ptr<std::complex<double> >(mxArray
const *pa)
140 return mxGetComplexDoubles(pa);
144 void *get_data_ptr<std::complex<float> >(mxArray
const *pa)
146 return mxGetComplexSingles(pa);
150 template <
class Scalar>
152 :
public Eigen::Map<Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> >
155 typedef Scalar scalar_t;
156 typedef Eigen::Map<Eigen::Matrix<scalar_t, Eigen::Dynamic, Eigen::Dynamic> > base_t;
164 matrix(
size_t rows,
size_t cols, mxArray*& output)
166 static_cast<scalar_t*>(
167 get_data_pointer<scalar_t>(
168 output = mxCreateNumericMatrix(
185 static_cast<scalar_t*>(get_data_pointer<scalar_t>(input)),
192 template <
class RealScalar>
193 using real_matrix = matrix<RealScalar>;
195 template <
class RealScalar>
196 using complex_matrix = matrix<std::complex<RealScalar> >;
198 template <
class Scalar>
199 Scalar
const &get_scalar(mxArray
const *pa)
201 return *
static_cast<Scalar
const *
>(get_data_ptr<Scalar>(pa));
207 template <
class Scalar>