PLaSK library

Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Friends | List of all members
plask::Tensor2< T > Struct Template Reference

Diagonal tensor with all lateral components equal. More...

`#include <plask/vector/tensor2.hpp>`

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

## Public Member Functions
T & | tran ()
const T & | tran () const
T & | vert ()
const T & | vert () const
| Tensor2 ()
| Construct uninitialized Tensor.
template<typename OtherT >
| Tensor2 (const Tensor2< OtherT > &p)
| Copy constructor from all other 2d tensors.
| Tensor2 (const T &val)
| Construct isotropic tensor.
| Tensor2 (const T &c00, const T &c11)
| Construct tensor with given diagonal values.
template<typename T0 , typename T1 >
| Tensor2 (const std::pair< T0, T1 > &comp)
| Construct tensor components given in std::pair.
| Tensor2 (const Vec< 2, T > &vec)
| Construct tensor from 2D vector.
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)
| operator std::tuple< T, T > () const
| Convert to std::tuple.
template<typename OtherT >
bool | operator== (const Tensor2< OtherT > &p) const
| Compare two tensors, this and `p`.
template<typename OtherT >
constexpr bool | equals (const Tensor2< OtherT > &p) const
| Check if two tensors, this and `p` are almost equal.
template<typename OtherT >
bool | operator!= (const Tensor2< OtherT > &p) const
| Compare two tensors, this and `p`.
template<typename OtherT >
auto | operator+ (const Tensor2< OtherT > &other) const -> Tensor2< decltype(c00+other.c00)>
| Calculate sum of two tesnors, `this` and `other`.
Tensor2< T > & | operator+= (const Tensor2< T > &other)
| Increase coordinates of this tensor by coordinates of other tensor `other`.
template<typename OtherT >
auto | operator- (const Tensor2< OtherT > &other) const -> Tensor2< decltype(c00 - other.c00)>
| Calculate difference of two tensors, `this` and `other`.
Tensor2< T > & | operator-= (const Tensor2< T > &other)
| Decrease coordinates of this tensor by coordinates of other tensor `other`.
template<typename OtherT >
auto | operator* (const OtherT scale) const -> Tensor2< decltype(c00 *scale)>
| Calculate this tensor multiplied by scalar `scale`.
Tensor2< T > & | operator*= (const T scalar)
| Multiple coordinates of this tensor by `scalar`.
Tensor2< T > | operator/ (const T scale) const
| Calculate this tensor divided by scalar `scale`.
Tensor2< T > & | operator/= (const T scalar)
| Divide coordinates of this tensor by `scalar`.
Tensor2< T > | operator- () const
| Calculate tensor opposite to this.
Tensor2< T > | pow (double a) const
| Power of each component of tensor.

## Public Attributes
T | c00
| Value of the tensor in lateral direction.
T | c11
| Value of the tensor in vertical direction.

## Friends
std::ostream & | operator<< (std::ostream &out, const Tensor2< T > &to_print)
| Print tensor to stream using format (where c00 and c11 are tensor components): [c00, c11].

## Detailed Description

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

Diagonal tensor with all lateral components equal.

[ c00 0 ] [ 0 c11 ]

Definition at line 34 of file tensor2.hpp.

## Constructor & Destructor Documentation

## ◆ Tensor2() [1/6]

template<typename T >

plask::Tensor2< T >::Tensor2 | ( |  | ) |
| inline

Construct uninitialized Tensor.

Definition at line 45 of file tensor2.hpp.

## ◆ Tensor2() [2/6]

template<typename T >
template<typename OtherT >

plask::Tensor2< T >::Tensor2 | ( | const Tensor2< OtherT > & | p | ) |
| inline

Copy constructor from all other 2d tensors.

Parameters

  p | tensor to copy from

Definition at line 51 of file tensor2.hpp.

## ◆ Tensor2() [3/6]

template<typename T >

plask::Tensor2< T >::Tensor2 | ( | const T & | val | ) |
| inline

Construct isotropic tensor.

Parameters

  val | value

Definition at line 57 of file tensor2.hpp.

## ◆ Tensor2() [4/6]

template<typename T >

plask::Tensor2< T >::Tensor2 | ( | const T & | c00,
|  | const T & | c11
| ) |  |
| inline

Construct tensor with given diagonal values.

Parameters

  c00,c11 | components

Definition at line 63 of file tensor2.hpp.

## ◆ Tensor2() [5/6]

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

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

Construct tensor components given in std::pair.

Parameters

  comp | components

Definition at line 69 of file tensor2.hpp.

## ◆ Tensor2() [6/6]

template<typename T >

plask::Tensor2< T >::Tensor2 | ( | const Vec< 2, T > & | vec | ) |
| inline

Construct tensor from 2D vector.

Parameters

  vec | vector

Definition at line 75 of file tensor2.hpp.

## Member Function Documentation

## ◆ equals()

template<typename T >
template<typename OtherT >

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

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

Parameters

  p | tensors to compare

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

Definition at line 114 of file tensor2.hpp.

## ◆ operator std::tuple< T, T >()

template<typename T >

plask::Tensor2< T >::operator std::tuple< T, T > | ( |  | ) | const
| inline

Convert to std::tuple.

Definition at line 100 of file tensor2.hpp.

## ◆ operator!=()

template<typename T >
template<typename OtherT >

bool plask::Tensor2< T >::operator!= | ( | const Tensor2< OtherT > & | p | ) | const
| inline

Compare two tensors, this and `p`.

Parameters

  p | tensor to compare

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

Definition at line 123 of file tensor2.hpp.

## ◆ operator*()

template<typename T >
template<typename OtherT >

auto plask::Tensor2< T >::operator* | ( | const OtherT | scale | ) | const -> Tensor2<decltype(c00 * scale)>
| inline

Calculate this tensor multiplied by scalar `scale`.

Parameters

  scale | scalar

Returns
  this tensor multiplied by scalar

Definition at line 171 of file tensor2.hpp.

## ◆ operator*=()

template<typename T >

Tensor2< T > & plask::Tensor2< T >::operator*= | ( | const T | scalar | ) |
| inline

Multiple coordinates of this tensor by `scalar`.

Parameters

  scalar | scalar

Returns
  *this (after scale)

Definition at line 180 of file tensor2.hpp.

## ◆ operator+()

template<typename T >
template<typename OtherT >

auto plask::Tensor2< T >::operator+ | ( | const Tensor2< OtherT > & | other | ) | const -> Tensor2<decltype(c00 + other.c00)>
| inline

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

Parameters

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

Returns
  tensors sum

Definition at line 130 of file tensor2.hpp.

## ◆ operator+=()

template<typename T >

Tensor2< T > & plask::Tensor2< T >::operator+= | ( | const Tensor2< T > & | other | ) |
| inline

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

Parameters

  other | tensor to add

Returns
  *this (after increase)

Definition at line 139 of file tensor2.hpp.

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

template<typename T >

Tensor2< T > plask::Tensor2< T >::operator- | ( |  | ) | const
| inline

Calculate tensor opposite to this.

Returns
  Tensor2<T>(-c00, -c11)

Definition at line 208 of file tensor2.hpp.

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

template<typename T >
template<typename OtherT >

auto plask::Tensor2< T >::operator- | ( | const Tensor2< OtherT > & | other | ) | const -> Tensor2<decltype(c00 - other.c00)>
| inline

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

Parameters

  other | tensor to subtract from this, can have different data type (than result type will be found using C++ types promotions rules)

Returns
  tensors difference

Definition at line 151 of file tensor2.hpp.

## ◆ operator-=()

template<typename T >

Tensor2< T > & plask::Tensor2< T >::operator-= | ( | const Tensor2< T > & | other | ) |
| inline

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

Parameters

  other | tensor to subtract

Returns
  *this (after decrease)

Definition at line 160 of file tensor2.hpp.

## ◆ operator/()

template<typename T >

Tensor2< T > plask::Tensor2< T >::operator/ | ( | const T | scale | ) | const
| inline

Calculate this tensor divided by scalar `scale`.

Parameters

  scale | scalar

Returns
  this tensor divided by scalar

Definition at line 191 of file tensor2.hpp.

## ◆ operator/=()

template<typename T >

Tensor2< T > & plask::Tensor2< T >::operator/= | ( | const T | scalar | ) |
| inline

Divide coordinates of this tensor by `scalar`.

Parameters

  scalar | scalar

Returns
  *this (after divide)

Definition at line 198 of file tensor2.hpp.

## ◆ operator==()

template<typename T >
template<typename OtherT >

bool plask::Tensor2< T >::operator== | ( | const Tensor2< OtherT > & | p | ) | const
| inline

Compare two tensors, this and `p`.

Parameters

  p | tensor to compare

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

Definition at line 107 of file tensor2.hpp.

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

template<typename T >

T & plask::Tensor2< 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 83 of file tensor2.hpp.

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

template<typename T >

const T & plask::Tensor2< 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 94 of file tensor2.hpp.

## ◆ pow()

template<typename T >

Tensor2< T > plask::Tensor2< T >::pow | ( | double | a | ) | const
| inline

Power of each component of tensor.

Returns
  squared tensor

Definition at line 248 of file tensor2.hpp.

## ◆ tran() [1/2]

template<typename T >

T & plask::Tensor2< T >::tran | ( |  | ) |
| inline

Definition at line 38 of file tensor2.hpp.

## ◆ tran() [2/2]

template<typename T >

const T & plask::Tensor2< T >::tran | ( |  | ) | const
| inline

Definition at line 39 of file tensor2.hpp.

## ◆ vert() [1/2]

template<typename T >

T & plask::Tensor2< T >::vert | ( |  | ) |
| inline

Definition at line 41 of file tensor2.hpp.

## ◆ vert() [2/2]

template<typename T >

const T & plask::Tensor2< T >::vert | ( |  | ) | const
| inline

Definition at line 42 of file tensor2.hpp.

## Friends And Related Symbol Documentation

## ◆ operator<<

template<typename T >

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

Print tensor to stream using format (where c00 and c11 are tensor components): [c00, c11].

Parameters

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

Returns
  out stream

Definition at line 256 of file tensor2.hpp.

## Member Data Documentation

## ◆ c00

template<typename T >

T plask::Tensor2< T >::c00

Value of the tensor in lateral direction.

Definition at line 35 of file tensor2.hpp.

## ◆ c11

template<typename T >

T plask::Tensor2< T >::c11

Value of the tensor in vertical direction.

Definition at line 36 of file tensor2.hpp.

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

- plask/vector/tensor2.hpp