function obj = decomposition( A, varargin )
%DECOMPOSITION Matrix decomposition of distributed array
%   DA = DECOMPOSITION(A)
%   DA = DECOMPOSITION(A, TYPE)
%   DA = DECOMPOSITION(..., 'CheckCondition', TF)
%   DA = DECOMPOSITION(..., 'RankTolerance', TOL)
%   DA = DECOMPOSITION(..., 'BandedDensity', TOL)
%   
%   Limitations:
%   * If A is sparse and TYPE is 'lu', then CheckCondition
%     must be false.
%   * If A is sparse, decomposition does not support TYPE 'chol'.
%   * If A is dense, decomposition does not support TYPE 'ldl'.
%   
%   Example:
%       N = 1000;
%       A = distributed.rand(N);
%       decompA = decomposition(A);
%       x = decompA\sum(A,2);
%   
%   See also DECOMPOSITION, DISTRIBUTED, DISTRIBUTED/RAND.


%   Copyright 2018-2021 The MathWorks, Inc.

% Gather all non-data inputs
if nargin>1
    [varargin{1:end}] = gather(varargin{:});
end

if ~isdistributed(A)
    obj = decomposition(A, varargin{:});
    return;
end

obj = parallel.distributed.Decomposition.buildFromDistributed(A, varargin{:});
end