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

Combines 2 one-dimensional functions into a two-dimensional function. More...

#include <CompoundFunctions.h>

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

Public Member Functions

 Combined2DFunction (const Ptr< const IFunction< R, Domain< X >>> &functionX, const Ptr< const IFunction< double, Domain< Y >>> &functionY)
 
virtual Interval< X, Y > getDomain () 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 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 Attributes

const Ptr< const IFunction< R, Domain< X > > > functionX
 
const Ptr< const IFunction< double, Domain< Y > > > functionY
 

Detailed Description

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

Combines 2 one-dimensional functions into a two-dimensional function.

Constructor & Destructor Documentation

◆ Combined2DFunction()

template<typename R , typename X , typename Y >
inet::math::Combined2DFunction< R, X, Y >::Combined2DFunction ( const Ptr< const IFunction< R, Domain< X >>> &  functionX,
const Ptr< const IFunction< double, Domain< Y >>> &  functionY 
)
inline
198  :

Member Function Documentation

◆ getDomain()

template<typename R , typename X , typename Y >
virtual Interval<X, Y> inet::math::Combined2DFunction< R, X, Y >::getDomain ( ) const
inlineoverridevirtual
201  {
202  const auto& fDomain = functionX->getDomain();
203  const auto& gDomain = functionY->getDomain();
204  Point<X, Y> lower(std::get<0>(fDomain.getLower()), std::get<0>(gDomain.getLower()));
205  Point<X, Y> upper(std::get<0>(fDomain.getUpper()), std::get<0>(gDomain.getUpper()));
206  auto lowerClosed = fDomain.getLowerClosed() << 1 | gDomain.getLowerClosed();
207  auto upperClosed = fDomain.getUpperClosed() << 1 | gDomain.getUpperClosed();
208  auto fixed = fDomain.getFixed() << 1 | gDomain.getFixed();
209  return Interval<X, Y>(lower, upper, lowerClosed, upperClosed, fixed);
210  }

◆ getValue()

template<typename R , typename X , typename Y >
virtual R inet::math::Combined2DFunction< R, X, Y >::getValue ( const Point< X, Y > &  p) const
inlineoverridevirtual
212  {
213  return functionX->getValue(std::get<0>(p)) * functionY->getValue(std::get<1>(p));
214  }

◆ partition()

template<typename R , typename X , typename Y >
virtual void inet::math::Combined2DFunction< 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
216  {
217  Interval<X> ix(Point<X>(std::get<0>(i.getLower())), Point<X>(std::get<0>(i.getUpper())), (i.getLowerClosed() & 0b10) >> 1, (i.getUpperClosed() & 0b10) >> 1, (i.getFixed() & 0b10) >> 1);
218  Interval<Y> iy(Point<Y>(std::get<1>(i.getLower())), Point<Y>(std::get<1>(i.getUpper())), (i.getLowerClosed() & 0b01) >> 0, (i.getUpperClosed() & 0b01) >> 0, (i.getFixed() & 0b01) >> 0);
219  functionX->partition(ix, [&] (const Interval<X>& ix1, const IFunction<R, Domain<X>> *fx1) {
220  functionY->partition(iy, [&] (const Interval<Y>& iy1, const IFunction<double, Domain<Y>> *fy1) {
221  Point<X, Y> lower(std::get<0>(ix1.getLower()), std::get<0>(iy1.getLower()));
222  Point<X, Y> upper(std::get<0>(ix1.getUpper()), std::get<0>(iy1.getUpper()));
223  auto lowerClosed = (ix1.getLowerClosed() << 1) | (iy1.getLowerClosed() << 0);
224  auto upperClosed = (ix1.getUpperClosed() << 1) | (iy1.getUpperClosed() << 0);
225  auto fixed = (ix1.getFixed() << 1) | (iy1.getFixed() << 0);
226  if (auto fx1c = dynamic_cast<const ConstantFunction<R, Domain<X>> *>(fx1)) {
227  if (auto fy1c = dynamic_cast<const ConstantFunction<double, Domain<Y>> *>(fy1)) {
228  ConstantFunction<R, Domain<X, Y>> g(fx1c->getConstantValue() * fy1c->getConstantValue());
229  callback(Interval<X, Y>(lower, upper, lowerClosed, upperClosed, fixed), &g);
230  }
231  else if (auto fy1l = dynamic_cast<const UnilinearFunction<double, Domain<Y>> *>(fy1)) {
232  UnilinearFunction<R, Domain<X, Y>> g(lower, upper, fy1l->getValue(iy1.getLower()) * fx1c->getConstantValue(), fy1l->getValue(iy1.getUpper()) * fx1c->getConstantValue(), 1);
233  simplifyAndCall(Interval<X, Y>(lower, upper, lowerClosed, upperClosed, fixed), &g, callback);
234  }
235  else
236  throw cRuntimeError("TODO");
237  }
238  else if (auto fx1l = dynamic_cast<const UnilinearFunction<R, Domain<X>> *>(fx1)) {
239  if (auto fy1c = dynamic_cast<const ConstantFunction<double, Domain<Y>> *>(fy1)) {
240  UnilinearFunction<R, Domain<X, Y>> g(lower, upper, fx1l->getValue(ix1.getLower()) * fy1c->getConstantValue(), fx1l->getValue(ix1.getUpper()) * fy1c->getConstantValue(), 0);
241  simplifyAndCall(Interval<X, Y>(lower, upper, lowerClosed, upperClosed, fixed), &g, callback);
242  }
243  else {
244 // QuadraticFunction<double, Domain<X, Y>> g();
245  throw cRuntimeError("TODO");
246  }
247  }
248  else
249  throw cRuntimeError("TODO");
250  });
251  });
252  }

◆ printStructure()

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

254  {
255  os << "(# ";
256  functionX->printStructure(os, level + 3);
257  os << "\n" << std::string(level + 3, ' ');
258  functionY->printStructure(os, level + 3);
259  os << ")";
260  }

Member Data Documentation

◆ functionX

template<typename R , typename X , typename Y >
const Ptr<const IFunction<R, Domain<X> > > inet::math::Combined2DFunction< R, X, Y >::functionX
protected

◆ functionY

template<typename R , typename X , typename Y >
const Ptr<const IFunction<double, Domain<Y> > > inet::math::Combined2DFunction< R, X, Y >::functionY
protected

The documentation for this class was generated from the following file:
inet::math::Combined2DFunction::functionX
const Ptr< const IFunction< R, Domain< X > > > functionX
Definition: CompoundFunctions.h:193
inet::units::units::g
milli< kg >::type g
Definition: Units.h:1071
inet::math::Combined2DFunction::functionY
const Ptr< const IFunction< double, Domain< Y > > > functionY
Definition: CompoundFunctions.h:194
inet::units::constants::R
const value< double, compose< units::J, compose< pow< units::mol, -1 >, pow< units::kg, -1 > > > > R(8.314472)
inet::math::simplifyAndCall
void simplifyAndCall(const typename D::I &i, const IFunction< R, D > *f, const std::function< void(const typename D::I &, const IFunction< R, D > *)> callback)
Definition: PrimitiveFunctions.h:776