PLaSK library
Loading...
Searching...
No Matches
plask::LateralVec< T > Struct Template Reference

#include <plask/vector/lateral.hpp>

Collaboration diagram for plask::LateralVec< T >:
[legend]

Public Types

typedef T * iterator
 Type of iterator over components.
 
typedef const T * const_iterator
 Type of const iterator over components.
 

Public Member Functions

T & lon ()
 
constexpr const T & tran () const
 
T & tran ()
 
constexpr const T & vert () const
 
 LateralVec ()
 Construct uninitialized vector.
 
template<typename OtherT >
constexpr LateralVec (const LateralVec< OtherT > &p)
 Copy constructor from all other lateral vectors.
 
template<int other_dim, typename OtherT >
PLASK_NO_CONVERSION_WARNING_BEGIN constexpr LateralVec (const Vec< other_dim, OtherT > &p)
 Copy constructor from 2D vectors.
 
PLASK_NO_WARNING_END constexpr LateralVec (T c0, T c1)
 Construct vector with given components.
 
template<typename T0 , typename T1 >
constexpr LateralVec (const std::pair< T0, T1 > &comp)
 Construct vector components given in std::pair.
 
iterator begin ()
 Get begin iterator over components.
 
const_iterator begin () const
 Get begin const iterator over components.
 
iterator end ()
 Get end iterator over components.
 
const_iterator end () const
 Get end const iterator over components.
 
template<typename OtherT >
constexpr bool operator== (const LateralVec< OtherT > &p) const
 Compare two vectors, this and p.
 
template<typename OtherT , typename SuprType >
constexpr bool equals (const LateralVec< OtherT > &p, const SuprType &abs_supremum) const
 Check if two vectors, this and p are almost equal.
 
template<typename OtherT >
constexpr bool equals (const LateralVec< OtherT > &p) const
 Check if two vectors, this and p are almost equal.
 
template<typename OtherT >
constexpr bool operator!= (const LateralVec< OtherT > &p) const
 Compare two vectors, this and p.
 
T & operator[] (size_t i)
 Get i-th component WARNING This function does not check if it is valid (for efficiency reasons)
 
const T & operator[] (size_t i) const
 Get i-th component WARNING This function does not check if it is valid (for efficiency reasons)
 
template<typename OtherT >
constexpr auto operator+ (const LateralVec< OtherT > &other) const -> LateralVec< decltype(c0+other.c0)>
 Calculate sum of two vectors, this and other.
 
LateralVec< T > & operator+= (const LateralVec< T > &other)
 Increase coordinates of this vector by coordinates of other vector other.
 
template<typename OtherT >
constexpr auto operator- (const LateralVec< OtherT > &other) const -> LateralVec< decltype(c0 - other.c0)>
 Calculate difference of two vectors, this and other.
 
LateralVec< T > & operator-= (const LateralVec< T > &other)
 Decrease coordinates of this vector by coordinates of other vector other.
 
template<typename OtherT >
constexpr auto operator* (const OtherT scale) const -> LateralVec< decltype(c0 *scale)>
 Calculate this vector multiplied by scalar scale.
 
LateralVec< T > & operator*= (const T scalar)
 Multiple coordinates of this vector by scalar.
 
constexpr LateralVec< T > operator/ (const T scale) const
 Calculate this vector divided by scalar scale.
 
LateralVec< T > & operator/= (const T scalar)
 Divide coordinates of this vector by scalar.
 
constexpr LateralVec< T > operator- () const
 Calculate vector opposite to this.
 
LateralVec< T > sqr () const
 Square each component of tensor.
 
LateralVec< T > & sqr_inplace ()
 Square each component of tensor in place.
 
template<typename OtherT >
LateralVec< T > pow (OtherT a) const
 Power of each component of tensor.
 
void flip (size_t i)
 Change i-th coordinate to oposite.
 
LateralVec< T > flipped (size_t i)
 Get vector similar to this but with changed i-th component to oposite.
 
template<class OT >
bool operator< (LateralVec< OT > const &v) const
 A lexical comparison of two vectors, allow to use vector in std::set and std::map as key type.
 

Static Public Member Functions

template<typename InputIteratorType >
static LateralVec< T > fromIterator (InputIteratorType inputIt)
 Construct vector with components read from input iterator (including C array).
 

Public Attributes

c0
 
c1
 

Static Public Attributes

static const int DIMS = 2
 

Friends

std::ostream & operator<< (std::ostream &out, const LateralVec< T > &to_print)
 Print vector to stream using format (where c0 and c1 are vector components): [c0, c1].
 

Detailed Description

template<typename T>
struct plask::LateralVec< T >

Definition at line 23 of file lateral.hpp.

Member Typedef Documentation

◆ const_iterator

template<typename T >
typedef const T* plask::LateralVec< T >::const_iterator

Type of const iterator over components.

Definition at line 43 of file lateral.hpp.

◆ iterator

template<typename T >
typedef T* plask::LateralVec< T >::iterator

Type of iterator over components.

Definition at line 38 of file lateral.hpp.

Constructor & Destructor Documentation

◆ LateralVec() [1/5]

template<typename T >
plask::LateralVec< T >::LateralVec ( )
inline

Construct uninitialized vector.

Definition at line 46 of file lateral.hpp.

◆ LateralVec() [2/5]

template<typename T >
template<typename OtherT >
constexpr plask::LateralVec< T >::LateralVec ( const LateralVec< OtherT > &  p)
inlineconstexpr

Copy constructor from all other lateral vectors.

Parameters
pvector to copy from

Definition at line 53 of file lateral.hpp.

◆ LateralVec() [3/5]

template<typename T >
template<int other_dim, typename OtherT >
PLASK_NO_CONVERSION_WARNING_BEGIN constexpr plask::LateralVec< T >::LateralVec ( const Vec< other_dim, OtherT > &  p)
inlineconstexpr

Copy constructor from 2D vectors.

Parameters
pvector to copy from

Definition at line 61 of file lateral.hpp.

◆ LateralVec() [4/5]

template<typename T >
PLASK_NO_WARNING_END constexpr plask::LateralVec< T >::LateralVec ( c0,
c1 
)
inlineconstexpr

Construct vector with given components.

Parameters
c0,c1components

Definition at line 68 of file lateral.hpp.

◆ LateralVec() [5/5]

template<typename T >
template<typename T0 , typename T1 >
constexpr plask::LateralVec< T >::LateralVec ( const std::pair< T0, T1 > &  comp)
inlineconstexpr

Construct vector components given in std::pair.

Parameters
compcomponents

Definition at line 75 of file lateral.hpp.

Member Function Documentation

◆ begin() [1/2]

template<typename T >
iterator plask::LateralVec< T >::begin ( )
inline

Get begin iterator over components.

Returns
begin iterator over components

Definition at line 94 of file lateral.hpp.

◆ begin() [2/2]

template<typename T >
const_iterator plask::LateralVec< T >::begin ( ) const
inline

Get begin const iterator over components.

Returns
begin const iterator over components

Definition at line 100 of file lateral.hpp.

◆ end() [1/2]

template<typename T >
iterator plask::LateralVec< T >::end ( )
inline

Get end iterator over components.

Returns
end iterator over components

Definition at line 106 of file lateral.hpp.

◆ end() [2/2]

template<typename T >
const_iterator plask::LateralVec< T >::end ( ) const
inline

Get end const iterator over components.

Returns
end const iterator over components

Definition at line 112 of file lateral.hpp.

◆ equals() [1/2]

template<typename T >
template<typename OtherT >
constexpr bool plask::LateralVec< T >::equals ( const LateralVec< OtherT > &  p) const
inlineconstexpr

Check if two vectors, this and p are almost equal.

Parameters
pvector to compare
Returns
true only if this vector and p have almost equals coordinates

Definition at line 138 of file lateral.hpp.

◆ equals() [2/2]

template<typename T >
constexpr bool plask::LateralVec< T >::equals ( const LateralVec< OtherT > &  p,
const SuprType abs_supremum 
) const
inlineconstexpr

Check if two vectors, this and p are almost equal.

Parameters
pvector to compare
abs_supremummaximal allowed difference for one coordinate
Returns
true only if this vector and p have almost equals coordinates

Definition at line 129 of file lateral.hpp.

◆ flip()

template<typename T >
void plask::LateralVec< T >::flip ( size_t  i)
inline

Change i-th coordinate to oposite.

WARNING This function does not check if it is valid (for efficiency reasons)

Parameters
inumber of coordinate

Definition at line 293 of file lateral.hpp.

◆ flipped()

template<typename T >
LateralVec< T > plask::LateralVec< T >::flipped ( size_t  i)
inline

Get vector similar to this but with changed i-th component to oposite.

WARNING This function does not check if it is valid (for efficiency reasons)

Parameters
inumber of coordinate
Returns
vector similar to this but with changed i-th component to oposite

Definition at line 304 of file lateral.hpp.

◆ fromIterator()

template<typename T >
static LateralVec< T > plask::LateralVec< T >::fromIterator ( InputIteratorType  inputIt)
inlinestatic

Construct vector with components read from input iterator (including C array).

Parameters
inputItinput iterator with minimum 3 objects available
Template Parameters
InputIteratorTypeinput iterator type, must allow for postincrementation and dereference operation

Definition at line 83 of file lateral.hpp.

◆ lon()

template<typename T >
T & plask::LateralVec< T >::lon ( )
inline

Definition at line 29 of file lateral.hpp.

◆ operator!=()

template<typename T >
template<typename OtherT >
constexpr bool plask::LateralVec< T >::operator!= ( const LateralVec< OtherT > &  p) const
inlineconstexpr

Compare two vectors, this and p.

Parameters
pvector to compare
Returns
true only if this vector and p don't have equals coordinates

Definition at line 147 of file lateral.hpp.

◆ operator*()

template<typename T >
template<typename OtherT >
constexpr auto plask::LateralVec< T >::operator* ( const OtherT  scale) const -> LateralVec<decltype(c0*scale)>
inlineconstexpr

Calculate this vector multiplied by scalar scale.

Parameters
scalescalar
Returns
this vector multiplied by scalar

Definition at line 219 of file lateral.hpp.

◆ operator*=()

template<typename T >
LateralVec< T > & plask::LateralVec< T >::operator*= ( const scalar)
inline

Multiple coordinates of this vector by scalar.

Parameters
scalarscalar
Returns
*this (after scale)

Definition at line 230 of file lateral.hpp.

◆ operator+()

template<typename T >
template<typename OtherT >
constexpr auto plask::LateralVec< T >::operator+ ( const LateralVec< OtherT > &  other) const -> LateralVec<decltype(c0 + other.c0)>
inlineconstexpr

Calculate sum of two vectors, this and other.

Parameters
othervector to add, can have different data type (than result type will be found using C++ types promotions rules)
Returns
vectors sum

Definition at line 177 of file lateral.hpp.

◆ operator+=()

template<typename T >
LateralVec< T > & plask::LateralVec< T >::operator+= ( const LateralVec< T > &  other)
inline

Increase coordinates of this vector by coordinates of other vector other.

Parameters
othervector to add
Returns
*this (after increase)

Definition at line 186 of file lateral.hpp.

◆ operator-() [1/2]

template<typename T >
constexpr LateralVec< T > plask::LateralVec< T >::operator- ( ) const
inlineconstexpr

Calculate vector opposite to this.

Returns
LateralVec<T>(-c0, -c1)

Definition at line 258 of file lateral.hpp.

◆ operator-() [2/2]

template<typename T >
template<typename OtherT >
constexpr auto plask::LateralVec< T >::operator- ( const LateralVec< OtherT > &  other) const -> LateralVec<decltype(c0 - other.c0)>
inlineconstexpr

Calculate difference of two vectors, this and other.

Parameters
othervector to subtract from this, can have different data type (than result type will be found using C++ types promotions rules)
Returns
vectors difference

Definition at line 198 of file lateral.hpp.

◆ operator-=()

template<typename T >
LateralVec< T > & plask::LateralVec< T >::operator-= ( const LateralVec< T > &  other)
inline

Decrease coordinates of this vector by coordinates of other vector other.

Parameters
othervector to subtract
Returns
*this (after decrease)

Definition at line 207 of file lateral.hpp.

◆ operator/()

template<typename T >
constexpr LateralVec< T > plask::LateralVec< T >::operator/ ( const scale) const
inlineconstexpr

Calculate this vector divided by scalar scale.

Parameters
scalescalar
Returns
this vector divided by scalar

Definition at line 241 of file lateral.hpp.

◆ operator/=()

template<typename T >
LateralVec< T > & plask::LateralVec< T >::operator/= ( const scalar)
inline

Divide coordinates of this vector by scalar.

Parameters
scalarscalar
Returns
*this (after divide)

Definition at line 248 of file lateral.hpp.

◆ operator<()

template<typename T >
template<class OT >
bool plask::LateralVec< T >::operator< ( LateralVec< OT > const v) const
inline

A lexical comparison of two vectors, allow to use vector in std::set and std::map as key type.

It supports NaN-s (which, due to this method, is greater than all other numbers).

Parameters
vvectors to compare
Returns
true only if this is smaller than the v

Definition at line 328 of file lateral.hpp.

◆ operator==()

template<typename T >
template<typename OtherT >
constexpr bool plask::LateralVec< T >::operator== ( const LateralVec< OtherT > &  p) const
inlineconstexpr

Compare two vectors, this and p.

Parameters
pvector to compare
Returns
true only if this vector and p have equals coordinates

Definition at line 120 of file lateral.hpp.

◆ operator[]() [1/2]

template<typename T >
T & plask::LateralVec< T >::operator[] ( size_t  i)
inline

Get i-th component WARNING This function does not check if it is valid (for efficiency reasons)

Parameters
inumber of coordinate
Returns
i-th component

Definition at line 155 of file lateral.hpp.

◆ operator[]() [2/2]

template<typename T >
const T & plask::LateralVec< T >::operator[] ( size_t  i) const
inline

Get i-th component WARNING This function does not check if it is valid (for efficiency reasons)

Parameters
inumber of coordinate
Returns
i-th component

Definition at line 166 of file lateral.hpp.

◆ pow()

template<typename T >
template<typename OtherT >
LateralVec< T > plask::LateralVec< T >::pow ( OtherT  a) const
inline

Power of each component of tensor.

Returns
squared tensor

Definition at line 284 of file lateral.hpp.

◆ sqr()

template<typename T >
LateralVec< T > plask::LateralVec< T >::sqr ( ) const
inline

Square each component of tensor.

Returns
squared tensor

Definition at line 266 of file lateral.hpp.

◆ sqr_inplace()

template<typename T >
LateralVec< T > & plask::LateralVec< T >::sqr_inplace ( )
inline

Square each component of tensor in place.

Returns
*this (squared)

Definition at line 274 of file lateral.hpp.

◆ tran() [1/2]

template<typename T >
T & plask::LateralVec< T >::tran ( )
inline

Definition at line 32 of file lateral.hpp.

◆ tran() [2/2]

template<typename T >
constexpr const T & plask::LateralVec< T >::tran ( ) const
inlineconstexpr

Definition at line 30 of file lateral.hpp.

◆ vert()

template<typename T >
constexpr const T & plask::LateralVec< T >::vert ( ) const
inlineconstexpr

Definition at line 33 of file lateral.hpp.

Friends And Related Symbol Documentation

◆ operator<<

template<typename T >
std::ostream & operator<< ( std::ostream &  out,
const LateralVec< T > &  to_print 
)
friend

Print vector to stream using format (where c0 and c1 are vector components): [c0, c1].

Parameters
outprint destination, output stream
to_printvector to print
Returns
out stream

Definition at line 316 of file lateral.hpp.

Member Data Documentation

◆ c0

template<typename T >
T plask::LateralVec< T >::c0

Definition at line 27 of file lateral.hpp.

◆ c1

template<typename T >
T plask::LateralVec< T >::c1

Definition at line 27 of file lateral.hpp.

◆ DIMS

template<typename T >
const int plask::LateralVec< T >::DIMS = 2
static

Definition at line 25 of file lateral.hpp.


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