function z = eps(z, y)
%EPS  Spacing of floating point numbers
%
%   Y = EPS(X) The output Y has the same data format, if any, as the input X.
%
%   Y = EPS('like',X) The output Y is an unformatted scalar dlarray.
%
%   See also EPS, DLARRAY.

%   Copyright 2019-2023 The MathWorks, Inc.

if nargin == 1 % One input EPS(X) syntax

    % If this file is modified to not be a standard unary element-wise
    % function, please also remove the following template tags.
    %!define $UnaryFunction eps($zdata)
    %!template $UnaryElementWiseTemplate
    % Code generated and inserted by deep.dev.generateDlarrayMethods.
    
    % Extract data to work on and create a template output object.
    [z, fdz, zdata] = extractUnaryElwiseData(z);
    
    zdata = eps(matlab.lang.internal.move(zdata));
    
    z = restoreUnaryElwiseData(z, ...
        matlab.lang.internal.move(fdz), ...
        matlab.lang.internal.move(zdata));
    %!template

else % Two input EPS('like',X) syntax
    if isdlarray(z)
        z = gatherData(z.FormattedData);
    end

    if isdlarray(y)
        y = gatherData(y.FormattedData);
    end

    % Prototype data (y) is not explicitly permuted because the result of
    % eps-like ought not to depend on the exact shape of the prototype
    % data.
    outdata = eps(z, y);

    z = dlarray(outdata);
end
