BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
RealLimits Class Reference

Description

Limits for a real fit parameter.

Public Member Functions

 RealLimits ()
 Default constructor creates a "limitless" instance. More...
 
void check (const std::string &name, double value) const
 Throws if value is outside limits. Parameter 'name' is for exception message. More...
 
bool hasLowerAndUpperLimits () const
 if has lower and upper limit More...
 
bool hasLowerLimit () const
 if has lower limit More...
 
bool hasUpperLimit () const
 if has upper limit More...
 
bool isInRange (double value) const
 Returns true if proposed value is in limits range. More...
 
bool isLimited () const
 
bool isLimitless () const
 
bool isLowerLimited () const
 
bool isNonnegative () const
 
bool isPositive () const
 
bool isUpperLimited () const
 
double lowerLimit () const
 Returns lower limit. More...
 
bool operator!= (const RealLimits &other) const
 
bool operator== (const RealLimits &other) const
 
void removeLimits ()
 remove limits More...
 
void removeLowerLimit ()
 remove lower limit More...
 
void removeUpperLimit ()
 remove upper limit More...
 
RealLimits scaledLimits (double factor) const
 Creates a copy with scaled boundaries, if applicable. More...
 
void setLimits (double xmin, double xmax)
 Sets lower and upper limits. More...
 
void setLowerLimit (double value)
 Sets lower limit. More...
 
void setUpperLimit (double value)
 Sets upper limit. More...
 
std::string toString () const
 
double upperLimit () const
 Returns upper limit. More...
 

Static Public Member Functions

static RealLimits limited (double left_bound_value, double right_bound_value)
 Creates an object bounded from the left and right. More...
 
static RealLimits limitless ()
 Creates an object without bounds (default) More...
 
static RealLimits lowerLimited (double bound_value)
 Creates an object bounded from the left. More...
 
static RealLimits nonnegative ()
 Creates an object which can have only positive values with 0. included. More...
 
static RealLimits positive ()
 Creates an object which can have only positive values (>0., zero is not included) More...
 
static RealLimits upperLimited (double bound_value)
 Creates an object bounded from the right. More...
 

Protected Member Functions

 RealLimits (bool has_lower_limit, bool has_upper_limit, double lower_limit, double upper_limit)
 

Protected Attributes

bool m_has_lower_limit
 
bool m_has_upper_limit
 parameter has lower bound More...
 
double m_lower_limit
 parameter has upper bound More...
 
double m_upper_limit
 minimum allowed value More...
 

Friends

std::ostream & operator<< (std::ostream &ostr, const RealLimits &m)
 Prints class. More...
 

Constructor & Destructor Documentation

◆ RealLimits() [1/2]

RealLimits::RealLimits ( )

Default constructor creates a "limitless" instance.

◆ RealLimits() [2/2]

RealLimits::RealLimits ( bool  has_lower_limit,
bool  has_upper_limit,
double  lower_limit,
double  upper_limit 
)
protected

Member Function Documentation

◆ check()

void RealLimits::check ( const std::string &  name,
double  value 
) const

Throws if value is outside limits. Parameter 'name' is for exception message.

◆ hasLowerAndUpperLimits()

bool RealLimits::hasLowerAndUpperLimits ( ) const

if has lower and upper limit

◆ hasLowerLimit()

bool RealLimits::hasLowerLimit ( ) const

if has lower limit

◆ hasUpperLimit()

bool RealLimits::hasUpperLimit ( ) const

if has upper limit

◆ isInRange()

bool RealLimits::isInRange ( double  value) const

Returns true if proposed value is in limits range.

◆ isLimited()

bool RealLimits::isLimited ( ) const

◆ isLimitless()

bool RealLimits::isLimitless ( ) const

◆ isLowerLimited()

bool RealLimits::isLowerLimited ( ) const

◆ isNonnegative()

bool RealLimits::isNonnegative ( ) const

◆ isPositive()

bool RealLimits::isPositive ( ) const

◆ isUpperLimited()

bool RealLimits::isUpperLimited ( ) const

◆ limited()

static RealLimits RealLimits::limited ( double  left_bound_value,
double  right_bound_value 
)
static

Creates an object bounded from the left and right.

◆ limitless()

static RealLimits RealLimits::limitless ( )
static

Creates an object without bounds (default)

◆ lowerLimit()

double RealLimits::lowerLimit ( ) const

Returns lower limit.

◆ lowerLimited()

static RealLimits RealLimits::lowerLimited ( double  bound_value)
static

Creates an object bounded from the left.

◆ nonnegative()

static RealLimits RealLimits::nonnegative ( )
static

Creates an object which can have only positive values with 0. included.

◆ operator!=()

bool RealLimits::operator!= ( const RealLimits other) const

◆ operator==()

bool RealLimits::operator== ( const RealLimits other) const

◆ positive()

static RealLimits RealLimits::positive ( )
static

Creates an object which can have only positive values (>0., zero is not included)

◆ removeLimits()

void RealLimits::removeLimits ( )

remove limits

◆ removeLowerLimit()

void RealLimits::removeLowerLimit ( )

remove lower limit

◆ removeUpperLimit()

void RealLimits::removeUpperLimit ( )

remove upper limit

◆ scaledLimits()

RealLimits RealLimits::scaledLimits ( double  factor) const

Creates a copy with scaled boundaries, if applicable.

◆ setLimits()

void RealLimits::setLimits ( double  xmin,
double  xmax 
)

Sets lower and upper limits.

◆ setLowerLimit()

void RealLimits::setLowerLimit ( double  value)

Sets lower limit.

◆ setUpperLimit()

void RealLimits::setUpperLimit ( double  value)

Sets upper limit.

◆ toString()

std::string RealLimits::toString ( ) const

◆ upperLimit()

double RealLimits::upperLimit ( ) const

Returns upper limit.

◆ upperLimited()

static RealLimits RealLimits::upperLimited ( double  bound_value)
static

Creates an object bounded from the right.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  ostr,
const RealLimits m 
)
friend

Prints class.

Member Data Documentation

◆ m_has_lower_limit

bool RealLimits::m_has_lower_limit
protected

◆ m_has_upper_limit

bool RealLimits::m_has_upper_limit
protected

parameter has lower bound

◆ m_lower_limit

double RealLimits::m_lower_limit
protected

parameter has upper bound

◆ m_upper_limit

double RealLimits::m_upper_limit
protected

minimum allowed value