21 RealLimits::RealLimits()
22 : m_has_lower_limit(false), m_has_upper_limit(false), m_lower_limit(0.), m_upper_limit(0.)
26 RealLimits::RealLimits(
bool has_lower_limit,
bool has_upper_limit,
double lower_limit,
28 : m_has_lower_limit(has_lower_limit), m_has_upper_limit(has_upper_limit),
29 m_lower_limit(lower_limit), m_upper_limit(upper_limit)
35 return m_has_lower_limit;
46 m_has_lower_limit =
true;
52 m_has_lower_limit =
false;
105 return RealLimits(
true,
false, bound_value, 0.);
110 return lowerLimited(std::numeric_limits<double>::min());
120 return RealLimits(
false,
true, 0., bound_value);
125 return RealLimits(
true,
true, left_bound_value, right_bound_value);
133 std::string RealLimits::toString()
const
135 std::ostringstream result;
138 result <<
"unlimited";
140 else if (isPositive())
141 result <<
"positive";
143 else if (isNonnegative())
144 result <<
"nonnegative";
146 else if (isLowerLimited())
147 result <<
"lowerLimited(" << std::fixed << std::setprecision(2) <<
lowerLimit() <<
")";
149 else if (isUpperLimited())
150 result <<
"upperLimited(" << std::fixed << std::setprecision(2) <<
upperLimit() <<
")";
152 else if (isLimited())
153 result <<
"limited(" << std::fixed << std::setprecision(2) <<
lowerLimit() <<
","
154 << std::fixed << std::setprecision(2) <<
upperLimit() <<
")";
159 bool RealLimits::operator==(
const RealLimits& other)
const
161 return (m_has_lower_limit == other.m_has_lower_limit)
166 bool RealLimits::operator!=(
const RealLimits& other)
const
168 return !(*
this == other);
171 bool RealLimits::isLimitless()
const
176 bool RealLimits::isPositive()
const
179 &&
lowerLimit() == std::numeric_limits<double>::min();
182 bool RealLimits::isNonnegative()
const
187 bool RealLimits::isLowerLimited()
const
192 bool RealLimits::isUpperLimited()
const
197 bool RealLimits::isLimited()
const
Defines class RealLimits.
Limits for a real fit parameter.
static RealLimits limitless()
Creates an object withoud bounds (default)
void removeLowerLimit()
remove lower limit
static RealLimits upperLimited(double bound_value)
Creates an object bounded from the right.
bool hasUpperLimit() const
if has upper limit
static RealLimits lowerLimited(double bound_value)
Creates an object bounded from the left.
bool hasLowerAndUpperLimits() const
if has lower and upper limit
static RealLimits positive()
Creates an object which can have only positive values (>0., zero is not included)
bool isInRange(double value) const
returns true if proposed value is in limits range
double m_lower_limit
parameter has upper bound
bool m_has_upper_limit
parameter has lower bound
double upperLimit() const
Returns upper limit.
void setLowerLimit(double value)
Sets lower limit.
double lowerLimit() const
Returns lower limit.
void removeUpperLimit()
remove upper limit
void setLimits(double xmin, double xmax)
Sets lower and upper limits.
static RealLimits nonnegative()
Creates an object which can have only positive values with 0. included.
double m_upper_limit
minimum allowed value
void removeLimits()
remove limits
static RealLimits limited(double left_bound_value, double right_bound_value)
Creates an object bounded from the left and right.
bool hasLowerLimit() const
if has lower limit
void setUpperLimit(double value)
Sets upper limit.