function n = pagenorm(X, p)
%PAGENORM Page-wise matrix or vector norm for codistributed array.
%   N = PAGENORM(X)
%   N = PAGENORM(X,p)
%   N = PAGENORM(X,"fro")
%   N = PAGENORM(V)
%   N = PAGENORM(V,p)
%   
%   See also PAGENORM, CODISTRIBUTED.
%   


%   Copyright 2022 The MathWorks, Inc.

arguments
    X {mustBeFloat,mustBeNonsparse}
    p = 2 % default to 2-norm. Validate later.
end

% If we have only one page avoid redistributing by calling NORM directly.
if ismatrix(X)
    n = norm(X, p);
    return
end

n = pagefun(@norm, X, p);

end