function d = bandarraydescriptor(distA)
%BANDARRAYDESCRIPTOR 1d utility function used to create special array
% descriptor as used by ScaLAPACK and PBLAS functions for arrays in banded
% solvers

% Copyright 2020 The MathWorks, Inc.

distDim = distA.Dimension;
if distDim == 1  % Rows are distributed
    heightLocalA = distA.Partition(1);
else             % Cols are distributed
    heightLocalA = distA.Cached.GlobalSize(1);
end


% Construct the array descriptor
% Note: The block size is always square
DTYPE = 503 - distDim;                    % 1D row or column distribution
CTXT  = NaN;                              % BLACS context to be determined
N     = distA.Cached.GlobalSize(distDim); % Length in distributed dimension
NB    = distA.Partition(1);               % Block size
SRC   = 0;                                % Zero-base. Process row or col where the first 
                                          % row or col of the distributed array is located
LLD   = max(1, heightLocalA);             % Leading dimension of the local array, LLD >= 1.
FILL  = 0;                                % Reserved for future use

d = [DTYPE CTXT N NB SRC LLD FILL];
