Mentions légales du service

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

Update matfaust.eye to rename dtype argument to class (more matlab compliant).

parent 40b0f259
No related branches found
No related tags found
No related merge requests found
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
%> &nbsp;&nbsp;&nbsp; @b eye(S, 'complex', 'dev', 'gpu') or eye(S, 'dev', 'gpu') same as above but creates the Faust on GPU.<br/> %> &nbsp;&nbsp;&nbsp; @b eye(S, 'complex', 'dev', 'gpu') or eye(S, 'dev', 'gpu') same as above but creates the Faust on GPU.<br/>
%> %>
%> @param 'dev',str 'gpu or 'cpu' to create the Faust on CPU or GPU (by default on CPU). %> @param 'dev',str 'gpu or 'cpu' to create the Faust on CPU or GPU (by default on CPU).
%> @param 'dtype',str 'double' (by default) or 'float' to select the scalar type used for the Faust generated. %> @param 'class',str 'double' (by default) or 'single' to select the scalar type used for the Faust generated.
%> %>
%> @b Example %> @b Example
%> %>
...@@ -104,7 +104,7 @@ function F = eye(varargin) ...@@ -104,7 +104,7 @@ function F = eye(varargin)
dev = 'cpu'; dev = 'cpu';
argc = length(varargin); argc = length(varargin);
is_real = true; is_real = true;
dtype = 'double'; class = 'double';
if(argc > 0) if(argc > 0)
i = 2; i = 2;
while(i <= argc) while(i <= argc)
...@@ -124,24 +124,30 @@ function F = eye(varargin) ...@@ -124,24 +124,30 @@ function F = eye(varargin)
dev = tmparg; dev = tmparg;
end end
i = i + 1; i = i + 1;
case 'dtype' case {'class', 'dtype'}
if(argc == i || ~ strcmp(tmparg, 'float') && ~ strcmp(tmparg, 'double')) if(argc == i || ~ any(strcmp(tmparg, {'single', 'float'})) && ~ strcmp(tmparg, 'double'))
error('dtype keyword argument is not followed by a valid value: float, double.') error('class keyword argument is not followed by a valid value: single, double.')
else else
dtype = tmparg; class = tmparg;
end end
i = i + 1; i = i + 1;
otherwise otherwise
if((isstr(varargin{i}) || ischar(varargin{i})) && ~ strcmp(tmparg, 'cpu') && ~ startsWith(tmparg, 'gpu') && ~ strcmp(tmparg, 'complex') && ~ strcmp(tmparg, 'float') && ~ strcmp(tmparg, 'double')) if((isstr(varargin{i}) || ischar(varargin{i})) && ~ strcmp(tmparg, 'cpu') && ~ startsWith(tmparg, 'gpu') && ~ strcmp(tmparg, 'complex') && ~ strcmp(tmparg, 'single') && ~ strcmp(tmparg, 'double'))
error([ tmparg ' unrecognized argument']) error([ tmparg ' unrecognized argument'])
end end
end end
i = i + 1; i = i + 1;
end end
end end
if strcmp(class, 'single')
class = 'float';
end
if strcmp(class, 'float') && ~ is_real
error('complex Fausts only support double class/precision')
end
if(strcmp(dev, 'cpu')) if(strcmp(dev, 'cpu'))
if(is_real) if(is_real)
if(strcmp(dtype, 'float')) if(strcmp(class, 'float'))
core_obj = mexFaustRealFloat('eye', m, n); core_obj = mexFaustRealFloat('eye', m, n);
else else
core_obj = mexFaustReal('eye', m, n); core_obj = mexFaustReal('eye', m, n);
...@@ -151,7 +157,7 @@ function F = eye(varargin) ...@@ -151,7 +157,7 @@ function F = eye(varargin)
end end
else else
if(is_real) if(is_real)
if(strcmp(dtype, 'float')) if(strcmp(class, 'float'))
core_obj = mexFaustGPURealFloat('eye', m, n); core_obj = mexFaustGPURealFloat('eye', m, n);
else else
core_obj = mexFaustGPUReal('eye', m, n); core_obj = mexFaustGPUReal('eye', m, n);
...@@ -164,5 +170,5 @@ function F = eye(varargin) ...@@ -164,5 +170,5 @@ function F = eye(varargin)
if(core_obj == 0) if(core_obj == 0)
throw(e) throw(e)
end end
F = matfaust.Faust(core_obj, is_real, dev, dtype); F = matfaust.Faust(core_obj, is_real, dev, class);
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment