Mentions légales du service

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

Add conversion CPU MatButterfly/MatPerm on the fly conversion to MatSparse in...

Add conversion CPU MatButterfly/MatPerm on the fly conversion to MatSparse in mex code of matfaust.factors.
parent dd5bfbc9
Branches
Tags
No related merge requests found
......@@ -45,5 +45,15 @@
#define __MEX_FAUST_FACTORS__
template <typename SCALAR, FDevice DEV>
void faust_factors(const mxArray **prhs, const int nrhs, mxArray **plhs, const int nlhs);
template <typename SCALAR>
mxArray* bsr_mat_to_sp_mat(int id, Faust::TransformHelper<SCALAR,Cpu>* core_ptr);
template <typename SCALAR>
mxArray* bsr_mat_to_sp_mat(int id, Faust::TransformHelper<SCALAR,GPU2>* core_ptr);
template <typename SCALAR>
mxArray* butterfly_mat_to_sp_mat(int id, Faust::TransformHelper<SCALAR,Cpu>* core_ptr);
template <typename SCALAR>
mxArray* perm_mat_to_sp_mat(int id, Faust::TransformHelper<SCALAR,Cpu>* core_ptr);
#include "faust_factors.hpp"
#endif
......@@ -5,11 +5,6 @@
/**
* These functions allow to convert a MatBSR factor of a Faust::TransformHelper to MatSparse, as the bsr matrices are not supported in Matlab.
*/
template <typename SCALAR>
mxArray* bsr_mat_to_sp_mat(int id, Faust::TransformHelper<SCALAR,Cpu>* core_ptr);
template <typename SCALAR>
mxArray* bsr_mat_to_sp_mat(int id, Faust::TransformHelper<SCALAR,GPU2>* core_ptr);
template <typename SCALAR, FDevice DEV>
void faust_factors(const mxArray **prhs, const int nrhs, mxArray **plhs, const int nlhs)
......@@ -20,6 +15,7 @@ void faust_factors(const mxArray **prhs, const int nrhs, mxArray **plhs, const i
mexErrMsgTxt("factors : incorrect number of arguments.");
}
int id = (int) (mxGetScalar(prhs[2])-1);
auto type = core_ptr->get_fact_type(id);
if(core_ptr->is_fact_sparse(id))
plhs[0] = transformFact2SparseMxArray(id,core_ptr);
......@@ -32,6 +28,12 @@ void faust_factors(const mxArray **prhs, const int nrhs, mxArray **plhs, const i
{
plhs[0] = bsr_mat_to_sp_mat(id, core_ptr);
}
else if(type == 4)
// MatButterfly
plhs[0] = butterfly_mat_to_sp_mat(id, core_ptr);
else if(type == 5)
// MatPerm
plhs[0] = perm_mat_to_sp_mat(id, core_ptr);
else
mexErrMsgTxt("Unhandled type of matrix");
......@@ -45,6 +47,24 @@ mxArray* bsr_mat_to_sp_mat(int id, Faust::TransformHelper<SCALAR,Cpu>* core_ptr)
return FaustSpMat2mxArray(sp_mat);
}
template <typename SCALAR>
mxArray* butterfly_mat_to_sp_mat(int id, Faust::TransformHelper<SCALAR,Cpu>* core_ptr)
{
auto bf_mat = dynamic_cast<const MatButterfly<SCALAR, Cpu>*>(core_ptr->get_gen_fact(id));
auto sp_mat = bf_mat->toMatSparse();
return FaustSpMat2mxArray(sp_mat);
}
template <typename SCALAR>
mxArray* perm_mat_to_sp_mat(int id, Faust::TransformHelper<SCALAR,Cpu>* core_ptr)
{
auto p_mat = dynamic_cast<const MatPerm<SCALAR, Cpu>*>(core_ptr->get_gen_fact(id));
auto sp_mat = p_mat->toMatSparse();
return FaustSpMat2mxArray(sp_mat);
}
#ifdef USE_GPU_MOD
template <typename SCALAR>
mxArray* bsr_mat_to_sp_mat(int id, Faust::TransformHelper<SCALAR, GPU2>* core_ptr)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment