Mentions légales du service

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

Add matfaust wrapper to TransformHelper::optimize_multiply() and fix VS14...

Add matfaust wrapper to TransformHelper::optimize_multiply() and fix VS14 specific error (C3863) into TransformHelper::optimize_multiply.
parent dd031ac4
Branches
Tags
No related merge requests found
......@@ -300,7 +300,7 @@ namespace Faust {
void TransformHelper<FPP,Cpu>::optimize_multiply(const bool transp /* deft to false */)
{
int NMETS = 5; //skip openmp method (not supported on macOS)
std::chrono::duration<double> times[NMETS];
std::chrono::duration<double> * times = new std::chrono::duration<double>[NMETS]; //use heap because of VS14 (error C3863)
MatDense<FPP,Cpu>* M = MatDense<FPP,Cpu>::randMat(transp?this->getNbRow():this->getNbCol(), 2048);
int nmuls = 1, opt_meth=0;
for(int i=0; i < NMETS; i++)
......@@ -319,6 +319,7 @@ namespace Faust {
opt_meth = times[opt_meth]<times[i+1]?opt_meth:i+1;
}
this->set_mul_order_opt_mode(opt_meth);
delete [] times;
}
template<typename FPP>
......
......@@ -797,13 +797,40 @@ classdef Faust
%> matrix products of the Faust.
%>
%=====================================================================
function OF = optimize(F)
function OF = optimize(F, varargin)
len_args = length(varargin);
transp = false; % default value
if(len_args > 0)
if(strcmp(varargin{1}, {'transpose', 'transp'}) && len_args > 1 && islogical(varargin{2}))
transp = varargin{2};
else
error('invalid key or value arguments')
end
end
if(F.isReal)
OF = matfaust.Faust(F, mexFaustReal('optimize', F.matrix.objectHandle, transp));
else % cplx Faust
OF = matfaust.Faust(F, mexFaustCplx('optimize', F.matrix.objectHandle, transp));
end
end
function OF = optimize_mul(F, varargin)
len_args = length(varargin);
transp = false; % default value
if(len_args > 0)
if(strcmp(varargin{1}, {'transpose', 'transp'}) && len_args > 1 && islogical(varargin{2}))
transp = varargin{2};
else
error('invalid key or value arguments')
end
end
if(F.isReal)
OF = matfaust.Faust(F, mexFaustReal('optimize', F.matrix.objectHandle));
mexFaustReal('optimize_mul', F.matrix.objectHandle, transp);
else % cplx Faust
OF = matfaust.Faust(F, mexFaustCplx('optimize', F.matrix.objectHandle));
mexFaustCplx('optimize_mul', F.matrix.objectHandle, transp);
end
end
%======================================================================
%> @brief The size of F.
%>
......
......@@ -718,13 +718,25 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
}
if(!strcmp("optimize", cmd)) {
if(nrhs != 2)
if(nrhs != 3)
mexErrMsgTxt("optimize mex error: invalid number of arguments.");
Faust::TransformHelper<SCALAR,Cpu>* th = core_ptr->optimize();
bool transp = (bool) mxGetScalar(prhs[2]);
Faust::TransformHelper<SCALAR,Cpu>* th = core_ptr->optimize(transp);
plhs[0] = convertPtr2Mat<Faust::TransformHelper<SCALAR,Cpu> >(th);
return;
}
if(!strcmp("optimize_mul", cmd))
{
if(nrhs != 3)
mexErrMsgTxt("optimize_mul mex error: invalid number of arguments.");
if(nlhs != 0)
mexErrMsgTxt("optimize_mul mex error: this function doesn't return any output argument.");
bool transp = (bool) mxGetScalar(prhs[2]);
core_ptr->optimize_multiply(transp);
return;
}
if(! strcmp("pruneout", cmd))
{
int nnz_tres = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment