Mentions légales du service

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

Verify matfaust.toeplitz r and c arguments and allow to pass indifferently a...

Verify matfaust.toeplitz r and c arguments and allow to pass indifferently a row-vector or a column-vector.
parent 999ecd41
Branches
Tags
No related merge requests found
...@@ -14,18 +14,28 @@ ...@@ -14,18 +14,28 @@
%> @b See also matfaust.circ, matfaust.anticirc %> @b See also matfaust.circ, matfaust.anticirc
%========================================= %=========================================
function T = toeplitz(c, varargin) function T = toeplitz(c, varargin)
if (length(varargin) > 0) if (length(varargin) > 0)
r = varargin{1}; r = varargin{1};
if(~ ismatrix(r) || size(r, 1) ~= 1 && size(r, 2) ~= 1) if(~ ismatrix(r) || size(r, 1) ~= 1 && size(r, 2) ~= 1)
error('The second argument must be a vector') error('The second argument must be a vector')
end end
else else
r = c; % default r r = c; % default r
end end
m = numel(c); if size(c, 2) == 1
n = numel(r); c = c.';
N = 2 ^ ceil(log2(max(m, n))); elseif size(c, 1) ~= 1
c_ = [c, zeros(1, N-m+1+N-n), r(end:-1:2)]; error('c must be a vector')
C = matfaust.circ(c_); end
T = C(1:m, 1:n); if size(r, 2) == 1
r = r.';
elseif size(r, 1) ~= 1
error('r must be a vector')
end
m = numel(c);
n = numel(r);
N = 2 ^ ceil(log2(max(m, n)));
c_ = [c, zeros(1, N-m+1+N-n), r(end:-1:2)];
C = matfaust.circ(c_);
T = C(1:m, 1:n);
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment