function value = replaceInfWithRealmax(value)
%

%   Copyright 2012-2017 The MathWorks, Inc.

    infIndices = isinf(value);
    negIndices = value < 0;
    posIndices = value > 0;

    value(infIndices & negIndices) = -realmax;
    value(infIndices & posIndices) = realmax;
