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

Linear in two dimensions and constant in the others. More...

#include <PrimitiveFunctions.h>

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

Public Member Functions

 BilinearFunction (const typename D::P &lowerLower, const typename D::P &lowerUpper, const typename D::P &upperLower, const typename D::P &upperUpper, const R rLowerLower, const R rLowerUpper, const R rUpperLower, const R rUpperUpper, const int dimension1, const int dimension2)
 
virtual const D::P & getLowerLower () const
 
virtual const D::P & getLowerUpper () const
 
virtual const D::P & getUpperLower () const
 
virtual const D::P & getUpperUpper () const
 
virtual R getRLowerLower () const
 
virtual R getRLowerUpper () const
 
virtual R getRUpperLower () const
 
virtual R getRUpperUpper () const
 
virtual int getDimension1 () const
 
virtual int getDimension2 () 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 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::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 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 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::IFunction< R, D >
virtual ~IFunction ()
 

Protected Member Functions

D::I getOtherInterval (const typename D::I &i) const
 

Protected Attributes

const D::P lowerLower
 
const D::P lowerUpper
 
const D::P upperLower
 
const D::P upperUpper
 
const R rLowerLower
 
const R rLowerUpper
 
const R rUpperLower
 
const R rUpperUpper
 
const int dimension1
 
const int dimension2
 

Detailed Description

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

Linear in two dimensions and constant in the others.

Constructor & Destructor Documentation

◆ BilinearFunction()

template<typename R , typename D >
inet::math::BilinearFunction< R, D >::BilinearFunction ( const typename D::P &  lowerLower,
const typename D::P &  lowerUpper,
const typename D::P &  upperLower,
const typename D::P &  upperUpper,
const R  rLowerLower,
const R  rLowerUpper,
const R  rUpperLower,
const R  rUpperUpper,
const int  dimension1,
const int  dimension2 
)
inline

Member Function Documentation

◆ getDimension1()

template<typename R , typename D >
virtual int inet::math::BilinearFunction< R, D >::getDimension1 ( ) const
inlinevirtual
166 { return dimension1; }

◆ getDimension2()

template<typename R , typename D >
virtual int inet::math::BilinearFunction< R, D >::getDimension2 ( ) const
inlinevirtual
167 { return dimension2; }

◆ getLowerLower()

template<typename R , typename D >
virtual const D::P& inet::math::BilinearFunction< R, D >::getLowerLower ( ) const
inlinevirtual
158 { return lowerLower; }

◆ getLowerUpper()

template<typename R , typename D >
virtual const D::P& inet::math::BilinearFunction< R, D >::getLowerUpper ( ) const
inlinevirtual
159 { return lowerUpper; }

◆ getMax()

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

205  {
206  auto j = getOtherInterval(i);
207  return math::maxnan(math::maxnan(getValue(i.getLower()), getValue(j.getLower())), math::maxnan(getValue(j.getUpper()), getValue(i.getUpper())));
208  }

◆ getMean()

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

210  {
211  return getValue((i.getLower() + i.getUpper()) / 2);
212  }

◆ getMin()

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

200  {
201  auto j = getOtherInterval(i);
202  return math::minnan(math::minnan(getValue(i.getLower()), getValue(j.getLower())), math::minnan(getValue(j.getUpper()), getValue(i.getUpper())));
203  }

◆ getOtherInterval()

template<typename R , typename D >
D::I inet::math::BilinearFunction< R, D >::getOtherInterval ( const typename D::I &  i) const
inlineprotected
139  {
140  const typename D::P& lower = i.getLower();
141  const typename D::P& upper = i.getUpper();
142  typename D::P lowerUpper = D::P::getZero();
143  typename D::P upperLower = D::P::getZero();
144  lowerUpper.set(dimension1, lower.get(dimension1));
145  lowerUpper.set(dimension2, upper.get(dimension2));
146  upperLower.set(dimension1, upper.get(dimension1));
147  upperLower.set(dimension2, lower.get(dimension2));
148  return typename D::I(lowerUpper, upperLower, i.getLowerClosed(), i.getUpperClosed(), i.getFixed());
149  }

◆ getRange()

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

Returns the valid range of the function as an interval.

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

◆ getRLowerLower()

template<typename R , typename D >
virtual R inet::math::BilinearFunction< R, D >::getRLowerLower ( ) const
inlinevirtual
162 { return rLowerLower; }

Referenced by inet::math::simplifyAndCall().

◆ getRLowerUpper()

template<typename R , typename D >
virtual R inet::math::BilinearFunction< R, D >::getRLowerUpper ( ) const
inlinevirtual
163 { return rLowerUpper; }

Referenced by inet::math::simplifyAndCall().

◆ getRUpperLower()

template<typename R , typename D >
virtual R inet::math::BilinearFunction< R, D >::getRUpperLower ( ) const
inlinevirtual
164 { return rUpperLower; }

Referenced by inet::math::simplifyAndCall().

◆ getRUpperUpper()

template<typename R , typename D >
virtual R inet::math::BilinearFunction< R, D >::getRUpperUpper ( ) const
inlinevirtual
165 { return rUpperUpper; }

Referenced by inet::math::simplifyAndCall().

◆ getUpperLower()

template<typename R , typename D >
virtual const D::P& inet::math::BilinearFunction< R, D >::getUpperLower ( ) const
inlinevirtual
160 { return upperLower; }

◆ getUpperUpper()

template<typename R , typename D >
virtual const D::P& inet::math::BilinearFunction< R, D >::getUpperUpper ( ) const
inlinevirtual
161 { return upperUpper; }

◆ getValue()

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

175  {
176  double lowerAlpha = (p - lowerLower).get(dimension1) / (upperLower - lowerLower).get(dimension1);
177  R rLower = rLowerLower * (1 - lowerAlpha) + rUpperLower * lowerAlpha;
178  const typename D::P lower = lowerLower * (1 - lowerAlpha) + upperLower * lowerAlpha;
179 
180  double upperAlpha = (p - lowerUpper).get(dimension1) / (upperUpper - lowerUpper).get(dimension1);
181  R rUpper = rLowerUpper * (1 - upperAlpha) + rUpperUpper * upperAlpha;
182  const typename D::P upper = lowerUpper * (1 - upperAlpha) + upperUpper * upperAlpha;
183 
184  double alpha = (p - lower).get(dimension2) / (upper - lower).get(dimension2);
185  return rLower * (1 - alpha) + rUpper * alpha;
186  }

◆ isFinite()

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

192  {
193  return std::isfinite(toDouble(rLowerLower)) && std::isfinite(toDouble(rLowerUpper)) && std::isfinite(toDouble(rUpperLower)) && std::isfinite(toDouble(rUpperUpper));
194  }

◆ isNonZero()

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

196  {
197  return rLowerLower != R(0) || rLowerUpper != R(0) || rUpperLower != R(0) || rUpperUpper != R(0);
198  }

◆ partition()

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

188  {
189  callback(i, this);
190  }

◆ printPartition()

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

214  {
215  os << "bilinear in dims. " << dimension1 << ", " << dimension2 << " over " << i << "\n"
216  << std::string(level + 2, ' ') << "→ " << getValue(i.getLower()) << " … " << getValue(i.getUpper()) << std::endl;
217  }

Member Data Documentation

◆ dimension1

template<typename R , typename D >
const int inet::math::BilinearFunction< R, D >::dimension1
protected

◆ dimension2

template<typename R , typename D >
const int inet::math::BilinearFunction< R, D >::dimension2
protected

◆ lowerLower

template<typename R , typename D >
const D::P inet::math::BilinearFunction< R, D >::lowerLower
protected

◆ lowerUpper

template<typename R , typename D >
const D::P inet::math::BilinearFunction< R, D >::lowerUpper
protected

◆ rLowerLower

template<typename R , typename D >
const R inet::math::BilinearFunction< R, D >::rLowerLower
protected

◆ rLowerUpper

template<typename R , typename D >
const R inet::math::BilinearFunction< R, D >::rLowerUpper
protected

◆ rUpperLower

template<typename R , typename D >
const R inet::math::BilinearFunction< R, D >::rUpperLower
protected

◆ rUpperUpper

template<typename R , typename D >
const R inet::math::BilinearFunction< R, D >::rUpperUpper
protected

◆ upperLower

template<typename R , typename D >
const D::P inet::math::BilinearFunction< R, D >::upperLower
protected

◆ upperUpper

template<typename R , typename D >
const D::P inet::math::BilinearFunction< R, D >::upperUpper
protected

The documentation for this class was generated from the following file:
inet::math::BilinearFunction::dimension1
const int dimension1
Definition: PrimitiveFunctions.h:135
inet::math::BilinearFunction::dimension2
const int dimension2
Definition: PrimitiveFunctions.h:136
inet::math::toDouble
double toDouble(const T v)
Definition: Point.h:28
inet::math::BilinearFunction::getOtherInterval
D::I getOtherInterval(const typename D::I &i) const
Definition: PrimitiveFunctions.h:139
inet::math::maxnan
const T maxnan(const T &a, const T &b)
This function properly and symmetrically handles NaNs in contrast with std::max and std::fmax.
Definition: INETMath.h:234
inet::math::BilinearFunction::rUpperLower
const R rUpperLower
Definition: PrimitiveFunctions.h:133
inet::math::BilinearFunction::rLowerUpper
const R rLowerUpper
Definition: PrimitiveFunctions.h:132
inet::math::BilinearFunction::upperLower
const D::P upperLower
Definition: PrimitiveFunctions.h:129
inet::math::BilinearFunction::getValue
virtual R getValue(const typename D::P &p) const override
Returns the value of the function at the given point.
Definition: PrimitiveFunctions.h:175
inet::math::BilinearFunction::lowerUpper
const D::P lowerUpper
Definition: PrimitiveFunctions.h:128
inet::units::constants::R
const value< double, compose< units::J, compose< pow< units::mol, -1 >, pow< units::kg, -1 > > > > R(8.314472)
inet::math::BilinearFunction::lowerLower
const D::P lowerLower
Definition: PrimitiveFunctions.h:127
inet::units::constants::alpha
const value< double, units::unit > alpha(7.2973525376e-3)
inet::math::minnan
const T minnan(const T &a, const T &b)
This function properly and symmetrically handles NaNs in contrast with std::min and std::fmin.
Definition: INETMath.h:216
inet::math::BilinearFunction::upperUpper
const D::P upperUpper
Definition: PrimitiveFunctions.h:130
inet::math::BilinearFunction::rLowerLower
const R rLowerLower
Definition: PrimitiveFunctions.h:131
inet::math::BilinearFunction::rUpperUpper
const R rUpperUpper
Definition: PrimitiveFunctions.h:134