function varargout = levinson(R,varargin)
%LEVINSON  Levinson-Durbin Recursion for gpuArray inputs.
%
%   A = LEVINSON(R)
%   A = LEVINSON(R,N)
%   [A,E,K] = LEVINSON(...)
%
%   See also: LEVINSON, GPUARRRAY

%   Copyright 2021 The MathWorks, Inc.

narginchk(1,2);

if nargin > 1
    [varargin{:}] = gather(varargin{:});
end

% Gather, call toolbox function, and return outputs on the GPU
varargout = cell(1, max(1,nargout));
[varargout{:}] = parallel.internal.array.callToolboxFunction(...
    "signal/signal/levinson.m", gather(R), varargin{:});

if isgpuarray(R)
    varargout = cellfun(@(x) gpuArray(x), varargout, 'UniformOutput', false);
end