function y = fpdf(x,v1,v2)
%FPDF   F probability density function optimized for the GPU.
%   Y = FPDF(X,V1,V2)
%
%   See also FPDF, GPUARRAY.

%   Algorithm must be kept in-sync with toolbox/stats/stats/fpdf.m

%   Copyright 2019 The MathWorks, Inc.


if nargin < 3
    error(message('stats:fpdf:TooFewInputs'));
end
[errorcode, x, v1, v2] = distchck(3,x,v1,v2);
if errorcode > 0
    error(message('stats:fpdf:InputSizeMismatch'));
end

% Work out the output type, then call arrayfun to do the actual work
% (this compiles the body into a single GPU kernel)
outProto = zeros(1,"like",internal.stats.dominantType(x,v1,v2));
y = arrayfun( @fpdf_scalar, x, v1, v2, outProto );
end
