Mentions légales du service

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

Document matfaust.fact.butterfly and add dir='left'|'right' argument.

parent 9aab054f
No related branches found
No related tags found
No related merge requests found
% experimental block start
%==========================================================================
%> @brief Factorizes the matrix M according to the butterfly support.
%> @brief Factorizes the matrix M according to a butterfly support.
%>
%> @param 'dir', str: the direction of factorization 'right'ward or 'left'ward
%> (more precisely: at each stage of the factorization the most right factor or
%> the most left factor is split in two).
%>
%> @retval F the Faust which is an approximate of M according to a butterfly support.
%==========================================================================
function F = butterfly(M)
import matfaust.Faust
if(isreal(M))
core_obj = mexButterflyReal(M);
else
core_obj = mexButterflyCplx(M);
end
F = Faust(core_obj, isreal(M));
function F = butterfly(M, varargin)
import matfaust.Faust
nargin = length(varargin);
dir = 'right';
if(nargin > 0)
for i=1:nargin
switch(varargin{i})
case 'dir'
if(nargin < i+1 || ~ any(strcmp(varargin{i+1}, {'right', 'left'})))
error('keyword argument ''dir'' must be followed by ''left'' or ''right''')
else
dir = varargin{i+1};
end
end
end
end
if(strcmp(dir, 'right'))
dir = 1;
elseif(strcmp(dir, 'left'))
dir = 0;
end
if(isreal(M))
core_obj = mexButterflyReal(M, dir);
else
core_obj = mexButterflyCplx(M, dir);
end
F = Faust(core_obj, isreal(M));
end
% experimental block end
......@@ -72,16 +72,18 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
if (nrhs < 1)
{
mexErrMsgTxt("Bad Number of inputs arguments (must be 1)");
mexErrMsgTxt("Bad Number of inputs arguments (must be at least 1)");
}
try
{
ButterflyFactDir dir = RIGHT;
if(nrhs >= 2)
dir = static_cast<ButterflyFactDir>(static_cast<int>(mxGetScalar(prhs[1])));
TransformHelper<SCALAR, Cpu>* F = nullptr;
Faust::MatDense<SCALAR,Cpu> matrix;
mxArray2FaustMat(prhs[0],matrix);
mxArray2FaustMat(prhs[0], matrix);
F = Faust::butterfly_hierarchical(matrix);
F->display();
F = Faust::butterfly_hierarchical(matrix, dir);
plhs[0] = convertPtr2Mat<Faust::TransformHelper<SCALAR, Cpu>>(F);
}
catch (const std::exception& e)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment