INET Framework for OMNeT++/OMNEST
inet::math::Boxcar2DFunction< R, X, Y > Class Template Reference

Some constant value r between (lowerX, lowerY) and (upperX, upperY) and zero otherwise. More...

#include <PrimitiveFunctions.h>

Inheritance diagram for inet::math::Boxcar2DFunction< R, X, Y >:
inet::math::FunctionBase< R, Domain< X, Y > > inet::math::IFunction< R, Domain< X, Y > >

Public Member Functions

 Boxcar2DFunction (X lowerX, X upperX, Y lowerY, Y upperY, R value)
 
virtual Interval< R > getRange () const override
 
virtual R getValue (const Point< X, Y > &p) const override
 
virtual void partition (const Interval< X, Y > &i, const std::function< void(const Interval< X, Y > &, const IFunction< R, Domain< X, Y >> *)> callback) const override
 
virtual bool isFinite (const Interval< X, Y > &i) const override
 
virtual bool isNonZero (const Interval< X, Y > &i) const override
 
virtual void printStructure (std::ostream &os, int level=0) const override
 Prints the internal data structure of this function in a human readable form to the provided stream. More...
 
- Public Member Functions inherited from inet::math::FunctionBase< R, Domain< X, Y > >
virtual void partition (const typename Domain< X, Y > ::I &i, const std::function< void(const typename Domain< X, Y > ::I &, const IFunction< R, Domain< X, Y > > *)> callback) const override
 Subdivides the provided domain and calls back f with the subdomains and the corresponding potentially simpler domain limited functions. More...
 
virtual Interval< R > getRange () const override
 Returns the valid range of the function as an interval. More...
 
virtual Interval< R > getRange (const typename Domain< X, Y > ::I &i) const override
 Returns the valid range of the function as an interval for the given domain. More...
 
virtual Domain< X, Y > ::I getDomain () const override
 Returns the valid domain of the function as an interval. More...
 
virtual bool isFinite () const override
 Returns true if the function value is finite in the whole domain. More...
 
virtual bool isFinite (const typename Domain< X, Y > ::I &i) const override
 Returns true if the function value is finite in the given domain. More...
 
virtual bool isNonZero () const override
 Returns true if the function value is non-zero in the whole domain. More...
 
virtual bool isNonZero (const typename Domain< X, Y > ::I &i) const override
 Returns true if the function value is non-zero in the given domain. More...
 
virtual R getMin () const override
 Returns the minimum value for the whole domain. More...
 
virtual R getMin (const typename Domain< X, Y > ::I &i) const override
 Returns the minimum value for the given domain. More...
 
virtual R getMax () const override
 Returns the maximum value for the whole domain. More...
 
virtual R getMax (const typename Domain< X, Y > ::I &i) const override
 Returns the maximum value for the given domain. More...
 
virtual R getMean () const override
 Returns the mean value for the whole domain. More...
 
virtual R getMean (const typename Domain< X, Y > ::I &i) const override
 Returns the mean value for the given domain. More...
 
virtual R getIntegral () const override
 Returns the integral value for the whole domain. More...
 
virtual R getIntegral (const typename Domain< X, Y > ::I &i) const override
 Returns the integral value for the given domain. More...
 
virtual const Ptr< const IFunction< R, Domain< X, Y > > > add (const Ptr< const IFunction< R, Domain< X, Y > >> &o) const override
 Adds the provided function to this function. More...
 
virtual const Ptr< const IFunction< R, Domain< X, Y > > > subtract (const Ptr< const IFunction< R, Domain< X, Y > >> &o) const override
 Substracts the provided function from this function. More...
 
virtual const Ptr< const IFunction< R, Domain< X, Y > > > multiply (const Ptr< const IFunction< double, Domain< X, Y > >> &o) const override
 Multiplies the provided function with this function. More...
 
virtual const Ptr< const IFunction< double, Domain< X, Y > > > divide (const Ptr< const IFunction< R, Domain< X, Y > >> &o) const override
 Divides this function with the provided function. More...
 
virtual std::ostream & printOn (std::ostream &os) const override
 
virtual void print (std::ostream &os, int level=0) const override
 Prints this function in human readable form to the provided stream for the whole domain. More...
 
virtual void print (std::ostream &os, const typename Domain< X, Y > ::I &i, int level=0) const override
 Prints this function in a human readable form to the provided stream for the given domain. More...
 
virtual void printPartitioning (std::ostream &os, const typename Domain< X, Y > ::I &i, int level) const override
 Prints the partitioning of this function in a human readable form to the provided stream for the given domain. More...
 
virtual void printPartition (std::ostream &os, const typename Domain< X, Y > ::I &i, int level=0) const override
 Prints a single partition of this function in a human readable form to the provided stream for the given domain. More...
 
- Public Member Functions inherited from inet::math::IFunction< R, Domain< X, Y > >
virtual ~IFunction ()
 
virtual R getValue (const typename Domain< X, Y > ::P &p) const=0
 Returns the value of the function at the given point. More...
 

Protected Member Functions

void call (const Interval< X, Y > &i, const std::function< void(const Interval< X, Y > &, const IFunction< R, Domain< X, Y >> *)> callback, R r) const
 

Protected Attributes

const X lowerX
 
const X upperX
 
const Y lowerY
 
const Y upperY
 
const R value
 

Detailed Description

template<typename R, typename X, typename Y>
class inet::math::Boxcar2DFunction< R, X, Y >

Some constant value r between (lowerX, lowerY) and (upperX, upperY) and zero otherwise.

Constructor & Destructor Documentation

◆ Boxcar2DFunction()

template<typename R , typename X , typename Y >
inet::math::Boxcar2DFunction< R, X, Y >::Boxcar2DFunction ( lowerX,
upperX,
lowerY,
upperY,
value 
)
inline
425  :
427  {
428  ASSERT(value > R(0));
429  }

Member Function Documentation

◆ call()

template<typename R , typename X , typename Y >
void inet::math::Boxcar2DFunction< R, X, Y >::call ( const Interval< X, Y > &  i,
const std::function< void(const Interval< X, Y > &, const IFunction< R, Domain< X, Y >> *)>  callback,
r 
) const
inlineprotected
417  {
418  if (!i.isEmpty()) {
419  ConstantFunction<R, Domain<X, Y>> g(r);
420  callback(i, &g);
421  }
422  }

◆ getRange()

template<typename R , typename X , typename Y >
virtual Interval<R> inet::math::Boxcar2DFunction< R, X, Y >::getRange ( ) const
inlineoverridevirtual
431 { return Interval<R>(R(0), value, 0b1, 0b1, 0b0); }

◆ getValue()

template<typename R , typename X , typename Y >
virtual R inet::math::Boxcar2DFunction< R, X, Y >::getValue ( const Point< X, Y > &  p) const
inlineoverridevirtual
433  {
434  return std::get<0>(p) < lowerX || std::get<0>(p) >= upperX || std::get<1>(p) < lowerY || std::get<1>(p) >= upperY ? R(0) : value;
435  }

◆ isFinite()

template<typename R , typename X , typename Y >
virtual bool inet::math::Boxcar2DFunction< R, X, Y >::isFinite ( const Interval< X, Y > &  i) const
inlineoverridevirtual
451 { return std::isfinite(toDouble(value)); }

◆ isNonZero()

template<typename R , typename X , typename Y >
virtual bool inet::math::Boxcar2DFunction< R, X, Y >::isNonZero ( const Interval< X, Y > &  i) const
inlineoverridevirtual
452  {
453  return value != R(0) &&
454  lowerX <= std::get<0>(i.getLower()) && std::get<0>(i.getUpper()) <= upperX &&
455  lowerY <= std::get<1>(i.getLower()) && std::get<1>(i.getUpper()) <= upperY;
456  }

◆ partition()

template<typename R , typename X , typename Y >
virtual void inet::math::Boxcar2DFunction< R, X, Y >::partition ( const Interval< X, Y > &  i,
const std::function< void(const Interval< X, Y > &, const IFunction< R, Domain< X, Y >> *)>  callback 
) const
inlineoverridevirtual
437  {
438  call(i.getIntersected(Interval<X, Y>(Point<X, Y>(getLowerBound<X>(), getLowerBound<Y>()), Point<X, Y>(X(lowerX), Y(lowerY)), 0b00, 0b00, 0b00)), callback, R(0));
439  call(i.getIntersected(Interval<X, Y>(Point<X, Y>(X(lowerX), getLowerBound<Y>()), Point<X, Y>(X(upperX), Y(lowerY)), 0b10, 0b00, 0b00)), callback, R(0));
440  call(i.getIntersected(Interval<X, Y>(Point<X, Y>(X(upperX), getLowerBound<Y>()), Point<X, Y>(getUpperBound<X>(), Y(lowerY)), 0b10, 0b00, 0b00)), callback, R(0));
441 
442  call(i.getIntersected(Interval<X, Y>(Point<X, Y>(getLowerBound<X>(), Y(lowerY)), Point<X, Y>(X(lowerX), Y(upperY)), 0b01, 0b00, 0b00)), callback, R(0));
443  call(i.getIntersected(Interval<X, Y>(Point<X, Y>(X(lowerX), Y(lowerY)), Point<X, Y>(X(upperX), Y(upperY)), 0b11, 0b00, 0b00)), callback, value);
444  call(i.getIntersected(Interval<X, Y>(Point<X, Y>(X(upperX), Y(lowerY)), Point<X, Y>(getUpperBound<X>(), Y(upperY)), 0b11, 0b00, 0b00)), callback, R(0));
445 
446  call(i.getIntersected(Interval<X, Y>(Point<X, Y>(getLowerBound<X>(), Y(upperY)), Point<X, Y>(X(lowerX), getUpperBound<Y>()), 0b01, 0b00, 0b00)), callback, R(0));
447  call(i.getIntersected(Interval<X, Y>(Point<X, Y>(X(lowerX), Y(upperY)), Point<X, Y>(X(upperX), getUpperBound<Y>()), 0b11, 0b00, 0b00)), callback, R(0));
448  call(i.getIntersected(Interval<X, Y>(Point<X, Y>(X(upperX), Y(upperY)), Point<X, Y>(getUpperBound<X>(), getUpperBound<Y>()), 0b11, 0b00, 0b00)), callback, R(0));
449  }

◆ printStructure()

template<typename R , typename X , typename Y >
virtual void inet::math::Boxcar2DFunction< R, X, Y >::printStructure ( std::ostream &  os,
int  level = 0 
) const
inlineoverridevirtual

Prints the internal data structure of this function in a human readable form to the provided stream.

Reimplemented from inet::math::FunctionBase< R, Domain< X, Y > >.

458  {
459  os << "(Boxcar2D, [" << lowerX << " … " << upperX << "] x [" << lowerY << " … " << upperY << "] → " << value << ")";
460  }

Member Data Documentation

◆ lowerX

template<typename R , typename X , typename Y >
const X inet::math::Boxcar2DFunction< R, X, Y >::lowerX
protected

◆ lowerY

template<typename R , typename X , typename Y >
const Y inet::math::Boxcar2DFunction< R, X, Y >::lowerY
protected

◆ upperX

template<typename R , typename X , typename Y >
const X inet::math::Boxcar2DFunction< R, X, Y >::upperX
protected

◆ upperY

template<typename R , typename X , typename Y >
const Y inet::math::Boxcar2DFunction< R, X, Y >::upperY
protected

◆ value

template<typename R , typename X , typename Y >
const R inet::math::Boxcar2DFunction< R, X, Y >::value
protected

The documentation for this class was generated from the following file:
inet::math::Boxcar2DFunction::lowerY
const Y lowerY
Definition: PrimitiveFunctions.h:412
inet::math::toDouble
double toDouble(const T v)
Definition: Point.h:28
inet::units::units::g
milli< kg >::type g
Definition: Units.h:1071
inet::math::Boxcar2DFunction::value
const R value
Definition: PrimitiveFunctions.h:414
inet::units::constants::R
const value< double, compose< units::J, compose< pow< units::mol, -1 >, pow< units::kg, -1 > > > > R(8.314472)
inet::math::Boxcar2DFunction::upperY
const Y upperY
Definition: PrimitiveFunctions.h:413
inet::math::Boxcar2DFunction::call
void call(const Interval< X, Y > &i, const std::function< void(const Interval< X, Y > &, const IFunction< R, Domain< X, Y >> *)> callback, R r) const
Definition: PrimitiveFunctions.h:417
inet::math::Boxcar2DFunction::lowerX
const X lowerX
Definition: PrimitiveFunctions.h:410
inet::math::Boxcar2DFunction::upperX
const X upperX
Definition: PrimitiveFunctions.h:411