function varargout = commblkbschan(P, M, s)
%COMMBLKBSCHAN Helper file for the Binary Symmetric Channel block.

%   Copyright 1996-2000 The MathWorks, Inc.
%   $Revision: 1.1 $  $Date: 2000/08/29 23:09:04 $

if ( sum(~isreal(P)) ) | ( sum(P<0) > 0 ) | ( sum(P>1) > 0 )
    error('Error probability values must be real numbers between zero and one.');
end
if ( length(M) > 1 ) | ( floor(M) ~= M ) | ( abs(M) ~= M )
    error('Input vector length must be a real, positive, scalar integer.');
end
if ( sum(abs(s) ~= s) ) | ( sum(floor(s) ~= s) )
    error('Initial seed values must be real, positive integers.');
end
if M > 1
    if length(P) > 1
        if length(P) ~= M
            error('Error probability must be either a scalar or a vector of size given by Input vector length.');
        end
    else
        P = P.*ones(1,M);
    end
    if length(s) > 1
        if length(s) ~= M
            error('Initial seed must be either a scalar or a vector of size given by Input vector length.');
        end
    else
        s = s*cumsum(1:M); 
    end
else
    if (length(P) > 1) | (length(s) > 1)
        error('If either Error probability or Initial seed is a vector, then Input vector length must equal the length of the vector.');
    end
end
varargout{1} = P;
varargout{2} = s;
