[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #50854] zeros: like keyword
From: |
Ceral Paquet |
Subject: |
[Octave-bug-tracker] [bug #50854] zeros: like keyword |
Date: |
Wed, 26 Apr 2017 01:55:57 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0 |
Follow-up Comment #6, bug #50854 (project octave):
It looks like "like" only copies the following properties:
* data type (class)
* complexity
* sparsity
X = zeros(___,'like',p) returns an array of zeros like p; that is, of the same
data type (class), sparsity, and complexity (real or complex) as p. You can
specify typename or 'like', but not both.
Sorry I have no ability to implement this properly. It's not that it's a
must-have thing, it just not having it breaks Matlab code. This is a horrible
hackaround.
function x = zeros(varargin)
for k = 1:nargin
if isequal(varargin{k},'like')
if k+1 > nargin
error('''like'' must be followed by a variable.');
end
varargin{k} = class(varargin{k+1});
varargin(k+1) = [];
break;
end
end
x = builtin('zeros',varargin{:});
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?50854>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/