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

Some constant value r between lower and upper and zero otherwise. More...

#include <PrimitiveFunctions.h>

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

Public Member Functions

 Boxcar1DFunction (X lower, X upper, R value)
 
virtual Interval< R > getRange () const override
 
virtual R getValue (const Point< X > &p) const override
 
virtual void partition (const Interval< X > &i, const std::function< void(const Interval< X > &, const IFunction< R, Domain< X >> *)> callback) const override
 
virtual bool isFinite (const Interval< X > &i) const override
 
virtual bool isNonZero (const Interval< X > &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 > >
virtual void partition (const typename Domain< X > ::I &i, const std::function< void(const typename Domain< X > ::I &, const IFunction< R, Domain< X > > *)> 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 > ::I &i) const override
 Returns the valid range of the function as an interval for the given domain. More...
 
virtual Domain< X > ::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 > ::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 > ::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 > ::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 > ::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 > ::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 > ::I &i) const override
 Returns the integral value for the given domain. More...
 
virtual const Ptr< const IFunction< R, Domain< X > > > add (const Ptr< const IFunction< R, Domain< X > >> &o) const override
 Adds the provided function to this function. More...
 
virtual const Ptr< const IFunction< R, Domain< X > > > subtract (const Ptr< const IFunction< R, Domain< X > >> &o) const override
 Substracts the provided function from this function. More...
 
virtual const Ptr< const IFunction< R, Domain< X > > > multiply (const Ptr< const IFunction< double, Domain< X > >> &o) const override
 Multiplies the provided function with this function. More...
 
virtual const Ptr< const IFunction< double, Domain< X > > > divide (const Ptr< const IFunction< R, Domain< X > >> &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 > ::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 > ::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 > ::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 > >
virtual ~IFunction ()
 
virtual R getValue (const typename Domain< X > ::P &p) const=0
 Returns the value of the function at the given point. More...
 

Protected Attributes

const X lower
 
const X upper
 
const R value
 

Detailed Description

template<typename R, typename X>
class inet::math::Boxcar1DFunction< R, X >

Some constant value r between lower and upper and zero otherwise.

Constructor & Destructor Documentation

◆ Boxcar1DFunction()

template<typename R , typename X >
inet::math::Boxcar1DFunction< R, X >::Boxcar1DFunction ( lower,
upper,
value 
)
inline
367  : lower(lower), upper(upper), value(value) {
368  ASSERT(value > R(0));
369  }

Member Function Documentation

◆ getRange()

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

◆ getValue()

template<typename R , typename X >
virtual R inet::math::Boxcar1DFunction< R, X >::getValue ( const Point< X > &  p) const
inlineoverridevirtual
373  {
374  return std::get<0>(p) < lower || std::get<0>(p) >= upper ? R(0) : value;
375  }

◆ isFinite()

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

◆ isNonZero()

template<typename R , typename X >
virtual bool inet::math::Boxcar1DFunction< R, X >::isNonZero ( const Interval< X > &  i) const
inlineoverridevirtual
396 { return value != R(0) && lower <= std::get<0>(i.getLower()) && std::get<0>(i.getUpper()) <= upper; }

◆ partition()

template<typename R , typename X >
virtual void inet::math::Boxcar1DFunction< R, X >::partition ( const Interval< X > &  i,
const std::function< void(const Interval< X > &, const IFunction< R, Domain< X >> *)>  callback 
) const
inlineoverridevirtual
377  {
378  const auto& i1 = i.getIntersected(Interval<X>(getLowerBound<X>(), Point<X>(lower), 0b0, 0b0, 0b0));
379  if (!i1.isEmpty()) {
380  ConstantFunction<R, Domain<X>> g(R(0));
381  callback(i1, &g);
382  }
383  const auto& i2 = i.getIntersected(Interval<X>(Point<X>(lower), Point<X>(upper), 0b1, 0b0, 0b0));
384  if (!i2.isEmpty()) {
385  ConstantFunction<R, Domain<X>> g(value);
386  callback(i2, &g);
387  }
388  const auto& i3 = i.getIntersected(Interval<X>(Point<X>(upper), getUpperBound<X>(), 0b1, 0b0, 0b0));
389  if (!i3.isEmpty()) {
390  ConstantFunction<R, Domain<X>> g(R(0));
391  callback(i3, &g);
392  }
393  }

◆ printStructure()

template<typename R , typename X >
virtual void inet::math::Boxcar1DFunction< R, X >::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 > >.

398  {
399  os << "(Boxcar1D, [" << lower << " … " << upper << "] → " << value << ")";
400  }

Member Data Documentation

◆ lower

template<typename R , typename X >
const X inet::math::Boxcar1DFunction< R, X >::lower
protected

◆ upper

template<typename R , typename X >
const X inet::math::Boxcar1DFunction< R, X >::upper
protected

◆ value

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

The documentation for this class was generated from the following file:
inet::math::Boxcar1DFunction::lower
const X lower
Definition: PrimitiveFunctions.h:362
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::units::constants::R
const value< double, compose< units::J, compose< pow< units::mol, -1 >, pow< units::kg, -1 > > > > R(8.314472)
inet::math::Boxcar1DFunction::upper
const X upper
Definition: PrimitiveFunctions.h:363
inet::math::Boxcar1DFunction::value
const R value
Definition: PrimitiveFunctions.h:364