Mentions légales du service

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

Update matfaust.eye and its mex code to bind them to the new C++ core impl. of Faust eye.

parent 3b840f47
Branches
Tags
No related merge requests found
......@@ -16,6 +16,7 @@
%>
%>Faust size 4x4, density 0.25, nnz_sum 4, 1 factor(s):
%>- FACTOR 0 (real) SPARSE, size 4x4, density 0.25, nnz 4
%>identity matrix flag
%>
%>>> full(matfaust.eye(4))
%>
......@@ -99,9 +100,13 @@ function F = eye(varargin)
if(nargin ~= 1 && ~ isnumeric(la) && (ischar(la) || ischar(cell2mat(la))))
% F = Faust(sparse(1:m, 1:n, 1+eps(1)*j)); % hack to avoid passing through a full matrix
if(strcmp(la,'complex'))
F = Faust(eye(m,n,'like', sparse(1,1,1+i)));
% F = Faust(eye(m,n,'like', sparse(1,1,1+i)));
core_obj = mexFaustCplx('eye', m, n);
is_real = false;
elseif(strcmp(la, 'real'))
F = Faust(speye(m,n));
% F = Faust(speye(m,n));
core_obj = mexFaustReal('eye', m, n);
is_real = true;
else
if(iscell(la))
la = cell2mat(la)
......@@ -109,6 +114,14 @@ function F = eye(varargin)
error(['Unknown option: ' la])
end
else
F = Faust(speye(m,n));
% F = Faust(speye(m,n));
core_obj = mexFaustReal('eye', m, n);
is_real = true;
end
e = MException('FAUST:OOM', 'Out of Memory');
if(core_obj == 0)
throw(e)
end
F = matfaust.Faust(core_obj, is_real);
end
......@@ -154,9 +154,9 @@ void save(Faust::TransformHelper<SCALAR,Cpu>* core_ptr, int nargs, const mxArray
//TODO: hadamard, fourier, and proxs must be in there own mex function (one for hadamard and fourier, another for the prox)
if(!strcmp("hadamard", cmd)){
if(nlhs!=1)
mexErrMsgTxt("hadamard(): 1 variable result is expected.");
mexErrMsgTxt("mex wht(): too many left hand side variables.");
if(nrhs < 3)
mexErrMsgTxt("hadamard(): wrong number of arguments (must be 2)");
mexErrMsgTxt("mex wht(): wrong number of arguments (must be 3)");
unsigned int n = (unsigned int) mxGetScalar(prhs[1]);
bool norma = (bool) mxGetScalar(prhs[2]);
......@@ -174,11 +174,12 @@ void save(Faust::TransformHelper<SCALAR,Cpu>* core_ptr, int nargs, const mxArray
}
if(!strcmp("fourier", cmd)){
if(!strcmp("fourier", cmd))
{
if(nlhs!=1)
mexErrMsgTxt("fourier(): 1 variable result is expected.");
mexErrMsgTxt("mex dft(): too many left hand side variables.");
if(nrhs < 3)
mexErrMsgTxt("fourier(): wrong number of arguments (must be 2)");
mexErrMsgTxt("mex dft(): wrong number of arguments (must be 3)");
unsigned int n = (unsigned int) mxGetScalar(prhs[1]);
bool norma = (bool) mxGetScalar(prhs[2]);
......@@ -196,6 +197,25 @@ void save(Faust::TransformHelper<SCALAR,Cpu>* core_ptr, int nargs, const mxArray
}
if(!strcmp("eye", cmd))
{
if(nlhs != 1)
mexErrMsgTxt("eye(): too many left hand side variables.");
unsigned int n, m;
n = mxGetScalar(prhs[1]);
m = mxGetScalar(prhs[2]);
Faust::TransformHelper<SCALAR,Cpu>* eye = Faust::TransformHelper<SCALAR,Cpu>::eyeFaust(n, m);
if(eye) // not NULL
plhs[0] = convertPtr2Mat<Faust::TransformHelper<SCALAR,Cpu>>(eye);
else
{
plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL);
double* ptr_out = (double*) mxGetData(plhs[0]);
ptr_out[0]=(double) 0;
}
return;
}
if(!strcmp("prox", cmd))
{
if(nlhs!=1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment