function errorForLabeledUnlessScalar(x, hasDimsX, y, hasDimsY)
%ERRORFORLABELEDUNLESSSCALAR Error check helper for MTIMES and DLMTIMES

%   Copyright 2019 The MathWorks, Inc.

if hasDimsX && ~(isscalar(y) && ~hasDimsY)
    % x has labels, but y is not an unformatted scalar
    error(message('deep:dlarray:MtimesLabeled'));
end

if hasDimsY && ~(isscalar(x) && ~hasDimsX)
    % y has labels, but x is not an unformatted scalar
    error(message('deep:dlarray:MtimesLabeled'));
end
