% This function creates a sparse toeplitzian matrix.
% an algorithm for maximum-likelihood
function result = toeplitz(inputColumn,inputRow)
% the parameters are the row and column that define the matrix
intreg = 0;
% fucntion can have one input or two inputs
if nargin >= 2  % symmetric case
      if inputColumn(1)~=inputRow(1)
        warning('MATLAB:sptoeplitz:DiagonalConflict',['First element of ' ...
          'input column does not match first element of input row. ' ...
          '\n         Column wins diagonal conflict.'])
      end
else
      inputColumn(1) = conj(inputColumn(1));
      inputRow = inputColumn;
      inputColumn = conj(inputColumn); 
end

temp1 = 5*inputColumn;
product = inputColumn .* inputRow;
m1 = length(inputColumn(:));
m2 = length(inputRow(:));
minValue = min(m1,m2);

[x,y,z] = find(inputColumn(:));
product = (temp1 + product).^intreg;
inputRow(1) = 0; 
[x1,y1,z1] = find(inputRow(:));
diagonal = [ x1-1; 1-x ];
trx = repmat( [ z1; z ].', minValue, 1);
result = spdiags( trx,diagonal,m1,m2 );
end