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

One-dimensional periodic function with a sawtooth shape. More...

#include <PrimitiveFunctions.h>

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

Public Member Functions

 SawtoothFunction (X start, X end, X period, R value)
 
virtual R getValue (const Point< X > &p) const override
 
- 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...
 
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, 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 start
 
const X end
 
const X period
 
const R value
 

Detailed Description

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

One-dimensional periodic function with a sawtooth shape.

Constructor & Destructor Documentation

◆ SawtoothFunction()

template<typename R , typename X >
inet::math::SawtoothFunction< R, X >::SawtoothFunction ( start,
end,
period,
value 
)
inline
497  :
499  {}

Member Function Documentation

◆ getValue()

template<typename R , typename X >
virtual R inet::math::SawtoothFunction< R, X >::getValue ( const Point< X > &  p) const
inlineoverridevirtual
501  {
502  auto x = std::get<0>(p);
503  if (x < start)
504  return R(0);
505  else if (x > end)
506  return R(0);
507  else
508  return value * fmod(toDouble(x - start) / toDouble(period), 1);
509  }

Member Data Documentation

◆ end

template<typename R , typename X >
const X inet::math::SawtoothFunction< R, X >::end
protected

◆ period

template<typename R , typename X >
const X inet::math::SawtoothFunction< R, X >::period
protected

◆ start

template<typename R , typename X >
const X inet::math::SawtoothFunction< R, X >::start
protected

◆ value

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

The documentation for this class was generated from the following file:
inet::math::SawtoothFunction::start
const X start
Definition: PrimitiveFunctions.h:491
inet::math::SawtoothFunction::period
const X period
Definition: PrimitiveFunctions.h:493
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)
inet::math::SawtoothFunction::value
const R value
Definition: PrimitiveFunctions.h:494
inet::math::SawtoothFunction::end
const X end
Definition: PrimitiveFunctions.h:492