Skip to content

Commit

Permalink
Improving support for single precision
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenbeckr committed May 23, 2019
1 parent 9a794ad commit 35591e6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
11 changes: 10 additions & 1 deletion @tfocs_tuple/tfocs_normsq.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@
% must be preserved. However, an object may overload
% TFOCS_NORMSQ to compute its value more efficiently.

v = sum( cellfun( @tfocs_normsq, x.value_ ) );
if ~all( cellfun('isclass',x.value_,'double') )
tmp = cellfun( @tfocs_normsq, x.value_,'UniformOutput',false );
% encapsulates each in a cell array
v = 0;
for i = 1:length(tmp)
v = v + tmp{i}; % might convert singles to doubles
end
else
v = sum( cellfun( @tfocs_normsq, x.value_ ) );
end

% TFOCS v1.3 by Stephen Becker, Emmanuel Candes, and Michael Grant.
% Copyright 2013 California Institute of Technology and CVX Research.
Expand Down
2 changes: 1 addition & 1 deletion linop_dot.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
% OP = LINOP_DOT( A, 1 ) returns the adjoint of that operator.

switch class( A ),
case 'double',
case {'double','single'}
sz = { size(A), [1,1] };
case 'cell',
A = tfocs_tuple(A);
Expand Down
7 changes: 6 additions & 1 deletion private/tfocs_zeros.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
else
z = zeros( size(y) );
end

case 'single'
if (numel(y) == 2 || numel(y) == 3) && all(isint(y))
z = zeros( y ,'single');
else
z = zeros( size(y) ,'single');
end
case 'cell',
if isa( y{1}, 'function_handle' ),
z = y{1}( y{2:end} );
Expand Down

0 comments on commit 35591e6

Please sign in to comment.