function [R1,p] = cholupdate(R,x,sgn)
%MATLAB Code Generation Library Function

%   Copyright 1984-2019 The MathWorks, Inc.
%#codegen

narginchk(2,3);
if nargin < 3
    sgn = '+';
end
coder.internal.prefer_const(sgn);
% Homogenize the types.
type = coder.internal.scalarEg(R,x);
R1 = cast(R,'like',type);
x1 = cast(x,'like',type);
% Perform the update.
if nargout <= 1
    R1 = coder.internal.cholupdate(R1,x1,sgn,'force');
else
    [R1,int8p] = coder.internal.cholupdate(R1,x1,sgn,'force');
    coder.internal.assert(int8p >= 0,'MATLAB:maxlhs');
    p = double(int8p);
end
