INET Framework for OMNeT++/OMNEST
inet::math::Point< T > Class Template Reference

N-dimensional point. More...

#include <Point.h>

Inheritance diagram for inet::math::Point< T >:

Public Types

typedef std::tuple< T ... > type
 

Public Member Functions

 Point (T ... t)
 
double get (int index) const
 
void set (int index, double value)
 
Point< T ... > operator- () const
 
Point< T ... > operator+ (const Point< T ... > &o) const
 
Point< T ... > operator- (const Point< T ... > &o) const
 
Point< T ... > operator* (double d) const
 
Point< T ... > operator/ (double d) const
 
template<typename P , int DIMS>
void copyTo (P &p) const
 Copy the dimensions selected by the 1 bits of DIMS into p. More...
 
template<typename P , int DIMS>
void copyFrom (const P &p)
 Copy the coordinates selected by the 1 bits of DIMS from p. More...
 
template<typename X , int DIMENSION>
Point< T ... > getReplaced (X x) const
 
std::string str () const
 

Static Public Member Functions

static Point< T ... > getZero ()
 
static Point< T ... > getLowerBounds ()
 
static Point< T ... > getUpperBounds ()
 

Protected Member Functions

template<size_t ... IS>
double getImpl (int index, std::integer_sequence< size_t, IS... >) const
 
template<size_t ... IS>
void setImpl (int index, double value, std::integer_sequence< size_t, IS... >)
 
template<size_t ... IS>
Point< T ... > add (const Point< T ... > &o, std::integer_sequence< size_t, IS ... >) const
 
template<size_t ... IS>
Point< T ... > subtract (const Point< T ... > &o, std::integer_sequence< size_t, IS ... >) const
 
template<size_t ... IS>
Point< T ... > multiply (double d, std::integer_sequence< size_t, IS ... >) const
 
template<size_t ... IS>
Point< T ... > divide (double d, std::integer_sequence< size_t, IS ... >) const
 

Detailed Description

template<typename... T>
class inet::math::Point< T >

N-dimensional point.

Supports algebraic operations.

Member Typedef Documentation

◆ type

template<typename... T>
typedef std::tuple<T ...> inet::math::Point< T >::type

Constructor & Destructor Documentation

◆ Point()

template<typename... T>
inet::math::Point< T >::Point ( T ...  t)
inline
132 : std::tuple<T ...>(t...) {}

Member Function Documentation

◆ add()

template<typename... T>
template<size_t ... IS>
Point<T ...> inet::math::Point< T >::add ( const Point< T ... > &  o,
std::integer_sequence< size_t, IS ... >   
) const
inlineprotected
112  {
113  return Point<T ...>{ (std::get<IS>(*this) + std::get<IS>(o)) ... };
114  }

◆ copyFrom()

template<typename... T>
template<typename P , int DIMS>
void inet::math::Point< T >::copyFrom ( const P &  p)
inline

Copy the coordinates selected by the 1 bits of DIMS from p.

170  {
171  internal::copyTupleElements(p, internal::make_bits_to_indices_sequence<DIMS, std::tuple_size<typename P::type>::value>{}, *this, std::index_sequence_for<T ...>{});
172  }

◆ copyTo()

template<typename... T>
template<typename P , int DIMS>
void inet::math::Point< T >::copyTo ( P &  p) const
inline

Copy the dimensions selected by the 1 bits of DIMS into p.

164  {
165  internal::copyTupleElements(*this, std::index_sequence_for<T ...>{}, p, internal::make_bits_to_indices_sequence<DIMS, std::tuple_size<typename P::type>::value>{});
166  }

◆ divide()

template<typename... T>
template<size_t ... IS>
Point<T ...> inet::math::Point< T >::divide ( double  d,
std::integer_sequence< size_t, IS ... >   
) const
inlineprotected
127  {
128  return Point<T ...>{ (std::get<IS>(*this) / d) ... };
129  }

◆ get()

template<typename... T>
double inet::math::Point< T >::get ( int  index) const
inline
134  {
135  return getImpl(index, std::index_sequence_for<T ...>{});
136  }

◆ getImpl()

template<typename... T>
template<size_t ... IS>
double inet::math::Point< T >::getImpl ( int  index,
std::integer_sequence< size_t, IS... >   
) const
inlineprotected
100  {
101  double result = 0;
102  (void)std::initializer_list<double>{ result = (IS == index ? toDouble(std::get<IS>(*this)) : result) ... };
103  return result;
104  }

◆ getLowerBounds()

template<typename... T>
static Point<T ...> inet::math::Point< T >::getLowerBounds ( )
inlinestatic
191  {
192  return Point<T ...>{ (getLowerBound<T>()) ... };
193  }

◆ getReplaced()

template<typename... T>
template<typename X , int DIMENSION>
Point<T ...> inet::math::Point< T >::getReplaced ( x) const
inline
175  {
176  Point<T ...> p = *this;
177  std::get<DIMENSION>(p) = x;
178  return p;
179  }

◆ getUpperBounds()

template<typename... T>
static Point<T ...> inet::math::Point< T >::getUpperBounds ( )
inlinestatic
195  {
196  return Point<T ...>{ (getUpperBound<T>()) ... };
197  }

◆ getZero()

template<typename... T>
static Point<T ...> inet::math::Point< T >::getZero ( )
inlinestatic
187  {
188  return Point<T ...>{ T(0) ... };
189  }

◆ multiply()

template<typename... T>
template<size_t ... IS>
Point<T ...> inet::math::Point< T >::multiply ( double  d,
std::integer_sequence< size_t, IS ... >   
) const
inlineprotected
122  {
123  return Point<T ...>{ (std::get<IS>(*this) * d) ... };
124  }

◆ operator*()

template<typename... T>
Point<T ...> inet::math::Point< T >::operator* ( double  d) const
inline
154  {
155  return multiply(d, std::index_sequence_for<T ...>{});
156  }

◆ operator+()

template<typename... T>
Point<T ...> inet::math::Point< T >::operator+ ( const Point< T ... > &  o) const
inline
146  {
147  return add(o, std::index_sequence_for<T ...>{});
148  }

◆ operator-() [1/2]

template<typename... T>
Point<T ...> inet::math::Point< T >::operator- ( ) const
inline
142  {
143  return multiply(-1, std::index_sequence_for<T ...>{});
144  }

◆ operator-() [2/2]

template<typename... T>
Point<T ...> inet::math::Point< T >::operator- ( const Point< T ... > &  o) const
inline
150  {
151  return subtract(o, std::index_sequence_for<T ...>{});
152  }

◆ operator/()

template<typename... T>
Point<T ...> inet::math::Point< T >::operator/ ( double  d) const
inline
158  {
159  return divide(d, std::index_sequence_for<T ...>{});
160  }

◆ set()

template<typename... T>
void inet::math::Point< T >::set ( int  index,
double  value 
)
inline
138  {
139  return setImpl(index, value, std::index_sequence_for<T ...>{});
140  }

◆ setImpl()

template<typename... T>
template<size_t ... IS>
void inet::math::Point< T >::setImpl ( int  index,
double  value,
std::integer_sequence< size_t, IS... >   
)
inlineprotected
107  {
108  (void)std::initializer_list<double>{ (IS == index ? toDouble(std::get<IS>(*this) = T(value)) : 0) ... };
109  }

◆ str()

template<typename... T>
std::string inet::math::Point< T >::str ( ) const
inline
181  {
182  std::stringstream os;
183  os << *this;
184  return os.str();
185  }

◆ subtract()

template<typename... T>
template<size_t ... IS>
Point<T ...> inet::math::Point< T >::subtract ( const Point< T ... > &  o,
std::integer_sequence< size_t, IS ... >   
) const
inlineprotected
117  {
118  return Point<T ...>{ (std::get<IS>(*this) - std::get<IS>(o)) ... };
119  }

The documentation for this class was generated from the following file:
inet::units::units::T
compose< Wb, pow< m, -2 > > T
Definition: Units.h:951
inet::math::Point::subtract
Point< T ... > subtract(const Point< T ... > &o, std::integer_sequence< size_t, IS ... >) const
Definition: Point.h:117
inet::math::Point::add
Point< T ... > add(const Point< T ... > &o, std::integer_sequence< size_t, IS ... >) const
Definition: Point.h:112
inet::math::toDouble
double toDouble(const T v)
Definition: Point.h:28
inet::math::internal::copyTupleElements
void copyTupleElements(const S &source, std::integer_sequence< size_t, SIS ... >, D &destination, std::integer_sequence< size_t, DIS ... >)
Definition: Point.h:83
inet::math::internal::make_bits_to_indices_sequence
typename bits_to_indices_sequence< DIMS, SIZE >::type make_bits_to_indices_sequence
Definition: Point.h:80
inet::math::Point::Point
Point(T ... t)
Definition: Point.h:132
inet::math::Point::divide
Point< T ... > divide(double d, std::integer_sequence< size_t, IS ... >) const
Definition: Point.h:127
inet::math::Point::setImpl
void setImpl(int index, double value, std::integer_sequence< size_t, IS... >)
Definition: Point.h:107
inet::math::Point::getImpl
double getImpl(int index, std::integer_sequence< size_t, IS... >) const
Definition: Point.h:100
inet::math::Point::multiply
Point< T ... > multiply(double d, std::integer_sequence< size_t, IS ... >) const
Definition: Point.h:122