function t = toeplitz(c,r)
%TOEPLITZ Toeplitz matrix.
%   TOEPLITZ(C,R) is a non-symmetric Toeplitz matrix having C as its
%   first column and R as its first row.   
%
%   TOEPLITZ(R) is a symmetric (or Hermitian) Toeplitz matrix.
%
%   Class support for inputs C,R:
%      float: double, single
%
%   See also HANKEL.

%   Revised 10-8-92, LS - code from A.K. Booer.
%   Copyright 1984-2004 The MathWorks, Inc. 
%   $Revision: 5.11.4.2 $  $Date: 2004/12/06 16:34:56 $

if nargin < 2,
  c(1) = conj(c(1)); r = c; c = conj(c); % set up for Hermitian Toeplitz
else
  if r(1) ~= c(1)
    warning('MATLAB:toeplitz:DiagonalConflict',['First element of ' ...
           'input column does not match first element of input row. ' ...
           '\n         Column wins diagonal conflict.'])
  end
end
%
r = r(:);                               % force column structure
p = length(r);
m = length(c);
x = [r(p:-1:2) ; c(:)];                 % build vector of user data
xclass = class(x);
cidx = (zeros(xclass):m-1)';
ridx = p:-1:ones(xclass);
t = cidx(:,ones(p,1)) + ridx(ones(m,1),:);  % Toeplitz subscripts
t(:) = x(t);                                   % actual data

