function obj = sum(obj, varargin)
%SUM Sum of elements.
%   Y = SUM(X)
%   Y = SUM(X,DIM)
%   Y = SUM(X,VECDIM)
%   Y = SUM(X,'all')
%   Y = SUM(...,'double')
%   Y = SUM(...,'native')
%   Y = SUM(...,'default')
%   Y = SUM(...,'includenan')
%
%   The output Y has the same dimension labels, if any, as the input X.
%
%   The order of the products within the SUM operation can change based on
%   the internal storage order of the dlarray. This can result in
%   differences on the order of round-off for two dlarrays that are
%   otherwise equal.
%
%   See also SUM, DLARRAY, GPUARRAY/SUM.

%   Copyright 2019 The MathWorks, Inc.

[fdx, xdata, args] = helperReduction(obj, varargin{:});

omitnanUnsupported(args);

xdata = sum(xdata, args{:});

obj.FormattedData = insertData(fdx, xdata);
obj = dropTrailingODims(obj);
end
