function p = sparseBalancedPartition(n, nnz1D)
%codistributor1d.sparseBalancedPartition Balanced partition p based on nnz
% per row/column as row vector. If nnz1D is not scalar, we aim for the
% following:
% - Choose a partitioning of the data such that the memory used by each
% worker is broadly the same (nnz per worker)
% - Avoid workers becoming completely empty
% - Empty workers (due to less columns/rows than workers) are at the end
% If nnz1D is a scalar, the underlying matrix is either a vector or a
% scalar and we use the defaultPartition.

%   Copyright 2017-2023 The MathWorks, Inc.

narginchk(2, 2);

p = distributedutil.getCodistributor1dSparseBalancedPartition(n, nnz1D, spmdSize);
end
