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

#include <PrimitiveFunctions.h>

Inheritance diagram for inet::math::ConstantFunction< R, D >:
inet::math::FunctionBase< R, D > inet::math::IFunction< R, D >

Public Member Functions

 ConstantFunction (R value)
 
virtual R getConstantValue () const
 
virtual Interval< R > getRange () const override
 Returns the valid range of the function as an interval. More...
 
virtual R getValue (const typename D::P &p) const override
 Returns the value of the function at the given point. More...
 
virtual void partition (const typename D::I &i, const std::function< void(const typename D::I &, const IFunction< R, D > *)> callback) const override
 Subdivides the provided domain and calls back f with the subdomains and the corresponding potentially simpler domain limited functions. More...
 
virtual bool isFinite (const typename D::I &i) const override
 Returns true if the function value is finite in the given domain. More...
 
virtual bool isNonZero (const typename D::I &i) const override
 Returns true if the function value is non-zero in the given domain. More...
 
virtual R getMin (const typename D::I &i) const override
 Returns the minimum value for the given domain. More...
 
virtual R getMax (const typename D::I &i) const override
 Returns the maximum value for the given domain. More...
 
virtual R getMean (const typename D::I &i) const override
 Returns the mean value for the given domain. More...
 
virtual R getIntegral (const typename D::I &i) const override
 Returns the integral value for the given domain. More...
 
virtual void printPartition (std::ostream &os, const typename D::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...
 
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, D >
virtual Interval< R > getRange (const typename D::I &i) const override
 Returns the valid range of the function as an interval for the given domain. More...
 
virtual D::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 isNonZero () const override
 Returns true if the function value is non-zero in the whole domain. More...
 
virtual R getMin () const override
 Returns the minimum value for the whole domain. More...
 
virtual R getMax () const override
 Returns the maximum value for the whole domain. More...
 
virtual R getMean () const override
 Returns the mean value for the whole domain. More...
 
virtual R getIntegral () const override
 Returns the integral value for the whole domain. More...
 
virtual const Ptr< const IFunction< R, D > > add (const Ptr< const IFunction< R, D >> &o) const override
 Adds the provided function to this function. More...
 
virtual const Ptr< const IFunction< R, D > > subtract (const Ptr< const IFunction< R, D >> &o) const override
 Substracts the provided function from this function. More...
 
virtual const Ptr< const IFunction< R, D > > multiply (const Ptr< const IFunction< double, D >> &o) const override
 Multiplies the provided function with this function. More...
 
virtual const Ptr< const IFunction< double, D > > divide (const Ptr< const IFunction< R, D >> &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 D::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 D::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...
 
- Public Member Functions inherited from inet::math::IFunction< R, D >
virtual ~IFunction ()
 

Protected Attributes

const R value
 

Constructor & Destructor Documentation

◆ ConstantFunction()

template<typename R , typename D >
inet::math::ConstantFunction< R, D >::ConstantFunction ( value)
inline
25 : value(value) {}

Member Function Documentation

◆ getConstantValue()

template<typename R , typename D >
virtual R inet::math::ConstantFunction< R, D >::getConstantValue ( ) const
inlinevirtual
27 { return value; }

◆ getIntegral()

template<typename R , typename D >
virtual R inet::math::ConstantFunction< R, D >::getIntegral ( const typename D::I &  i) const
inlineoverridevirtual

Returns the integral value for the given domain.

Reimplemented from inet::math::FunctionBase< R, D >.

42 { return value == R(0) ? value : value *i.getVolume(); }

◆ getMax()

template<typename R , typename D >
virtual R inet::math::ConstantFunction< R, D >::getMax ( const typename D::I &  i) const
inlineoverridevirtual

Returns the maximum value for the given domain.

Reimplemented from inet::math::FunctionBase< R, D >.

40 { return value; }

◆ getMean()

template<typename R , typename D >
virtual R inet::math::ConstantFunction< R, D >::getMean ( const typename D::I &  i) const
inlineoverridevirtual

Returns the mean value for the given domain.

Reimplemented from inet::math::FunctionBase< R, D >.

41 { return value; }

◆ getMin()

template<typename R , typename D >
virtual R inet::math::ConstantFunction< R, D >::getMin ( const typename D::I &  i) const
inlineoverridevirtual

Returns the minimum value for the given domain.

Reimplemented from inet::math::FunctionBase< R, D >.

39 { return value; }

◆ getRange()

template<typename R , typename D >
virtual Interval<R> inet::math::ConstantFunction< R, D >::getRange ( ) const
inlineoverridevirtual

Returns the valid range of the function as an interval.

Reimplemented from inet::math::FunctionBase< R, D >.

29 { return Interval<R>(value, value, 0b1, 0b1, 0b0); }

◆ getValue()

template<typename R , typename D >
virtual R inet::math::ConstantFunction< R, D >::getValue ( const typename D::P &  p) const
inlineoverridevirtual

Returns the value of the function at the given point.

The returned value falls into the range of the function. The provided point must fall into the domain of the function.

Implements inet::math::IFunction< R, D >.

31 { return value; }

◆ isFinite()

template<typename R , typename D >
virtual bool inet::math::ConstantFunction< R, D >::isFinite ( const typename D::I &  i) const
inlineoverridevirtual

Returns true if the function value is finite in the given domain.

Reimplemented from inet::math::FunctionBase< R, D >.

37 { return std::isfinite(toDouble(value)); }

◆ isNonZero()

template<typename R , typename D >
virtual bool inet::math::ConstantFunction< R, D >::isNonZero ( const typename D::I &  i) const
inlineoverridevirtual

Returns true if the function value is non-zero in the given domain.

Reimplemented from inet::math::FunctionBase< R, D >.

38 { return value != R(0); }

◆ partition()

template<typename R , typename D >
virtual void inet::math::ConstantFunction< R, D >::partition ( const typename D::I &  i,
const std::function< void(const typename D::I &, const IFunction< R, D > *)>  f 
) const
inlineoverridevirtual

Subdivides the provided domain and calls back f with the subdomains and the corresponding potentially simpler domain limited functions.

Reimplemented from inet::math::FunctionBase< R, D >.

33  {
34  callback(i, this);
35  }

◆ printPartition()

template<typename R , typename D >
virtual void inet::math::ConstantFunction< R, D >::printPartition ( std::ostream &  os,
const typename D::I &  i,
int  level = 0 
) const
inlineoverridevirtual

Prints a single partition of this function in a human readable form to the provided stream for the given domain.

Reimplemented from inet::math::FunctionBase< R, D >.

44  {
45  os << "constant over " << i << "\n" << std::string(level + 2, ' ') << "→ " << value << std::endl;
46  }

◆ printStructure()

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

48  {
49  os << "Constant " << value;
50  }

Member Data Documentation

◆ value

template<typename R , typename D >
const R inet::math::ConstantFunction< R, D >::value
protected

The documentation for this class was generated from the following file:
inet::math::ConstantFunction::value
const R value
Definition: PrimitiveFunctions.h:22
inet::math::toDouble
double toDouble(const T v)
Definition: Point.h:28
inet::units::constants::R
const value< double, compose< units::J, compose< pow< units::mol, -1 >, pow< units::kg, -1 > > > > R(8.314472)