function xIndices = classifyBoundsOnVars(lb,ub,nVar,findFixedVar)
%

%classifyBoundsOnVars Helper function that identifies variables
% that are fixed, and that have finite bounds. 
 
%   Copyright 2007-2022 The MathWorks, Inc.

xIndices.finiteLb = ~isinf(lb);
xIndices.finiteUb = ~isinf(ub);
% Fixed variables
if findFixedVar
    % Indices for which both v1 and v2 are finite
    finiteRange_idx = xIndices.finiteLb & xIndices.finiteUb;

    % Indices at which v1 and v2 are (i) finite and (ii) equal in a
    % floating point sense
    xIndices.fixed = finiteRange_idx & ...
        abs(lb - ub) <= eps*max( 1,max(abs(lb),abs(ub)) );

    % Finite lower and upper bounds; exclude fixed variables
    xIndices.finiteLb = ~xIndices.fixed & xIndices.finiteLb;
    xIndices.finiteUb = ~xIndices.fixed & xIndices.finiteUb;
else % Do not attempt to detect fixed variables
    xIndices.fixed = false(nVar,1);
end
