function varargout = histc(varargin)
%HISTC overloaded for distributed arrays
%   N = HISTC(X,EDGES), for vector X, counts the number of values in X that
%   fall between the elements in the EDGES vector. For a matrix or for N-D
%   array X, the same is done but only along the first non-singleton dimension
%   of X.
%   
%   N = HISTC(X,EDGES,DIM) counts the number of values in X that fall between
%   the elements in the EDGES vector along dimension DIM.
%   
%   [N,BIN] = HISTC(...) returns the bin index that each value of X falls into.
%   
%   Example:
%       N = distributed(pascal(3));
%       h = histc(N, 1:6)
%   
%   See also HISTC, DISTRIBUTED.


%   Copyright 2013-2020 The MathWorks, Inc.

% This round of error checking must be done before entering SPMD because
% some weird types could be converted to [] afterwards.
isInvalidType = @(x) ~isdistributed(x) && (~isnumeric(x) || matlab.internal.datatypes.isText(x) || issparse(x));
if nargin >= 1 && isInvalidType(varargin{1})
    error(message('MATLAB:histc:InvalidFirstInput'));
elseif nargin >= 2 && isInvalidType(varargin{2})
    error(message('MATLAB:histc:InvalidSecondInput'));
end

% Flow through the standard MATLAB version on the codistributed array
varargout = cell( 1, max( nargout, 1 ) );
[varargout{:}] = distributedutil.distributedSpmdWrapper( @histc, varargin{:} );
end
