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

Shifts the domain of a multidimensional function. More...

#include <CompoundFunctions.h>

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

Public Member Functions

 DomainShiftedFunction (const Ptr< const IFunction< R, D >> &f, const typename D::P &s)
 
virtual D::I getDomain () const override
 Returns the valid domain 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 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 override
 Returns the valid range of the function as an interval. More...
 
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 bool isFinite () const override
 Returns true if the function value is finite in the whole domain. 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 override
 Returns true if the function value is non-zero in the whole 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 override
 Returns the minimum value for the whole 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 override
 Returns the maximum value for the whole 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 override
 Returns the mean value for the whole 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 override
 Returns the integral value for the whole domain. More...
 
virtual R getIntegral (const typename D::I &i) const override
 Returns the integral value for the given 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...
 
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...
 
- Public Member Functions inherited from inet::math::IFunction< R, D >
virtual ~IFunction ()
 

Protected Attributes

const Ptr< const IFunction< R, D > > function
 
const D::P shift
 

Detailed Description

template<typename R, typename D>
class inet::math::DomainShiftedFunction< R, D >

Shifts the domain of a multidimensional function.

Constructor & Destructor Documentation

◆ DomainShiftedFunction()

template<typename R , typename D >
inet::math::DomainShiftedFunction< R, D >::DomainShiftedFunction ( const Ptr< const IFunction< R, D >> &  f,
const typename D::P &  s 
)
inline
88 : function(f), shift(s) {}

Member Function Documentation

◆ getDomain()

template<typename R , typename D >
virtual D::I inet::math::DomainShiftedFunction< R, D >::getDomain ( ) const
inlineoverridevirtual

Returns the valid domain of the function as an interval.

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

90  {
91  const auto& domain = function->getDomain();
92  typename D::I i(domain.getLower() + shift, domain.getUpper() + shift, domain.getLowerClosed(), domain.getLowerClosed(), domain.getFixed());
93  return i;
94  }

◆ getValue()

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

96  {
97  return function->getValue(p - shift);
98  }

◆ partition()

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

100  {
101  function->partition(i.getShifted(-shift), [&] (const typename D::I& i1, const IFunction<R, D> *f1) {
102  if (auto f1c = dynamic_cast<const ConstantFunction<R, D> *>(f1))
103  callback(i1.getShifted(shift), f1);
104  else if (auto f1l = dynamic_cast<const UnilinearFunction<R, D> *>(f1)) {
105  UnilinearFunction<R, D> g(i1.getLower() + shift, i1.getUpper() + shift, f1l->getValue(i1.getLower()), f1l->getValue(i1.getUpper()), f1l->getDimension());
106  simplifyAndCall(i1.getShifted(shift), &g, callback);
107  }
108  else
109  throw cRuntimeError("TODO");
110  });
111  }

◆ printStructure()

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

113  {
114  os << "(DomainShifted, shift = " << shift << "\n" << std::string(level + 2, ' ');
115  function->printStructure(os, level + 2);
116  os << ")";
117  }

Member Data Documentation

◆ function

template<typename R , typename D >
const Ptr<const IFunction<R, D> > inet::math::DomainShiftedFunction< R, D >::function
protected

◆ shift

template<typename R , typename D >
const D::P inet::math::DomainShiftedFunction< R, D >::shift
protected

The documentation for this class was generated from the following file:
inet::math::DomainShiftedFunction::shift
const D::P shift
Definition: CompoundFunctions.h:85
inet::units::values::s
value< double, units::s > s
Definition: Units.h:1235