Hermes
hermes::Index2< T > Struct Template Reference

Holds 2-dimensional integer index coordinates. More...

Public Member Functions

HERMES_DEVICE_CALLABLE Index2< T > operator- () const
 
HERMES_DEVICE_CALLABLE Index2 ()
 Default constructor.
 
HERMES_DEVICE_CALLABLE Index2 (T v)
 Constructor. More...
 
HERMES_DEVICE_CALLABLE Index2 (T i, T j)
 Constructor. More...
 
template<typename S >
HERMES_DEVICE_CALLABLE Index2 (const Size2< S > &size)
 Constructor from a Size2 object. More...
 
HERMES_DEVICE_CALLABLEoperator[] (int d) const
 
HERMES_DEVICE_CALLABLE T & operator[] (int d)
 
HERMES_DEVICE_CALLABLE Index2< T > plus (T _i, T _j) const
 Generates an index with incremented values. More...
 
HERMES_DEVICE_CALLABLE Index2< T > left (T d=T(1)) const
 Generates a copy with i decremented by d More...
 
HERMES_DEVICE_CALLABLE Index2< T > right (T d=T(1)) const
 Generates a copy with i incremented by d More...
 
HERMES_DEVICE_CALLABLE Index2< T > down (T d=T(1)) const
 Generates a copy with j decremented by d More...
 
HERMES_DEVICE_CALLABLE Index2< T > up (T d=T(1)) const
 Generates a copy with j incremented by d More...
 
HERMES_DEVICE_CALLABLE void clampTo (const size2 &s)
 Clamps to the inclusive range [0, size] More...
 

Public Attributes

i = T(0)
 0-th coordinate value
 
j = T(0)
 1-th coordinate value
 

Friends

HERMES_DEVICE_CALLABLE friend T distance (const Index2< T > &a, const Index2< T > &b)
 Computes the manhattan distance between two indices. More...
 

Detailed Description

template<typename T>
struct hermes::Index2< T >

Holds 2-dimensional integer index coordinates.

  • Usually the field i is related to the x axis in cartesian coordinates, and the field j is related to the y axis.
Template Parameters
Tindex type
Precondition
Index type must be a signed integer type.

Constructor & Destructor Documentation

◆ Index2() [1/3]

template<typename T >
HERMES_DEVICE_CALLABLE hermes::Index2< T >::Index2 ( v)
inlineexplicit

Constructor.

Parameters
v- value assigned to both i and j

◆ Index2() [2/3]

template<typename T >
HERMES_DEVICE_CALLABLE hermes::Index2< T >::Index2 ( i,
j 
)
inline

Constructor.

Parameters
i- coordinate value for i
j- coordinate value for j

◆ Index2() [3/3]

template<typename T >
template<typename S >
HERMES_DEVICE_CALLABLE hermes::Index2< T >::Index2 ( const Size2< S > &  size)
inlineexplicit

Constructor from a Size2 object.

  • i receives size.with and j receives size.height
    Template Parameters
    Ssize type
    Parameters
    size-

Member Function Documentation

◆ clampTo()

template<typename T >
HERMES_DEVICE_CALLABLE void hermes::Index2< T >::clampTo ( const size2 s)
inline

Clamps to the inclusive range [0, size]

Parameters
s- upper bound

◆ down()

template<typename T >
HERMES_DEVICE_CALLABLE Index2<T> hermes::Index2< T >::down ( d = T(1)) const
inline

Generates a copy with j decremented by d

Parameters
d[in | default = 1] decrement value
Returns
Index2<T> resulting index coordinates (i, j-d)

◆ left()

template<typename T >
HERMES_DEVICE_CALLABLE Index2<T> hermes::Index2< T >::left ( d = T(1)) const
inline

Generates a copy with i decremented by d

Parameters
d[in | default = 1] decrement value
Returns
Index2<T> resulting index coordinates (i-d, j)

◆ operator[]() [1/2]

template<typename T >
HERMES_DEVICE_CALLABLE T& hermes::Index2< T >::operator[] ( int  d)
inline
Parameters
dcoordinate index
Precondition
d must be in [0,1]
Warning
the value of d is not checked
Returns

◆ operator[]() [2/2]

template<typename T >
HERMES_DEVICE_CALLABLE T hermes::Index2< T >::operator[] ( int  d) const
inline
Parameters
dcoordinate index
Precondition
d must be in [0,1]
Warning
the value of d is not checked
Returns

◆ plus()

template<typename T >
HERMES_DEVICE_CALLABLE Index2<T> hermes::Index2< T >::plus ( _i,
_j 
) const
inline

Generates an index with incremented values.

Parameters
_i- value incremented to i
_j- value incremented to j
Returns
Index2<T> resulting index coordinates

◆ right()

template<typename T >
HERMES_DEVICE_CALLABLE Index2<T> hermes::Index2< T >::right ( d = T(1)) const
inline

Generates a copy with i incremented by d

Parameters
d[in | default = 1] increment value
Returns
Index2<T> resulting index coordinates (i+d, j)

◆ up()

template<typename T >
HERMES_DEVICE_CALLABLE Index2<T> hermes::Index2< T >::up ( d = T(1)) const
inline

Generates a copy with j incremented by d

Parameters
d[in | default = 1] increment value
Returns
Index2<T> resulting index coordinates (i, j+d)

Friends And Related Function Documentation

◆ distance

template<typename T >
HERMES_DEVICE_CALLABLE friend T distance ( const Index2< T > &  a,
const Index2< T > &  b 
)
friend

Computes the manhattan distance between two indices.

\(\sum_i |a_i - b_i| \)

Template Parameters
T
Parameters
a-
b-
Returns
T

The documentation for this struct was generated from the following file: