Mentions légales du service

Skip to content
Snippets Groups Projects
Commit fa22f1f4 authored by hhakim's avatar hhakim
Browse files

Fix mex newMxGetData added in cd72e390.

Other related (or not) minor changes/fixes.
parent 43a48e29
Branches
Tags
No related merge requests found
...@@ -21,6 +21,9 @@ void new_faust(const mxArray **prhs, const int nrhs, mxArray **plhs, const int n ...@@ -21,6 +21,9 @@ void new_faust(const mxArray **prhs, const int nrhs, mxArray **plhs, const int n
for (int i=0; i < nb_element; i++) for (int i=0; i < nb_element; i++)
{ {
mxMat=mxGetCell(prhs[1],i); mxMat=mxGetCell(prhs[1],i);
// test if the i-th element of the cell is a matrix or a cell (BSR encoding)
// if the element is a valid BSR encoding create the BSRMatrix here and add it to list_factor
if(mxIsCell(mxMat)) if(mxIsCell(mxMat))
{ {
// adding at MatBSR matrix // adding at MatBSR matrix
...@@ -63,8 +66,6 @@ void new_faust(const mxArray **prhs, const int nrhs, mxArray **plhs, const int n ...@@ -63,8 +66,6 @@ void new_faust(const mxArray **prhs, const int nrhs, mxArray **plhs, const int n
continue; continue;
} }
// add a MatDense or MatSparse factor // add a MatDense or MatSparse factor
//TODO: test if the i-th element of the cell is a matrix or a cell (BSR encoding)
//TODO: if the element is a valid BSR encoding create the BSRMatrix here and add it to list_factor
concatMatGeneric<SCALAR, DEV>(mxMat, list_factor); concatMatGeneric<SCALAR, DEV>(mxMat, list_factor);
} }
......
...@@ -145,7 +145,7 @@ void mxArray2Scalar(const mxArray* scalar, complex<FPP>* out); ...@@ -145,7 +145,7 @@ void mxArray2Scalar(const mxArray* scalar, complex<FPP>* out);
* There is no copy (direct access) but the mxArray must match the type asked (otherwise a runtime error is raised). * There is no copy (direct access) but the mxArray must match the type asked (otherwise a runtime error is raised).
*/ */
template<typename FPP> template<typename FPP>
void newMxGetData(FPP* ptr_out, const mxArray* mxMat); void newMxGetData(FPP*& ptr_out, const mxArray* mxMat);
#endif #endif
#include "faust2Mx.hpp" #include "faust2Mx.hpp"
......
...@@ -65,8 +65,10 @@ ...@@ -65,8 +65,10 @@
template<typename FPP, FDevice DEV> template<typename FPP, FDevice DEV>
mxArray* FaustMat2mxArray(const Faust::MatDense<FPP,DEV>& M) mxArray* FaustMat2mxArray(const Faust::MatDense<FPP,DEV>& M)
{ {
#ifndef MX_HAS_INTERLEAVED_COMPLEX
if (!M.isReal()) if (!M.isReal())
mexErrMsgTxt("FaustMat2mxArray : Faust::MatDense must be real"); mexErrMsgTxt("FaustMat2mxArray : Faust::MatDense must be real");
#endif
mxArray * mxMat; mxArray * mxMat;
int row,col; int row,col;
...@@ -85,7 +87,7 @@ mxArray* FaustMat2mxArray(const Faust::MatDense<FPP,DEV>& M) ...@@ -85,7 +87,7 @@ mxArray* FaustMat2mxArray(const Faust::MatDense<FPP,DEV>& M)
mexErrMsgTxt("FaustMat2mxArray : unsupported type of float"); mexErrMsgTxt("FaustMat2mxArray : unsupported type of float");
} }
FPP* ptr_out; FPP* ptr_out = nullptr;
#ifdef MX_HAS_INTERLEAVED_COMPLEX #ifdef MX_HAS_INTERLEAVED_COMPLEX
newMxGetData(ptr_out, mxMat); newMxGetData(ptr_out, mxMat);
#else #else
...@@ -101,7 +103,7 @@ mxArray* FaustMat2mxArray(const Faust::MatDense<FPP,DEV>& M) ...@@ -101,7 +103,7 @@ mxArray* FaustMat2mxArray(const Faust::MatDense<FPP,DEV>& M)
#ifdef MX_HAS_INTERLEAVED_COMPLEX #ifdef MX_HAS_INTERLEAVED_COMPLEX
template<> template<>
void newMxGetData<float>(float* ptr_out, const mxArray* mxMat) void newMxGetData<float>(float*& ptr_out, const mxArray* mxMat)
{ {
if(mxGetClassID(mxMat) != mxSINGLE_CLASS || mxIsComplex(mxMat)) if(mxGetClassID(mxMat) != mxSINGLE_CLASS || mxIsComplex(mxMat))
mexErrMsgTxt("newMxGetData: the mex matrix must be double as the ptr is."); mexErrMsgTxt("newMxGetData: the mex matrix must be double as the ptr is.");
...@@ -109,7 +111,7 @@ void newMxGetData<float>(float* ptr_out, const mxArray* mxMat) ...@@ -109,7 +111,7 @@ void newMxGetData<float>(float* ptr_out, const mxArray* mxMat)
} }
template<> template<>
void newMxGetData<double>(double* ptr_out, const mxArray* mxMat) void newMxGetData<double>(double*& ptr_out, const mxArray* mxMat)
{ {
if(mxGetClassID(mxMat) != mxDOUBLE_CLASS && mxIsComplex(mxMat)) if(mxGetClassID(mxMat) != mxDOUBLE_CLASS && mxIsComplex(mxMat))
mexErrMsgTxt("newMxGetData: the mex matrix must be double as the ptr."); mexErrMsgTxt("newMxGetData: the mex matrix must be double as the ptr.");
...@@ -117,7 +119,7 @@ void newMxGetData<double>(double* ptr_out, const mxArray* mxMat) ...@@ -117,7 +119,7 @@ void newMxGetData<double>(double* ptr_out, const mxArray* mxMat)
} }
template<> template<>
void newMxGetData<std::complex<double>>(complex<double>* ptr_out, const mxArray* mxMat) void newMxGetData<std::complex<double>>(complex<double>*& ptr_out, const mxArray* mxMat)
{ {
if(mxGetClassID(mxMat) != mxDOUBLE_CLASS || ! mxIsComplex(mxMat)) if(mxGetClassID(mxMat) != mxDOUBLE_CLASS || ! mxIsComplex(mxMat))
mexErrMsgTxt("newMxGetData: the mex matrix must be complex double as the ptr."); mexErrMsgTxt("newMxGetData: the mex matrix must be complex double as the ptr.");
...@@ -125,7 +127,7 @@ void newMxGetData<std::complex<double>>(complex<double>* ptr_out, const mxArray* ...@@ -125,7 +127,7 @@ void newMxGetData<std::complex<double>>(complex<double>* ptr_out, const mxArray*
} }
template<> template<>
void newMxGetData<std::complex<float>>(complex<float>* ptr_out, const mxArray* mxMat) void newMxGetData<std::complex<float>>(complex<float>*& ptr_out, const mxArray* mxMat)
{ {
if(mxGetClassID(mxMat) != mxSINGLE_CLASS || ! mxIsComplex(mxMat)) if(mxGetClassID(mxMat) != mxSINGLE_CLASS || ! mxIsComplex(mxMat))
mexErrMsgTxt("newMxGetData: the mex matrix must be complex float as the ptr."); mexErrMsgTxt("newMxGetData: the mex matrix must be complex float as the ptr.");
...@@ -269,7 +271,7 @@ mxArray* FaustVec2mxArray(const Faust::Vect<FPP,Cpu>& M) ...@@ -269,7 +271,7 @@ mxArray* FaustVec2mxArray(const Faust::Vect<FPP,Cpu>& M)
FPP* ptr_out; FPP* ptr_out;
#ifdef MX_HAS_INTERLEAVED_COMPLEX #ifdef MX_HAS_INTERLEAVED_COMPLEX
ptr_out = static_cast<FPP*> (mxGetDoubles(mxMat)); newMxGetData(ptr_out, mxMat);
#else #else
ptr_out = static_cast<FPP*> (mxGetData(mxMat)); ptr_out = static_cast<FPP*> (mxGetData(mxMat));
#endif #endif
...@@ -499,7 +501,7 @@ mxArray* transformFact2FullMxArray(faust_unsigned_int id, Faust::TransformHelper ...@@ -499,7 +501,7 @@ mxArray* transformFact2FullMxArray(faust_unsigned_int id, Faust::TransformHelper
mxArray* fullMat = mxCreateNumericArray(2, dim_sizes, classId, mxREAL); mxArray* fullMat = mxCreateNumericArray(2, dim_sizes, classId, mxREAL);
FPP* data_ptr; FPP* data_ptr;
#ifdef MX_HAS_INTERLEAVED_COMPLEX #ifdef MX_HAS_INTERLEAVED_COMPLEX
data_ptr = static_cast<FPP*>(mxGetDoubles(fullMat)); newMxGetData(data_ptr, fullMat);
#else #else
data_ptr = static_cast<FPP*>(mxGetData(fullMat)); data_ptr = static_cast<FPP*>(mxGetData(fullMat));
#endif #endif
......
...@@ -181,7 +181,6 @@ void mxArray2PtrBase(const mxArray* mxMat, FPP* & ptr_data) ...@@ -181,7 +181,6 @@ void mxArray2PtrBase(const mxArray* mxMat, FPP* & ptr_data)
{ {
if(! is_same<FPP, double>::value) if(! is_same<FPP, double>::value)
{ {
std::cout << "NB_ELEMENTS=" << NB_ELEMENTS << std::endl;
mexErrMsgTxt("mxMat is double, the output buffer must be double"); mexErrMsgTxt("mxMat is double, the output buffer must be double");
} }
ptr_data = new FPP[NB_ELEMENTS]; ptr_data = new FPP[NB_ELEMENTS];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment