Mentions légales du service

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

Enable default normalization in mataust.FaustFactory.wht() using C++ backend...

Enable default normalization in mataust.FaustFactory.wht() using C++ backend code (added by 7daa5b22).

Issue #112 related.
parent 715f4623
No related branches found
No related tags found
No related merge requests found
......@@ -759,20 +759,21 @@ classdef FaustFactory
if(log2n > 31)
error('Can''t handle a Hadamard Faust of order larger than 2^31')
end
core_obj = mexFaustReal('hadamard', log2n);
is_real = true;
e = MException('FAUST:OOM', 'Out of Memory');
if(core_obj == 0)
throw(e)
end
H = matfaust.Faust(core_obj, is_real);
if(length(varargin) > 0)
if(~ islogical(varargin{1}))
error('wht optional second argument must be a boolean');
end
norma = varargin{1};
else
H =H*(1/sqrt(n));
norma = true; % normalization by default
end
core_obj = mexFaustReal('hadamard', log2n, norma);
is_real = true;
e = MException('FAUST:OOM', 'Out of Memory');
if(core_obj == 0)
throw(e)
end
H = matfaust.Faust(core_obj, is_real);
end
%==========================================================================================
......@@ -845,7 +846,6 @@ classdef FaustFactory
else
F = F*(1/sqrt(n));
end
end
%==========================================================================================
......
......@@ -155,12 +155,13 @@ void save(Faust::TransformHelper<SCALAR,Cpu>* core_ptr, int nargs, const mxArray
if(!strcmp("hadamard", cmd)){
if(nlhs!=1)
mexErrMsgTxt("hadamard(): 1 variable result is expected.");
if(nrhs < 2)
if(nrhs < 3)
mexErrMsgTxt("hadamard(): wrong number of arguments (must be 2)");
unsigned int n = (unsigned int) mxGetScalar(prhs[1]);
bool norma = (bool) mxGetScalar(prhs[2]);
//printf("mexFaust.cpp hadamard(): faust creation\n");
Faust::TransformHelper<SCALAR,Cpu>* H = Faust::TransformHelper<SCALAR,Cpu>::hadamardFaust(n);
Faust::TransformHelper<SCALAR,Cpu>* H = Faust::TransformHelper<SCALAR,Cpu>::hadamardFaust(n, norma);
//H->display();
if(H) //not NULL
plhs[0]=convertPtr2Mat<Faust::TransformHelper<SCALAR,Cpu> >(H);
......@@ -519,7 +520,7 @@ void save(Faust::TransformHelper<SCALAR,Cpu>* core_ptr, int nargs, const mxArray
if(!strcmp("normalize", cmd))
{
int ord = (int) mxGetScalar(prhs[2]);
if(ord == 2) ord = -2; //tmp workaround to the bug in normalization according 2-norm on complex Faust
Faust::TransformHelper<SCALAR,Cpu>* th = core_ptr->normalize(ord);
plhs[0] = convertPtr2Mat<Faust::TransformHelper<SCALAR,Cpu> >(th);
return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment