function X = extractdata(obj)
%EXTRACTDATA Extract data represented by dlarray
%   Y = EXTRACTDATA(X) returns the data that is represented by the dlarray X.
%   The output Y is of type double, single, logical, or a gpuArray of
%   one of these types depending on the type of X. All dimension label
%   information is removed. If X contains an implicit permutation, this is
%   explicitly computed for the output Y.
%
%   See also DLARRAY, GATHER.

%   Copyright 2019-2021 The MathWorks, Inc.

X = gatherData(obj.FormattedData);

if isa(X, 'deep.internal.blank')
    error(message('deep:blank:NotSupported'))
end

if ~isempty(obj.ViewToDataMap)
    X = permute(X, obj.ViewToDataMap);
end
end
