Mentions légales du service

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

Add butterfly diagonal optimization option (diag_opt) to matfaust.dft.

parent bec3943e
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,11 @@
%> @param n: the power of two for a FFT of order n and a factorization in log2(n)+1 factors.
%> @param 'normed',bool: true (by default) to normalize the returned Faust as if Faust.normalize() was called, false otherwise.
%> @param 'dev', str: 'gpu or 'cpu' to create the Faust on CPU or GPU ('cpu' by default).
%>
%> @param 'diag_opt', bool: enable the diagonal optimization of Butterfly and permutation
%> factors. Basically, it consists to simplify the product of Faust-vector
%> F*x and Faust-matrix F*M to multiplications of factor
%> diagonals by the vector x/matrix M. It is particularly more efficient
%> when the DFT is multiplied by a matrix.
%>
%> @retval F the Faust implementing the FFT transform of dimension n.
%>
......@@ -60,6 +64,7 @@ function F = dft(n, varargin)
end
normed = true; % normalization by default
dev = 'cpu';
diag_opt = false;
argc = length(varargin);
if(argc > 0)
for i=1:2:argc
......@@ -68,6 +73,12 @@ function F = dft(n, varargin)
tmparg = varargin{i+1};
end
switch(varargin{i})
case 'diag_opt'
if(argc == i || ~ islogical(tmparg))
error('diag_opt keyword argument is not followed by a logical')
else
diag_opt = tmparg;
end
case 'normed'
if(argc == i || ~ islogical(tmparg))
error('normed keyword argument is not followed by a logical')
......@@ -88,9 +99,9 @@ function F = dft(n, varargin)
end
end
if(strcmp(dev, 'cpu'))
core_obj = mexFaustCplx('fourier', log2n, normed);
core_obj = mexFaustCplx('fourier', log2n, normed, diag_opt);
else
core_obj = mexFaustGPUCplx('fourier', log2n, normed);
core_obj = mexFaustGPUCplx('fourier', log2n, normed, diag_opt);
end
is_real = false;
e = MException('FAUST:OOM', 'Out of Memory');
......
#include "class_handle.hpp"
#include "faust_TransformHelper.h"
#include "faust_TransformHelperButterfly.h"
#ifdef USE_GPU_MOD
#include "faust_TransformHelperButterfly_gpu.h"
#endif
template <typename SCALAR, FDevice DEV>
void faust_fourier(const mxArray **prhs, const int nrhs, mxArray **plhs, const int nlhs)
{
if(nlhs!=1)
mexErrMsgTxt("mex dft(): too many left hand side variables.");
if(nrhs < 3)
mexErrMsgTxt("mex dft(): wrong number of arguments (must be 3)");
if(nrhs < 4)
mexErrMsgTxt("mex dft(): wrong number of arguments (must be 4)");
unsigned int n = (unsigned int) mxGetScalar(prhs[1]);
bool norma = (bool) mxGetScalar(prhs[2]);
Faust::TransformHelper<complex<double>,DEV>* F = Faust::TransformHelper<complex<double>,DEV>::fourierFaust(n, norma);
bool diag_prod = (bool) mxGetScalar(prhs[3]);
Faust::TransformHelper<complex<double>,DEV>* F = nullptr;
if(diag_prod)
{
F = Faust::TransformHelperButterfly<complex<double>,DEV>::fourierFaust(n, norma);
}
else
F = Faust::TransformHelper<complex<double>,DEV>::fourierFaust(n, norma);
if(F) //not NULL
plhs[0]=convertPtr2Mat<Faust::TransformHelper<complex<double>,DEV> >(F);
else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment