PLaSK library

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
plask::Vec< 2, T > Struct Template Reference

Vector in 2D space. More...

`#include <plask/vector/2d.hpp>`

Collaboration diagram for plask::Vec< 2, 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 & | tran ()
constexpr const T & | tran () const
T & | vert ()
constexpr const T & | vert () const
T & | rad_r ()
constexpr const T & | rad_r () const
T & | rad_z ()
constexpr const T & | rad_z () const
T & | se_y ()
constexpr const T & | se_y () const
T & | se_z ()
constexpr const T & | se_z () const
T & | zup_y ()
constexpr const T & | z_up_y () const
T & | zup_z ()
constexpr const T & | z_up_z () const
T & | ee_x ()
constexpr const T & | ee_x () const
T & | ee_y ()
constexpr const T & | ee_y () const
T & | yup_x ()
constexpr const T & | y_up_x () const
T & | yup_y ()
constexpr const T & | y_up_y () const
| Vec ()
| Construct uninitialized vector.
template<typename OtherT >
constexpr | Vec (const Vec< 2, OtherT > &p)
| Copy constructor from all other 2D vectors.
constexpr | Vec (const T &c0__tran, const T &c1__up)
| Construct vector with given components.
template<typename T0 , typename T1 >
constexpr | Vec (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 Vec< 2, OtherT > &p) const
| Compare two vectors, this and `p`.
template<typename OtherT , typename SuprType >
constexpr bool | equals (const Vec< 2, OtherT > &p, const SuprType &abs_supremum) const
| Check if two vectors, this and `p` are almost equal.
template<typename OtherT >
constexpr bool | equals (const Vec< 2, OtherT > &p) const
| Check if two vectors, this and `p` are almost equal.
template<typename OtherT >
constexpr bool | operator!= (const Vec< 2, 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 Vec< 2, OtherT > &other) const -> Vec< 2, decltype(c0+other.c0)>
| Calculate sum of two vectors, `this` and `other`.
Vec< 2, T > & | operator+= (const Vec< 2, T > &other)
| Increase coordinates of this vector by coordinates of other vector `other`.
template<typename OtherT >
constexpr auto | operator- (const Vec< 2, OtherT > &other) const -> Vec< 2, decltype(c0 - other.c0)>
| Calculate difference of two vectors, `this` and `other`.
Vec< 2, T > & | operator-= (const Vec< 2, T > &other)
| Decrease coordinates of this vector by coordinates of other vector `other`.
template<typename OtherT >
constexpr auto | operator* (const OtherT scale) const -> Vec< 2, decltype(c0 *scale)>
| Calculate this vector multiplied by scalar `scale`.
Vec< 2, T > & | operator*= (const T scalar)
| Multiple coordinates of this vector by `scalar`.
template<typename OtherT >
constexpr auto | operator/ (const OtherT scale) const -> Vec< 2, decltype(c0/scale)>
| Calculate this vector divided by scalar `scale`.
Vec< 2, T > & | operator/= (const T scalar)
| Divide coordinates of this vector by `scalar`.
constexpr Vec< 2, T > | operator- () const
| Calculate vector opposite to this.
Vec< 2, T > | sqr () const
| Square each component of tensor.
Vec< 2, T > & | sqr_inplace ()
| Square each component of tensor in place.
Vec< 2, T > | sqrt () const
| Square root of each component of tensor.
Vec< 2, T > & | sqrt_inplace ()
| Square root of each component of tensor in place.
template<typename OtherT >
Vec< 2, T > | pow (OtherT a) const
| Power of each component of tensor.
void | flip (size_t i)
| Change i-th coordinate to oposite.
Vec< 2, T > | flipped (size_t i)
| Get vector similar to this but with changed i-th component to oposite.
template<class OT >
bool | operator< (Vec< 2, 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 Vec< 2, T > | fromIterator (InputIteratorType inputIt)
| Construct vector with components read from input iterator (including C array).

## Public Attributes
T | c0
T | c1

## Static Public Attributes
static const int | DIMS = 2

## Friends
std::ostream & | operator<< (std::ostream &out, const Vec< 2, 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::Vec< 2, T >

Vector in 2D space.

Definition at line 37 of file 2d.hpp.

## Member Typedef Documentation

## ◆ const_iterator

template<typename T >

typedef const T* plask::Vec< 2, T >::const_iterator

Type of const iterator over components.

Definition at line 86 of file 2d.hpp.

## ◆ iterator

template<typename T >

typedef T* plask::Vec< 2, T >::iterator

Type of iterator over components.

Definition at line 81 of file 2d.hpp.

## Constructor & Destructor Documentation

## ◆ Vec() [1/4]

template<typename T >

plask::Vec< 2, T >::Vec | ( |  | ) |
| inline

Construct uninitialized vector.

Definition at line 89 of file 2d.hpp.

## ◆ Vec() [2/4]

template<typename T >
template<typename OtherT >

constexpr plask::Vec< 2, T >::Vec | ( | const Vec< 2, OtherT > & | p | ) |
| inline constexpr

Copy constructor from all other 2D vectors.

Parameters

  p | vector to copy from

Definition at line 95 of file 2d.hpp.

## ◆ Vec() [3/4]

template<typename T >

constexpr plask::Vec< 2, T >::Vec | ( | const T & | c0__tran,
|  | const T & | c1__up
| ) |  |
| inline constexpr

Construct vector with given components.

Parameters

  c0__tran,c1__up | components

Definition at line 101 of file 2d.hpp.

## ◆ Vec() [4/4]

template<typename T >
template<typename T0 , typename T1 >

constexpr plask::Vec< 2, T >::Vec | ( | const std::pair< T0, T1 > & | comp | ) |
| inline constexpr

Construct vector components given in std::pair.

Parameters

  comp | components

Definition at line 107 of file 2d.hpp.

## Member Function Documentation

## ◆ begin() [1/2]

template<typename T >

iterator plask::Vec< 2, T >::begin | ( |  | ) |
| inline

Get begin iterator over components.

Returns
  begin iterator over components

Definition at line 125 of file 2d.hpp.

## ◆ begin() [2/2]

template<typename T >

const_iterator plask::Vec< 2, T >::begin | ( |  | ) | const
| inline

Get begin const iterator over components.

Returns
  begin const iterator over components

Definition at line 131 of file 2d.hpp.

## ◆ ee_x() [1/2]

template<typename T >

T & plask::Vec< 2, T >::ee_x | ( |  | ) |
| inline

Definition at line 67 of file 2d.hpp.

## ◆ ee_x() [2/2]

template<typename T >

constexpr const T & plask::Vec< 2, T >::ee_x | ( |  | ) | const
| inline constexpr

Definition at line 68 of file 2d.hpp.

## ◆ ee_y() [1/2]

template<typename T >

T & plask::Vec< 2, T >::ee_y | ( |  | ) |
| inline

Definition at line 69 of file 2d.hpp.

## ◆ ee_y() [2/2]

template<typename T >

constexpr const T & plask::Vec< 2, T >::ee_y | ( |  | ) | const
| inline constexpr

Definition at line 70 of file 2d.hpp.

## ◆ end() [1/2]

template<typename T >

iterator plask::Vec< 2, T >::end | ( |  | ) |
| inline

Get end iterator over components.

Returns
  end iterator over components

Definition at line 137 of file 2d.hpp.

## ◆ end() [2/2]

template<typename T >

const_iterator plask::Vec< 2, T >::end | ( |  | ) | const
| inline

Get end const iterator over components.

Returns
  end const iterator over components

Definition at line 143 of file 2d.hpp.

## ◆ equals() [1/2]

template<typename T >
template<typename OtherT >

constexpr bool plask::Vec< 2, T >::equals | ( | const Vec< 2, OtherT > & | p | ) | const
| inline constexpr

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

Parameters

  p | vector to compare

Returns
  `true` only if this vector and `p` have almost equals coordinates

Definition at line 168 of file 2d.hpp.

## ◆ equals() [2/2]

template<typename T >
template<typename OtherT , typename SuprType >

constexpr bool plask::Vec< 2, T >::equals | ( | const Vec< 2, OtherT > & | p,
|  | const SuprType & | abs_supremum
| ) |  | const
| inline constexpr

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

Parameters

  p | vector to compare
  abs_supremum | maximal allowed difference for one coordinate

Returns
  `true` only if this vector and `p` have almost equals coordinates

Definition at line 159 of file 2d.hpp.

## ◆ flip()

template<typename T >

void plask::Vec< 2, 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

  i | number of coordinate

Definition at line 339 of file 2d.hpp.

## ◆ flipped()

template<typename T >

Vec< 2, T > plask::Vec< 2, 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

  i | number of coordinate

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

Definition at line 350 of file 2d.hpp.

## ◆ fromIterator()

template<typename T >
template<typename InputIteratorType >

static Vec< 2, T > plask::Vec< 2, T >::fromIterator | ( | InputIteratorType | inputIt | ) |
| inline static

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

Parameters

  inputIt | input iterator with minimum 3 objects available

Template Parameters

  InputIteratorType | input iterator type, must allow for postincrementation and dereference operation

Definition at line 114 of file 2d.hpp.

## ◆ operator!=()

template<typename T >
template<typename OtherT >

constexpr bool plask::Vec< 2, T >::operator!= | ( | const Vec< 2, OtherT > & | p | ) | const
| inline constexpr

Compare two vectors, this and `p`.

Parameters

  p | vector to compare

Returns
  true only if this vector and `p` don't have equals coordinates

Definition at line 177 of file 2d.hpp.

## ◆ operator*()

template<typename T >
template<typename OtherT >

constexpr auto plask::Vec< 2, T >::operator* | ( | const OtherT | scale | ) | const -> Vec<2, decltype(c0 * scale)>
| inline constexpr

Calculate this vector multiplied by scalar `scale`.

Parameters

  scale | scalar

Returns
  this vector multiplied by scalar

Definition at line 247 of file 2d.hpp.

## ◆ operator*=()

template<typename T >

Vec< 2, T > & plask::Vec< 2, T >::operator*= | ( | const T | scalar | ) |
| inline

Multiple coordinates of this vector by `scalar`.

Parameters

  scalar | scalar

Returns
  *this (after scale)

Definition at line 258 of file 2d.hpp.

## ◆ operator+()

template<typename T >
template<typename OtherT >

constexpr auto plask::Vec< 2, T >::operator+ | ( | const Vec< 2, OtherT > & | other | ) | const -> Vec<2, decltype(c0 + other.c0)>
| inline constexpr

Calculate sum of two vectors, `this` and `other`.

Parameters

  other | vector to add, can have different data type (than result type will be found using C++ types promotions rules)

Returns
  vectors sum

Definition at line 206 of file 2d.hpp.

## ◆ operator+=()

template<typename T >

Vec< 2, T > & plask::Vec< 2, T >::operator+= | ( | const Vec< 2, T > & | other | ) |
| inline

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

Parameters

  other | vector to add

Returns
  *this (after increase)

Definition at line 215 of file 2d.hpp.

## ◆ operator-() [1/2]

template<typename T >

constexpr Vec< 2, T > plask::Vec< 2, T >::operator- | ( |  | ) | const
| inline constexpr

Calculate vector opposite to this.

Returns
  Vec<2,T>(-c0, -c1)

Definition at line 290 of file 2d.hpp.

## ◆ operator-() [2/2]

template<typename T >
template<typename OtherT >

constexpr auto plask::Vec< 2, T >::operator- | ( | const Vec< 2, OtherT > & | other | ) | const -> Vec<2, decltype(c0 - other.c0)>
| inline constexpr

Calculate difference of two vectors, `this` and `other`.

Parameters

  other | vector 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 227 of file 2d.hpp.

## ◆ operator-=()

template<typename T >

Vec< 2, T > & plask::Vec< 2, T >::operator-= | ( | const Vec< 2, T > & | other | ) |
| inline

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

Parameters

  other | vector to subtract

Returns
  *this (after decrease)

Definition at line 236 of file 2d.hpp.

## ◆ operator/()

template<typename T >
template<typename OtherT >

constexpr auto plask::Vec< 2, T >::operator/ | ( | const OtherT | scale | ) | const -> Vec<2, decltype(c0 / scale)>
| inline constexpr

Calculate this vector divided by scalar `scale`.

Parameters

  scale | scalar

Returns
  this vector divided by scalar

Definition at line 269 of file 2d.hpp.

## ◆ operator/=()

template<typename T >

Vec< 2, T > & plask::Vec< 2, T >::operator/= | ( | const T | scalar | ) |
| inline

Divide coordinates of this vector by `scalar`.

Parameters

  scalar | scalar

Returns
  *this (after divide)

Definition at line 280 of file 2d.hpp.

## ◆ operator<()

template<typename T >
template<class OT >

bool plask::Vec< 2, T >::operator< | ( | Vec< 2, 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

  v | vectors to compare

Returns
  `true` only if `this` is smaller than the `v`

Definition at line 373 of file 2d.hpp.

## ◆ operator==()

template<typename T >
template<typename OtherT >

constexpr bool plask::Vec< 2, T >::operator== | ( | const Vec< 2, OtherT > & | p | ) | const
| inline constexpr

Compare two vectors, this and `p`.

Parameters

  p | vector to compare

Returns
  true only if this vector and `p` have equals coordinates

Definition at line 150 of file 2d.hpp.

## ◆ operator[]() [1/2]

template<typename T >

T & plask::Vec< 2, T >::operator[] | ( | size_t | i | ) |
| inline

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

Parameters

  i | number of coordinate

Returns
  i-th component

Definition at line 185 of file 2d.hpp.

## ◆ operator[]() [2/2]

template<typename T >

const T & plask::Vec< 2, 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

  i | number of coordinate

Returns
  i-th component

Definition at line 196 of file 2d.hpp.

## ◆ pow()

template<typename T >
template<typename OtherT >

Vec< 2, T > plask::Vec< 2, T >::pow | ( | OtherT | a | ) | const
| inline

Power of each component of tensor.

Returns
  squared tensor

Definition at line 332 of file 2d.hpp.

## ◆ rad_r() [1/2]

template<typename T >

T & plask::Vec< 2, T >::rad_r | ( |  | ) |
| inline

Definition at line 49 of file 2d.hpp.

## ◆ rad_r() [2/2]

template<typename T >

constexpr const T & plask::Vec< 2, T >::rad_r | ( |  | ) | const
| inline constexpr

Definition at line 50 of file 2d.hpp.

## ◆ rad_z() [1/2]

template<typename T >

T & plask::Vec< 2, T >::rad_z | ( |  | ) |
| inline

Definition at line 51 of file 2d.hpp.

## ◆ rad_z() [2/2]

template<typename T >

constexpr const T & plask::Vec< 2, T >::rad_z | ( |  | ) | const
| inline constexpr

Definition at line 52 of file 2d.hpp.

## ◆ se_y() [1/2]

template<typename T >

T & plask::Vec< 2, T >::se_y | ( |  | ) |
| inline

Definition at line 55 of file 2d.hpp.

## ◆ se_y() [2/2]

template<typename T >

constexpr const T & plask::Vec< 2, T >::se_y | ( |  | ) | const
| inline constexpr

Definition at line 56 of file 2d.hpp.

## ◆ se_z() [1/2]

template<typename T >

T & plask::Vec< 2, T >::se_z | ( |  | ) |
| inline

Definition at line 57 of file 2d.hpp.

## ◆ se_z() [2/2]

template<typename T >

constexpr const T & plask::Vec< 2, T >::se_z | ( |  | ) | const
| inline constexpr

Definition at line 58 of file 2d.hpp.

## ◆ sqr()

template<typename T >

Vec< 2, T > plask::Vec< 2, T >::sqr | ( |  | ) | const
| inline

Square each component of tensor.

Returns
  squared tensor

Definition at line 296 of file 2d.hpp.

## ◆ sqr_inplace()

template<typename T >

Vec< 2, T > & plask::Vec< 2, T >::sqr_inplace | ( |  | ) |
| inline

Square each component of tensor in place.

Returns
  *this (squared)

Definition at line 302 of file 2d.hpp.

## ◆ sqrt()

template<typename T >

Vec< 2, T > plask::Vec< 2, T >::sqrt | ( |  | ) | const
| inline

Square root of each component of tensor.

Returns
  squared tensor

Definition at line 312 of file 2d.hpp.

## ◆ sqrt_inplace()

template<typename T >

Vec< 2, T > & plask::Vec< 2, T >::sqrt_inplace | ( |  | ) |
| inline

Square root of each component of tensor in place.

Returns
  *this (squared)

Definition at line 322 of file 2d.hpp.

## ◆ tran() [1/2]

template<typename T >

T & plask::Vec< 2, T >::tran | ( |  | ) |
| inline

Definition at line 42 of file 2d.hpp.

## ◆ tran() [2/2]

template<typename T >

constexpr const T & plask::Vec< 2, T >::tran | ( |  | ) | const
| inline constexpr

Definition at line 43 of file 2d.hpp.

## ◆ vert() [1/2]

template<typename T >

T & plask::Vec< 2, T >::vert | ( |  | ) |
| inline

Definition at line 45 of file 2d.hpp.

## ◆ vert() [2/2]

template<typename T >

constexpr const T & plask::Vec< 2, T >::vert | ( |  | ) | const
| inline constexpr

Definition at line 46 of file 2d.hpp.

## ◆ y_up_x()

template<typename T >

constexpr const T & plask::Vec< 2, T >::y_up_x | ( |  | ) | const
| inline constexpr

Definition at line 74 of file 2d.hpp.

## ◆ y_up_y()

template<typename T >

constexpr const T & plask::Vec< 2, T >::y_up_y | ( |  | ) | const
| inline constexpr

Definition at line 76 of file 2d.hpp.

## ◆ yup_x()

template<typename T >

T & plask::Vec< 2, T >::yup_x | ( |  | ) |
| inline

Definition at line 73 of file 2d.hpp.

## ◆ yup_y()

template<typename T >

T & plask::Vec< 2, T >::yup_y | ( |  | ) |
| inline

Definition at line 75 of file 2d.hpp.

## ◆ z_up_y()

template<typename T >

constexpr const T & plask::Vec< 2, T >::z_up_y | ( |  | ) | const
| inline constexpr

Definition at line 62 of file 2d.hpp.

## ◆ z_up_z()

template<typename T >

constexpr const T & plask::Vec< 2, T >::z_up_z | ( |  | ) | const
| inline constexpr

Definition at line 64 of file 2d.hpp.

## ◆ zup_y()

template<typename T >

T & plask::Vec< 2, T >::zup_y | ( |  | ) |
| inline

Definition at line 61 of file 2d.hpp.

## ◆ zup_z()

template<typename T >

T & plask::Vec< 2, T >::zup_z | ( |  | ) |
| inline

Definition at line 63 of file 2d.hpp.

## Friends And Related Symbol Documentation

## ◆ operator<<

template<typename T >

std::ostream & operator<< | ( | std::ostream & | out,
|  | const Vec< 2, T > & | to_print
| ) |  |
| friend

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

Parameters

  out | print destination, output stream
  to_print | vector to print

Returns
  out stream

Definition at line 362 of file 2d.hpp.

## Member Data Documentation

## ◆ c0

template<typename T >

T plask::Vec< 2, T >::c0

Definition at line 40 of file 2d.hpp.

## ◆ c1

template<typename T >

T plask::Vec< 2, T >::c1

Definition at line 40 of file 2d.hpp.

## ◆ DIMS

template<typename T >

const int plask::Vec< 2, T >::DIMS = 2
| static

Definition at line 38 of file 2d.hpp.

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

- plask/vector/2d.hpp