function z = erf(z)
%ERF    Error function.
%   Y = ERF(X) is the error function for each element of X.  X must be
%   real. The error function is defined as:
%
%     erf(x) = 2/sqrt(pi) * integral from 0 to x of exp(-t^2) dt.
%
%   The output Y has the same data format, if any, as the input X.
%
%   See also ERF, DLARRAY.

%   Copyright 2021-2023 The MathWorks, Inc.

% If this file is modified to not be a standard unary element-wise
% function, please also remove the following template tags.
%!define $UnaryFunction erf($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 = erf(matlab.lang.internal.move(zdata));

z = restoreUnaryElwiseData(z, ...
    matlab.lang.internal.move(fdz), ...
    matlab.lang.internal.move(zdata));
%!template
end
