Reference documentation for deal.II version 9.6.1
 
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
Tensor< 0, dim, Number > Class Template Reference

#include <deal.II/base/tensor.h>

Inheritance diagram for Tensor< 0, dim, Number >:

Public Types

using real_type = typename numbers::NumberTraits<Number>::real_type
 
using value_type = Number
 
using array_type = Number
 
using tensor_type = Number
 
using value_type
 
using array_type
 
using tensor_type
 

Public Member Functions

constexpr Tensor ()
 
template<typename OtherNumber>
constexpr Tensor (const Tensor< 0, dim, OtherNumber > &initializer)
 
template<typename OtherNumber>
constexpr Tensor (const OtherNumber &initializer)
 
constexpr operator Number & ()
 
constexpr operator const Number & () const
 
template<typename OtherNumber>
constexpr Tensoroperator= (const Tensor< 0, dim, OtherNumber > &rhs)
 
template<typename OtherNumber>
constexpr Tensoroperator= (const OtherNumber &d) &
 
template<typename OtherNumber>
constexpr Tensoroperator= (const OtherNumber &d) &&=delete
 
template<typename OtherNumber>
constexpr bool operator== (const Tensor< 0, dim, OtherNumber > &rhs) const
 
template<typename OtherNumber>
constexpr bool operator!= (const Tensor< 0, dim, OtherNumber > &rhs) const
 
template<typename OtherNumber>
constexpr Tensoroperator+= (const Tensor< 0, dim, OtherNumber > &rhs)
 
template<typename OtherNumber>
constexpr Tensoroperator-= (const Tensor< 0, dim, OtherNumber > &rhs)
 
template<typename OtherNumber>
constexpr Tensoroperator*= (const OtherNumber &factor)
 
template<typename OtherNumber>
constexpr Tensoroperator/= (const OtherNumber &factor)
 
constexpr Tensor operator- () const
 
constexpr void clear ()
 
real_type norm () const
 
constexpr real_type norm_square () const
 
template<class Iterator>
void unroll (const Iterator begin, const Iterator end) const
 
template<class Archive>
void serialize (Archive &ar, const unsigned int version)
 
constexpr DEAL_II_HOST_DEVICE_ALWAYS_INLINE Tensor ()
 
constexpr Tensor (const array_type &initializer)
 
constexpr Tensor (const ArrayView< ElementType, MemorySpace > &initializer)
 
constexpr Tensor (const Tensor< rank_, dim, OtherNumber > &initializer)
 
constexpr Tensor (const Tensor< 1, dim, Tensor< rank_ - 1, dim, OtherNumber > > &initializer)
 
constexpr operator Tensor< 1, dim, Tensor< rank_ - 1, dim, OtherNumber > > () const
 
constexpr value_typeoperator[] (const unsigned int i)
 
constexpr const value_typeoperator[] (const unsigned int i) const
 
constexpr const Number & operator[] (const TableIndices< rank_ > &indices) const
 
constexpr Number & operator[] (const TableIndices< rank_ > &indices)
 
Number * begin_raw ()
 
const Number * begin_raw () const
 
Number * end_raw ()
 
const Number * end_raw () const
 
constexpr Tensoroperator= (const Tensor< rank_, dim, OtherNumber > &rhs)
 
constexpr Tensoroperator= (const Number &d) &
 
constexpr Tensoroperator= (const Number &d) &&=delete
 
constexpr bool operator== (const Tensor< rank_, dim, OtherNumber > &) const
 
constexpr bool operator!= (const Tensor< rank_, dim, OtherNumber > &) const
 
constexpr Tensoroperator+= (const Tensor< rank_, dim, OtherNumber > &)
 
constexpr Tensoroperator-= (const Tensor< rank_, dim, OtherNumber > &)
 
constexpr Tensoroperator*= (const OtherNumber &factor)
 
constexpr Tensoroperator/= (const OtherNumber &factor)
 
constexpr Tensor operator- () const
 
constexpr void clear ()
 
numbers::NumberTraits< Number >::real_type norm () const
 
constexpr numbers::NumberTraits< Number >::real_type norm_square () const
 
void unroll (Vector< OtherNumber > &result) const
 
void unroll (const Iterator begin, const Iterator end) const
 
void serialize (Archive &ar, const unsigned int version)
 

Static Public Member Functions

static constexpr unsigned int component_to_unrolled_index (const TableIndices< rank_ > &indices)
 
static constexpr TableIndices< rank_ > unrolled_to_component_indices (const unsigned int i)
 
static constexpr std::size_t memory_consumption ()
 

Static Public Attributes

static constexpr unsigned int dimension = dim
 
static constexpr unsigned int rank = 0
 
static constexpr unsigned int n_independent_components = 1
 
static constexpr unsigned int dimension
 
static constexpr unsigned int rank
 
static constexpr unsigned int n_independent_components
 

Private Member Functions

constexpr Tensor (const ArrayLike &initializer, std::index_sequence< Indices... >)
 

Private Attributes

Number value
 
std::conditional_t< rank_==1, std::array< Number, dim >, std::array< Tensor< rank_ - 1, dim, Number >, dim > > values
 

Friends

template<int, int, typename>
class Tensor
 
class Tensor
 
class Point< dim, Number >
 

Related Symbols

(Note that these are not member symbols.)

Tensor< rank, dim, Number > sum (const Tensor< rank, dim, Number > &local, const MPI_Comm mpi_communicator)
 
Tensor< rank, dim, Number > sum (const Tensor< rank, dim, Number > &local, const MPI_Comm mpi_communicator)
 
Output functions for Tensor objects
std::ostream & operator<< (std::ostream &out, const Tensor< rank_, dim, Number > &p)
 
std::ostream & operator<< (std::ostream &out, const Tensor< 0, dim, Number > &p)
 
std::ostream & operator<< (std::ostream &out, const Tensor< rank_, dim, Number > &p)
 
std::ostream & operator<< (std::ostream &out, const Tensor< 0, dim, Number > &p)
 
Vector space operations on Tensor objects
constexpr ProductType< Other, Number >::type operator* (const Other &object, const Tensor< 0, dim, Number > &t)
 
constexpr ProductType< Number, Other >::type operator* (const Tensor< 0, dim, Number > &t, const Other &object)
 
constexpr ProductType< Number, OtherNumber >::type operator* (const Tensor< 0, dim, Number > &src1, const Tensor< 0, dim, OtherNumber > &src2)
 
constexpr Tensor< 0, dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator/ (const Tensor< 0, dim, Number > &t, const OtherNumber &factor)
 
constexpr DEAL_II_HOST_DEVICE_ALWAYS_INLINE Tensor< 0, dim, typename ProductType< Number, OtherNumber >::type > operator+ (const Tensor< 0, dim, Number > &p, const Tensor< 0, dim, OtherNumber > &q)
 
constexpr DEAL_II_HOST_DEVICE_ALWAYS_INLINE Tensor< 0, dim, typename ProductType< Number, OtherNumber >::type > operator- (const Tensor< 0, dim, Number > &p, const Tensor< 0, dim, OtherNumber > &q)
 
constexpr Tensor< rank, dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator* (const Tensor< rank, dim, Number > &t, const OtherNumber &factor)
 
constexpr Tensor< rank, dim, typename ProductType< typename EnableIfScalar< Number >::type, OtherNumber >::type > operator* (const Number &factor, const Tensor< rank, dim, OtherNumber > &t)
 
constexpr Tensor< rank, dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator/ (const Tensor< rank, dim, Number > &t, const OtherNumber &factor)
 
constexpr Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > operator+ (const Tensor< rank, dim, Number > &p, const Tensor< rank, dim, OtherNumber > &q)
 
constexpr Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > operator- (const Tensor< rank, dim, Number > &p, const Tensor< rank, dim, OtherNumber > &q)
 
constexpr Tensor< 0, dim, typename ProductType< Number, OtherNumber >::type > schur_product (const Tensor< 0, dim, Number > &src1, const Tensor< 0, dim, OtherNumber > &src2)
 
constexpr Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > schur_product (const Tensor< rank, dim, Number > &src1, const Tensor< rank, dim, OtherNumber > &src2)
 
constexpr DEAL_II_HOST_DEVICE_ALWAYS_INLINE Tensor< 0, dim, typename ProductType< Number, OtherNumber >::type > operator- (const Tensor< 0, dim, Number > &p, const Tensor< 0, dim, OtherNumber > &q)
 
constexpr Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > operator- (const Tensor< rank, dim, Number > &p, const Tensor< rank, dim, OtherNumber > &q)
 
constexpr ProductType< Other, Number >::type operator* (const Other &object, const Tensor< 0, dim, Number > &t)
 
constexpr ProductType< Number, Other >::type operator* (const Tensor< 0, dim, Number > &t, const Other &object)
 
constexpr ProductType< Number, OtherNumber >::type operator* (const Tensor< 0, dim, Number > &src1, const Tensor< 0, dim, OtherNumber > &src2)
 
constexpr Tensor< rank, dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator* (const Tensor< rank, dim, Number > &t, const OtherNumber &factor)
 
constexpr Tensor< rank, dim, typename ProductType< typename EnableIfScalar< Number >::type, OtherNumber >::type > operator* (const Number &factor, const Tensor< rank, dim, OtherNumber > &t)
 
constexpr Tensor< 0, dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator/ (const Tensor< 0, dim, Number > &t, const OtherNumber &factor)
 
constexpr Tensor< rank, dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator/ (const Tensor< rank, dim, Number > &t, const OtherNumber &factor)
 
constexpr DEAL_II_HOST_DEVICE_ALWAYS_INLINE Tensor< 0, dim, typename ProductType< Number, OtherNumber >::type > operator+ (const Tensor< 0, dim, Number > &p, const Tensor< 0, dim, OtherNumber > &q)
 
constexpr Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > operator+ (const Tensor< rank, dim, Number > &p, const Tensor< rank, dim, OtherNumber > &q)
 
constexpr Tensor< 0, dim, typename ProductType< Number, OtherNumber >::type > schur_product (const Tensor< 0, dim, Number > &src1, const Tensor< 0, dim, OtherNumber > &src2)
 
constexpr Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > schur_product (const Tensor< rank, dim, Number > &src1, const Tensor< rank, dim, OtherNumber > &src2)
 
Contraction operations and the outer product for tensor objects
constexpr Tensor< rank_1+rank_2-2, dim, typenameProductType< Number, OtherNumber >::type >::tensor_type operator* (const Tensor< rank_1, dim, Number > &src1, const Tensor< rank_2, dim, OtherNumber > &src2)
 
constexpr Tensor< rank_1+rank_2-2, dim, typenameProductType< Number, OtherNumber >::type >::tensor_type contract (const Tensor< rank_1, dim, Number > &src1, const Tensor< rank_2, dim, OtherNumber > &src2)
 
constexpr Tensor< rank_1+rank_2-4, dim, typenameProductType< Number, OtherNumber >::type >::tensor_type double_contract (const Tensor< rank_1, dim, Number > &src1, const Tensor< rank_2, dim, OtherNumber > &src2)
 
constexpr ProductType< Number, OtherNumber >::type scalar_product (const Tensor< rank, dim, Number > &left, const Tensor< rank, dim, OtherNumber > &right)
 
constexpr ProductType< T1, typenameProductType< T2, T3 >::type >::type contract3 (const TensorT1< rank_1, dim, T1 > &left, const TensorT2< rank_1+rank_2, dim, T2 > &middle, const TensorT3< rank_2, dim, T3 > &right)
 
constexpr Tensor< rank_1+rank_2, dim, typename ProductType< Number, OtherNumber >::type > outer_product (const Tensor< rank_1, dim, Number > &src1, const Tensor< rank_2, dim, OtherNumber > &src2)
 
constexpr Tensor< rank_1+rank_2-2, dim, typenameProductType< Number, OtherNumber >::type >::tensor_type operator* (const Tensor< rank_1, dim, Number > &src1, const Tensor< rank_2, dim, OtherNumber > &src2)
 
constexpr Tensor< rank_1+rank_2-2, dim, typenameProductType< Number, OtherNumber >::type >::tensor_type contract (const Tensor< rank_1, dim, Number > &src1, const Tensor< rank_2, dim, OtherNumber > &src2)
 
constexpr Tensor< rank_1+rank_2-4, dim, typenameProductType< Number, OtherNumber >::type >::tensor_type double_contract (const Tensor< rank_1, dim, Number > &src1, const Tensor< rank_2, dim, OtherNumber > &src2)
 
constexpr ProductType< Number, OtherNumber >::type scalar_product (const Tensor< rank, dim, Number > &left, const Tensor< rank, dim, OtherNumber > &right)
 
constexpr ProductType< T1, typenameProductType< T2, T3 >::type >::type contract3 (const TensorT1< rank_1, dim, T1 > &left, const TensorT2< rank_1+rank_2, dim, T2 > &middle, const TensorT3< rank_2, dim, T3 > &right)
 
constexpr Tensor< rank_1+rank_2, dim, typename ProductType< Number, OtherNumber >::type > outer_product (const Tensor< rank_1, dim, Number > &src1, const Tensor< rank_2, dim, OtherNumber > &src2)
 
Special operations on tensors of rank 1
constexpr Tensor< 1, dim, Number > cross_product_2d (const Tensor< 1, dim, Number > &src)
 
constexpr Tensor< 1, dim, typename ProductType< Number1, Number2 >::type > cross_product_3d (const Tensor< 1, dim, Number1 > &src1, const Tensor< 1, dim, Number2 > &src2)
 
constexpr Tensor< 1, dim, Number > cross_product_2d (const Tensor< 1, dim, Number > &src)
 
constexpr Tensor< 1, dim, typename ProductType< Number1, Number2 >::type > cross_product_3d (const Tensor< 1, dim, Number1 > &src1, const Tensor< 1, dim, Number2 > &src2)
 
Special operations on tensors of rank 2
constexpr Number determinant (const Tensor< 2, dim, Number > &t)
 
constexpr Number determinant (const Tensor< 2, 1, Number > &t)
 
constexpr Number determinant (const Tensor< 2, 2, Number > &t)
 
constexpr Number determinant (const Tensor< 2, 3, Number > &t)
 
constexpr Number trace (const Tensor< 2, dim, Number > &d)
 
constexpr Tensor< 2, dim, Number > invert (const Tensor< 2, dim, Number > &)
 
constexpr Tensor< 2, dim, Number > transpose (const Tensor< 2, dim, Number > &t)
 
constexpr Tensor< 2, dim, Number > adjugate (const Tensor< 2, dim, Number > &t)
 
constexpr Tensor< 2, dim, Number > cofactor (const Tensor< 2, dim, Number > &t)
 
Tensor< 2, dim, Number > project_onto_orthogonal_tensors (const Tensor< 2, dim, Number > &A)
 
Number l1_norm (const Tensor< 2, dim, Number > &t)
 
Number linfty_norm (const Tensor< 2, dim, Number > &t)
 
constexpr Number determinant (const Tensor< 2, dim, Number > &t)
 
constexpr Number determinant (const Tensor< 2, 1, Number > &t)
 
constexpr Number determinant (const Tensor< 2, 2, Number > &t)
 
constexpr Number determinant (const Tensor< 2, 3, Number > &t)
 
constexpr Number trace (const Tensor< 2, dim, Number > &d)
 
constexpr Tensor< 2, dim, Number > invert (const Tensor< 2, dim, Number > &)
 
constexpr Tensor< 2, dim, Number > transpose (const Tensor< 2, dim, Number > &t)
 
constexpr Tensor< 2, dim, Number > adjugate (const Tensor< 2, dim, Number > &t)
 
constexpr Tensor< 2, dim, Number > cofactor (const Tensor< 2, dim, Number > &t)
 
Tensor< 2, dim, Number > project_onto_orthogonal_tensors (const Tensor< 2, dim, Number > &A)
 
Number l1_norm (const Tensor< 2, dim, Number > &t)
 
Number linfty_norm (const Tensor< 2, dim, Number > &t)
 

Detailed Description

template<int dim, typename Number>
class Tensor< 0, dim, Number >

This class is a specialized version of the Tensor<rank,dim,Number> class. It handles tensors of rank zero, i.e. scalars. The second template argument dim is ignored.

This class exists because in some cases we want to construct objects of type Tensor<spacedim-dim,dim,Number>, which should expand to scalars, vectors, matrices, etc, depending on the values of the template arguments dim and spacedim. We therefore need a class that acts as a scalar (i.e. Number) for all purposes but is part of the Tensor template family.

Template Parameters
dimAn integer that denotes the dimension of the space in which this tensor operates. This of course equals the number of coordinates that identify a point and rank-1 tensor. Since the current object is a rank-0 tensor (a scalar), this template argument has no meaning for this class.
NumberThe data type in which the tensor elements are to be stored. This will, in almost all cases, simply be the default double, but there are cases where one may want to store elements in a different (and always scalar) type. It can be used to base tensors on float or complex numbers or any other data type that implements basic arithmetic operations. Another example would be a type that allows for Automatic Differentiation (see, for example, the Sacado type used in step-33) and thereby can generate analytic (spatial) derivatives of a function that takes a tensor as argument.

Definition at line 103 of file tensor.h.

Member Typedef Documentation

◆ real_type

template<int dim, typename Number>
using Tensor< 0, dim, Number >::real_type = typename numbers::NumberTraits<Number>::real_type

Declare a type that has holds real-valued numbers with the same precision as the template argument to this class. For std::complex<number>, this corresponds to type number, and it is equal to Number for all other cases. See also the respective field in Vector<Number>.

This alias is used to represent the return type of norms.

Definition at line 137 of file tensor.h.

◆ value_type [1/2]

template<int dim, typename Number>
using Tensor< 0, dim, Number >::value_type = Number

Type of objects encapsulated by this container and returned by operator[](). This is a scalar number type for a rank 0 tensor.

Definition at line 143 of file tensor.h.

◆ array_type [1/2]

template<int dim, typename Number>
using Tensor< 0, dim, Number >::array_type = Number

Declare an array type which can be used to initialize an object of this type statically. In case of a tensor of rank 0 this is just the scalar number type Number.

Definition at line 150 of file tensor.h.

◆ tensor_type [1/2]

template<int dim, typename Number>
using Tensor< 0, dim, Number >::tensor_type = Number

Internal type declaration that is used to specialize the return type of operator[]() for Tensor<1,dim,Number>

Definition at line 381 of file tensor.h.

◆ value_type [2/2]

using Tensor< rank_, dim, Number >::value_type

Type of objects encapsulated by this container and returned by operator[](). This is a tensor of lower rank for a general tensor, and a scalar number type for rank-1 tensors.

Definition at line 514 of file tensor.h.

◆ array_type [2/2]

using Tensor< rank_, dim, Number >::array_type

Declare an array type which can be used to initialize an object of this type statically. For rank-1 tensors, this array is simply an array of length dim of scalars of type Number. For higher-rank tensors, it is an array of length dim of the array_type of the next lower-rank tensor.

This class is occasionally instantiated for dim == 0. C++ does not allow the creation of zero-length arrays. As a consequence, if dim==0, then all arrays that should have length dim are instead declared as having length 1 to avoid compiler errors.

Definition at line 528 of file tensor.h.

◆ tensor_type [2/2]

using Tensor< rank_, dim, Number >::tensor_type

Internal type declaration that is used to specialize the return type of operator[]() for Tensor<1,dim,Number>

Definition at line 857 of file tensor.h.

Constructor & Destructor Documentation

◆ Tensor() [1/9]

template<int dim, typename Number>
Tensor< 0, dim, Number >::Tensor ( )
constexpr

Constructor. Set to zero.

Note
This function can also be used in device code.

◆ Tensor() [2/9]

template<int dim, typename Number>
template<typename OtherNumber>
Tensor< 0, dim, Number >::Tensor ( const Tensor< 0, dim, OtherNumber > & initializer)
constexpr

Constructor from tensors with different underlying scalar type. This obviously requires that the OtherNumber type is convertible to Number.

Note
This function can also be used in device code.

◆ Tensor() [3/9]

template<int dim, typename Number>
template<typename OtherNumber>
Tensor< 0, dim, Number >::Tensor ( const OtherNumber & initializer)
constexpr

Constructor, where the data is copied from a C-style array.

Note
This function can also be used in device code.

◆ Tensor() [4/9]

DEAL_II_HOST_DEVICE_ALWAYS_INLINE Tensor< rank_, dim, Number >::Tensor ( )
constexpr

Constructor. Initialize all entries to zero.

Note
This function can also be used in device code.

◆ Tensor() [5/9]

Tensor< rank_, dim, Number >::Tensor ( const array_type & initializer)
explicitconstexpr

A constructor where the data is copied from a C-style array.

Note
This function can also be used in device code.

◆ Tensor() [6/9]

Tensor< rank_, dim, Number >::Tensor ( const ArrayView< ElementType, MemorySpace > & initializer)
explicitconstexpr

A constructor where the data is copied from an ArrayView object. Obviously, the ArrayView object must represent a stretch of data of size dimrank. The sequentially ordered elements of the argument initializer are interpreted as described by unrolled_to_component_indices().

This constructor obviously requires that the ElementType type is either equal to Number, or is convertible to Number.

Note
This function can also be used in device code.

◆ Tensor() [7/9]

Tensor< rank_, dim, Number >::Tensor ( const Tensor< rank_, dim, OtherNumber > & initializer)
constexpr

Constructor from tensors with different underlying scalar type. This obviously requires that the OtherNumber type is convertible to Number.

Note
This function can also be used in device code.

◆ Tensor() [8/9]

Tensor< rank_, dim, Number >::Tensor ( const Tensor< 1, dim, Tensor< rank_ - 1, dim, OtherNumber > > & initializer)
constexpr

Constructor that converts from a "tensor of tensors".

◆ Tensor() [9/9]

Tensor< rank_, dim, Number >::Tensor ( const ArrayLike & initializer,
std::index_sequence< Indices... >  )
constexprprivate

This constructor is for internal use. It provides a way to create constexpr constructors for Tensor<rank, dim, Number>

Note
This function can also be used in device code.

Member Function Documentation

◆ operator Number &()

template<int dim, typename Number>
Tensor< 0, dim, Number >::operator Number & ( )
constexpr

Return a reference to the encapsulated Number object. Since rank-0 tensors are scalars, this is a natural operation.

This is the non-const conversion operator that returns a writable reference.

Note
This function can also be used in device code.

◆ operator const Number &()

template<int dim, typename Number>
Tensor< 0, dim, Number >::operator const Number & ( ) const
constexpr

Return a reference to the encapsulated Number object. Since rank-0 tensors are scalars, this is a natural operation.

This is the const conversion operator that returns a read-only reference.

Note
This function can also be used in device code.

◆ operator=() [1/6]

template<int dim, typename Number>
template<typename OtherNumber>
Tensor & Tensor< 0, dim, Number >::operator= ( const Tensor< 0, dim, OtherNumber > & rhs)
constexpr

Assignment from tensors with different underlying scalar type. This obviously requires that the OtherNumber type is convertible to Number.

Note
This function can also be used in device code.

◆ operator=() [2/6]

template<int dim, typename Number>
template<typename OtherNumber>
Tensor & Tensor< 0, dim, Number >::operator= ( const OtherNumber & d) &
constexpr

This operator assigns a scalar to a tensor. This obviously requires that the OtherNumber type is convertible to Number.

Note
This function can also be used in device code.

◆ operator=() [3/6]

template<int dim, typename Number>
template<typename OtherNumber>
Tensor & Tensor< 0, dim, Number >::operator= ( const OtherNumber & d) &&
constexprdelete

Assign a scalar to the current object. This overload is used for rvalue references; because it does not make sense to assign something to a temporary, the function is deleted.

◆ operator==() [1/2]

template<int dim, typename Number>
template<typename OtherNumber>
bool Tensor< 0, dim, Number >::operator== ( const Tensor< 0, dim, OtherNumber > & rhs) const
constexpr

Test for equality of two tensors.

◆ operator!=() [1/2]

template<int dim, typename Number>
template<typename OtherNumber>
bool Tensor< 0, dim, Number >::operator!= ( const Tensor< 0, dim, OtherNumber > & rhs) const
constexpr

Test for inequality of two tensors.

◆ operator+=() [1/2]

template<int dim, typename Number>
template<typename OtherNumber>
Tensor & Tensor< 0, dim, Number >::operator+= ( const Tensor< 0, dim, OtherNumber > & rhs)
constexpr

Add another scalar.

Note
This function can also be used in device code.

◆ operator-=() [1/2]

template<int dim, typename Number>
template<typename OtherNumber>
Tensor & Tensor< 0, dim, Number >::operator-= ( const Tensor< 0, dim, OtherNumber > & rhs)
constexpr

Subtract another scalar.

Note
This function can also be used in device code.

◆ operator*=() [1/2]

template<int dim, typename Number>
template<typename OtherNumber>
Tensor & Tensor< 0, dim, Number >::operator*= ( const OtherNumber & factor)
constexpr

Multiply the scalar with a factor.

Note
This function can also be used in device code.

◆ operator/=() [1/2]

template<int dim, typename Number>
template<typename OtherNumber>
Tensor & Tensor< 0, dim, Number >::operator/= ( const OtherNumber & factor)
constexpr

Divide the scalar by factor.

Note
This function can also be used in device code.

◆ operator-() [1/2]

template<int dim, typename Number>
Tensor Tensor< 0, dim, Number >::operator- ( ) const
constexpr

Tensor with inverted entries.

Note
This function can also be used in device code.

◆ clear() [1/2]

template<int dim, typename Number>
void Tensor< 0, dim, Number >::clear ( )
constexpr

Reset all values to zero.

Note that this is partly inconsistent with the semantics of the clear() member functions of the standard library containers and of several other classes within deal.II, which not only reset the values of stored elements to zero, but release all memory and return the object into an empty state. However, since the size of objects of the present type is determined by its template parameters, resizing is not an option, and indeed the state where all elements have a zero value is the state right after construction of such an object.

◆ norm() [1/2]

template<int dim, typename Number>
real_type Tensor< 0, dim, Number >::norm ( ) const

Return the Frobenius-norm of a tensor, i.e. the square root of the sum of the absolute squares of all entries. For the present case of rank-1 tensors, this equals the usual l2 norm of the vector.

◆ norm_square() [1/2]

template<int dim, typename Number>
real_type Tensor< 0, dim, Number >::norm_square ( ) const
constexpr

Return the square of the Frobenius-norm of a tensor, i.e. the sum of the absolute squares of all entries.

Note
This function can also be used in device code.

◆ unroll() [1/3]

template<int dim, typename Number>
template<class Iterator>
void Tensor< 0, dim, Number >::unroll ( const Iterator begin,
const Iterator end ) const

Fill a range with all tensor elements. Since this type of Tensor only has one entry this just copies the value of this tensor into *begin.

The template type Number must be convertible to the type of *begin.

◆ serialize() [1/2]

template<int dim, typename Number>
template<class Archive>
void Tensor< 0, dim, Number >::serialize ( Archive & ar,
const unsigned int version )

Read or write the data of this object to or from a stream for the purpose of serialization using the BOOST serialization library.

◆ operator Tensor< 1, dim, Tensor< rank_ - 1, dim, OtherNumber > >()

Tensor< rank_, dim, Number >::operator Tensor< 1, dim, Tensor< rank_ - 1, dim, OtherNumber > > ( ) const
constexpr

Conversion operator to tensor of tensors.

◆ operator[]() [1/4]

value_type & Tensor< rank_, dim, Number >::operator[] ( const unsigned int i)
constexpr

Read-Write access operator.

Note
This function can also be used in device code.

◆ operator[]() [2/4]

const value_type & Tensor< rank_, dim, Number >::operator[] ( const unsigned int i) const
constexpr

Read-only access operator.

Note
This function can also be used in device code.

◆ operator[]() [3/4]

const Number & Tensor< rank_, dim, Number >::operator[] ( const TableIndices< rank_ > & indices) const
constexpr

Read access using TableIndices indices

◆ operator[]() [4/4]

Number & Tensor< rank_, dim, Number >::operator[] ( const TableIndices< rank_ > & indices)
constexpr

Read and write access using TableIndices indices

◆ begin_raw() [1/2]

Number * Tensor< rank_, dim, Number >::begin_raw ( )

Return a pointer to the first element of the underlying storage.

◆ begin_raw() [2/2]

const Number * Tensor< rank_, dim, Number >::begin_raw ( ) const

Return a const pointer to the first element of the underlying storage.

◆ end_raw() [1/2]

Number * Tensor< rank_, dim, Number >::end_raw ( )

Return a pointer to the element past the end of the underlying storage.

◆ end_raw() [2/2]

const Number * Tensor< rank_, dim, Number >::end_raw ( ) const

Return a pointer to the element past the end of the underlying storage.

◆ operator=() [4/6]

Tensor & Tensor< rank_, dim, Number >::operator= ( const Tensor< rank_, dim, OtherNumber > & rhs)
constexpr

Assignment operator from tensors with different underlying scalar type. This obviously requires that the OtherNumber type is convertible to Number.

Note
This function can also be used in device code.

◆ operator=() [5/6]

Tensor & Tensor< rank_, dim, Number >::operator= ( const Number & d) &
constexpr

This operator assigns a scalar to a tensor. To avoid confusion with what exactly it means to assign a scalar value to a tensor, zero is the only value allowed for d, allowing the intuitive notation t=0 to reset all elements of the tensor to zero.

◆ operator=() [6/6]

Tensor & Tensor< rank_, dim, Number >::operator= ( const Number & d) &&
constexprdelete

Assign a scalar to the current object. This overload is used for rvalue references; because it does not make sense to assign something to a temporary, the function is deleted.

◆ operator==() [2/2]

bool Tensor< rank_, dim, Number >::operator== ( const Tensor< rank_, dim, OtherNumber > & ) const
constexpr

Test for equality of two tensors.

◆ operator!=() [2/2]

bool Tensor< rank_, dim, Number >::operator!= ( const Tensor< rank_, dim, OtherNumber > & ) const
constexpr

Test for inequality of two tensors.

◆ operator+=() [2/2]

Tensor & Tensor< rank_, dim, Number >::operator+= ( const Tensor< rank_, dim, OtherNumber > & )
constexpr

Add another tensor.

Note
This function can also be used in device code.

◆ operator-=() [2/2]

Tensor & Tensor< rank_, dim, Number >::operator-= ( const Tensor< rank_, dim, OtherNumber > & )
constexpr

Subtract another tensor.

Note
This function can also be used in device code.

◆ operator*=() [2/2]

Tensor & Tensor< rank_, dim, Number >::operator*= ( const OtherNumber & factor)
constexpr

Scale the tensor by factor, i.e. multiply all components by factor.

Note
This function can also be used in device code.

◆ operator/=() [2/2]

Tensor & Tensor< rank_, dim, Number >::operator/= ( const OtherNumber & factor)
constexpr

Scale the vector by 1/factor.

Note
This function can also be used in device code.

◆ operator-() [2/2]

Tensor Tensor< rank_, dim, Number >::operator- ( ) const
constexpr

Unary minus operator. Negate all entries of a tensor.

Note
This function can also be used in device code.

◆ clear() [2/2]

void Tensor< rank_, dim, Number >::clear ( )
constexpr

Reset all values to zero.

Note that this is partly inconsistent with the semantics of the clear() member functions of the standard library containers and of several other classes within deal.II, which not only reset the values of stored elements to zero, but release all memory and return the object into an empty state. However, since the size of objects of the present type is determined by its template parameters, resizing is not an option, and indeed the state where all elements have a zero value is the state right after construction of such an object.

◆ norm() [2/2]

numbers::NumberTraits< Number >::real_type Tensor< rank_, dim, Number >::norm ( ) const

Return the Frobenius-norm of a tensor, i.e. the square root of the sum of the absolute squares of all entries. For the present case of rank-1 tensors, this equals the usual l2 norm of the vector.

Note
This function can also be used in device code.

◆ norm_square() [2/2]

numbers::NumberTraits< Number >::real_type Tensor< rank_, dim, Number >::norm_square ( ) const
constexpr

Return the square of the Frobenius-norm of a tensor, i.e. the sum of the absolute squares of all entries.

Note
This function can also be used in device code.

◆ unroll() [2/3]

void Tensor< rank_, dim, Number >::unroll ( Vector< OtherNumber > & result) const

Fill a vector with all tensor elements.

This function unrolls all tensor entries into a single, linearly numbered vector. As usual in C++, the rightmost index of the tensor marches fastest.

Deprecated
Use the more general function that takes a pair of iterators instead.

◆ unroll() [3/3]

void Tensor< rank_, dim, Number >::unroll ( const Iterator begin,
const Iterator end ) const

Fill a range with all tensor elements.

This function unrolls all tensor entries into a single, linearly numbered sequence. The order of the elements is the one given by component_to_unrolled_index().

The template type Number must be convertible to the type of *begin.

◆ component_to_unrolled_index()

static constexpr unsigned int Tensor< rank_, dim, Number >::component_to_unrolled_index ( const TableIndices< rank_ > & indices)
staticconstexpr

Return an unrolled index in the range $[0,\text{dim}^{\text{rank}}-1]$ for the element of the tensor indexed by the argument to the function.

◆ unrolled_to_component_indices()

static constexpr TableIndices< rank_ > Tensor< rank_, dim, Number >::unrolled_to_component_indices ( const unsigned int i)
staticconstexpr

Opposite of component_to_unrolled_index: For an index in the range $[0, \text{dim}^{\text{rank}}-1]$, return which set of indices it would correspond to.

◆ memory_consumption()

static constexpr std::size_t Tensor< rank_, dim, Number >::memory_consumption ( )
staticconstexpr

Determine an estimate for the memory consumption (in bytes) of this object.

◆ serialize() [2/2]

void Tensor< rank_, dim, Number >::serialize ( Archive & ar,
const unsigned int version )

Read or write the data of this object to or from a stream for the purpose of serialization using the BOOST serialization library.

Friends And Related Symbol Documentation

◆ Tensor [1/2]

template<int dim, typename Number>
template<int, int, typename>
friend class Tensor
friend

Definition at line 391 of file tensor.h.

◆ sum() [1/2]

Tensor< rank, dim, Number > sum ( const Tensor< rank, dim, Number > & local,
const MPI_Comm mpi_communicator )
related

Perform an MPI sum of the entries of a tensor.

◆ operator<<() [1/4]

std::ostream & operator<< ( std::ostream & out,
const Tensor< rank_, dim, Number > & p )
related

Output operator for tensors. Print the elements consecutively, with a space in between, two spaces between rank 1 subtensors, three between rank 2 and so on.

Definition at line 1949 of file tensor.h.

◆ operator<<() [2/4]

std::ostream & operator<< ( std::ostream & out,
const Tensor< 0, dim, Number > & p )
related

Output operator for tensors of rank 0. Since such tensors are scalars, we simply print this one value.

Definition at line 1971 of file tensor.h.

◆ operator*() [1/12]

ProductType< Other, Number >::type operator* ( const Other & object,
const Tensor< 0, dim, Number > & t )
related

Scalar multiplication of a tensor of rank 0 with an object from the left.

This function unwraps the underlying Number stored in the Tensor and multiplies object with it.

Note
This function can also be used in device code.

Definition at line 2000 of file tensor.h.

◆ operator*() [2/12]

ProductType< Number, Other >::type operator* ( const Tensor< 0, dim, Number > & t,
const Other & object )
related

Scalar multiplication of a tensor of rank 0 with an object from the right.

This function unwraps the underlying Number stored in the Tensor and multiplies object with it.

Note
This function can also be used in device code.

Definition at line 2020 of file tensor.h.

◆ operator*() [3/12]

ProductType< Number, OtherNumber >::type operator* ( const Tensor< 0, dim, Number > & src1,
const Tensor< 0, dim, OtherNumber > & src2 )
related

Scalar multiplication of two tensors of rank 0.

This function unwraps the underlying objects of type Number and OtherNumber that are stored within the Tensor and multiplies them. It returns an unwrapped number of product type.

Note
This function can also be used in device code.

Definition at line 2040 of file tensor.h.

◆ operator/() [1/4]

Tensor< 0, dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator/ ( const Tensor< 0, dim, Number > & t,
const OtherNumber & factor )
related

Division of a tensor of rank 0 by a scalar number.

Note
This function can also be used in device code.

Definition at line 2061 of file tensor.h.

◆ operator+() [1/4]

DEAL_II_HOST_DEVICE_ALWAYS_INLINE Tensor< 0, dim, typename ProductType< Number, OtherNumber >::type > operator+ ( const Tensor< 0, dim, Number > & p,
const Tensor< 0, dim, OtherNumber > & q )
related

Add two tensors of rank 0.

Note
This function can also be used in device code.

Definition at line 2077 of file tensor.h.

◆ operator-() [1/4]

DEAL_II_HOST_DEVICE_ALWAYS_INLINE Tensor< 0, dim, typename ProductType< Number, OtherNumber >::type > operator- ( const Tensor< 0, dim, Number > & p,
const Tensor< 0, dim, OtherNumber > & q )
related

Subtract two tensors of rank 0.

Note
This function can also be used in device code.

Definition at line 2094 of file tensor.h.

◆ operator*() [4/12]

Tensor< rank, dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator* ( const Tensor< rank, dim, Number > & t,
const OtherNumber & factor )
related

Multiplication of a tensor of general rank with a scalar number from the right.

Only multiplication with a scalar number type (i.e., a floating point number, a complex floating point number, etc.) is allowed, see the documentation of EnableIfScalar for details.

Note
This function can also be used in device code.

Definition at line 2119 of file tensor.h.

◆ operator*() [5/12]

Tensor< rank, dim, typename ProductType< typename EnableIfScalar< Number >::type, OtherNumber >::type > operator* ( const Number & factor,
const Tensor< rank, dim, OtherNumber > & t )
related

Multiplication of a tensor of general rank with a scalar number from the left.

Only multiplication with a scalar number type (i.e., a floating point number, a complex floating point number, etc.) is allowed, see the documentation of EnableIfScalar for details.

Note
This function can also be used in device code.

Definition at line 2145 of file tensor.h.

◆ operator/() [2/4]

Tensor< rank, dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator/ ( const Tensor< rank, dim, Number > & t,
const OtherNumber & factor )
related

Division of a tensor of general rank with a scalar number. See the discussion on operator*() above for more information about template arguments and the return type.

Note
This function can also be used in device code.

Definition at line 2168 of file tensor.h.

◆ operator+() [2/4]

Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > operator+ ( const Tensor< rank, dim, Number > & p,
const Tensor< rank, dim, OtherNumber > & q )
related

Addition of two tensors of general rank.

Template Parameters
rankThe rank of both tensors.
Note
This function can also be used in device code.

Definition at line 2188 of file tensor.h.

◆ operator-() [2/4]

Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > operator- ( const Tensor< rank, dim, Number > & p,
const Tensor< rank, dim, OtherNumber > & q )
related

Subtraction of two tensors of general rank.

Template Parameters
rankThe rank of both tensors.
Note
This function can also be used in device code.

Definition at line 2209 of file tensor.h.

◆ schur_product() [1/4]

Tensor< 0, dim, typename ProductType< Number, OtherNumber >::type > schur_product ( const Tensor< 0, dim, Number > & src1,
const Tensor< 0, dim, OtherNumber > & src2 )
related

Entrywise multiplication of two tensor objects of rank 0 (i.e. the multiplication of two scalar values).

Definition at line 2226 of file tensor.h.

◆ schur_product() [2/4]

Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > schur_product ( const Tensor< rank, dim, Number > & src1,
const Tensor< rank, dim, OtherNumber > & src2 )
related

Entrywise multiplication of two tensor objects of general rank.

This multiplication is also called "Hadamard-product" (c.f. https://en.wikipedia.org/wiki/Hadamard_product_(matrices)), and generates a new tensor of size <rank, dim>:

\[  \text{result}_{i, j}
  = \text{left}_{i, j}\circ
    \text{right}_{i, j}
\]

Template Parameters
rankThe rank of both tensors.

Definition at line 2255 of file tensor.h.

◆ operator*() [6/12]

Tensor< rank_1+rank_2-2, dim, typenameProductType< Number, OtherNumber >::type >::tensor_type operator* ( const Tensor< rank_1, dim, Number > & src1,
const Tensor< rank_2, dim, OtherNumber > & src2 )
related

The dot product (single contraction) for tensors. This function return a tensor of rank $(\text{rank}_1 + \text{rank}_2 - 2)$ that is the contraction of the last index of a tensor src1 of rank rank_1 with the first index of a tensor src2 of rank rank_2:

\[  \text{result}_{i_1,\ldots,i_{r1},j_1,\ldots,j_{r2}}
  = \sum_{k}
    \text{left}_{i_1,\ldots,i_{r1}, k}
    \text{right}_{k, j_1,\ldots,j_{r2}}
\]

Note
For the Tensor class, the multiplication operator only performs a contraction over a single pair of indices. This is in contrast to the multiplication operator for SymmetricTensor, for which the corresponding operator*() performs a double contraction. The origin of the difference in how operator*() is implemented between Tensor and SymmetricTensor is that for the former, the product between two Tensor objects of same rank and dimension results in another Tensor object – that it, operator*() corresponds to the multiplicative group action within the group of tensors. On the other hand, there is no corresponding multiplicative group action with the set of symmetric tensors because, in general, the product of two symmetric tensors is a nonsymmetric tensor. As a consequence, for a mathematician, it is clear that operator*() for symmetric tensors must have a different meaning: namely the dot or scalar product that maps two symmetric tensors of rank 2 to a scalar. This corresponds to the double-dot (colon) operator whose meaning is then extended to the product of any two even-ranked symmetric tensors.
In case the contraction yields a tensor of rank 0, that is, if rank_1==rank_2==1, then a scalar number is returned as an unwrapped number type.

Definition at line 2321 of file tensor.h.

◆ contract() [1/2]

Tensor< rank_1+rank_2-2, dim, typenameProductType< Number, OtherNumber >::type >::tensor_type contract ( const Tensor< rank_1, dim, Number > & src1,
const Tensor< rank_2, dim, OtherNumber > & src2 )
related

Generic contraction of a pair of indices of two tensors of arbitrary rank: Return a tensor of rank $(\text{rank}_1 + \text{rank}_2 - 2)$ that is the contraction of index index_1 of a tensor src1 of rank rank_1 with the index index_2 of a tensor src2 of rank rank_2:

\[  \text{result}_{i_1,\ldots,i_{r1},j_1,\ldots,j_{r2}}
  = \sum_{k}
    \text{left}_{i_1,\ldots,k,\ldots,i_{r1}}
    \text{right}_{j_1,\ldots,k,\ldots,j_{r2}}
\]

If for example the first index (index_1==0) of a tensor t1 shall be contracted with the third index (index_2==2) of a tensor t2, this function should be invoked as

constexpr Tensor< rank_1+rank_2-2, dim, typenameProductType< Number, OtherNumber >::type >::tensor_type contract(const Tensor< rank_1, dim, Number > &src1, const Tensor< rank_2, dim, OtherNumber > &src2)
Definition tensor.h:2415
Note
The position of the index is counted from 0, i.e., $0\le\text{index}_i<\text{range}_i$.
In case the contraction yields a tensor of rank 0 the scalar number is returned as an unwrapped number type.

Definition at line 2415 of file tensor.h.

◆ double_contract() [1/2]

Tensor< rank_1+rank_2-4, dim, typenameProductType< Number, OtherNumber >::type >::tensor_type double_contract ( const Tensor< rank_1, dim, Number > & src1,
const Tensor< rank_2, dim, OtherNumber > & src2 )
related

Generic contraction of two pairs of indices of two tensors of arbitrary rank: Return a tensor of rank $(\text{rank}_1 + \text{rank}_2 - 4)$ that is the contraction of index index_1 with index index_2, and index index_3 with index index_4 of a tensor src1 of rank rank_1 and a tensor src2 of rank rank_2:

\[  \text{result}_{i_1,\ldots,i_{r1},j_1,\ldots,j_{r2}}
  = \sum_{k, l}
    \text{left}_{i_1,\ldots,k,\ldots,l,\ldots,i_{r1}}
    \text{right}_{j_1,\ldots,k,\ldots,l\ldots,j_{r2}}
\]

If for example the first index (index_1==0) shall be contracted with the third index (index_2==2), and the second index (index_3==1) with the first index (index_4==0) of a tensor t2, this function should be invoked as

constexpr Tensor< rank_1+rank_2-4, dim, typenameProductType< Number, OtherNumber >::type >::tensor_type double_contract(const Tensor< rank_1, dim, Number > &src1, const Tensor< rank_2, dim, OtherNumber > &src2)
Definition tensor.h:2490
Note
The position of the index is counted from 0, i.e., $0\le\text{index}_i<\text{range}_i$.
In case the contraction yields a tensor of rank 0 the scalar number is returned as an unwrapped number type.

Definition at line 2490 of file tensor.h.

◆ scalar_product() [1/2]

ProductType< Number, OtherNumber >::type scalar_product ( const Tensor< rank, dim, Number > & left,
const Tensor< rank, dim, OtherNumber > & right )
related

The scalar product, or (generalized) Frobenius inner product of two tensors of equal rank: Return a scalar number that is the result of a full contraction of a tensor left and right:

\[  \sum_{i_1,\ldots,i_r}
  \text{left}_{i_1,\ldots,i_r}
  \text{right}_{i_1,\ldots,i_r}
\]

Definition at line 2569 of file tensor.h.

◆ contract3() [1/2]

ProductType< T1, typenameProductType< T2, T3 >::type >::type contract3 ( const TensorT1< rank_1, dim, T1 > & left,
const TensorT2< rank_1+rank_2, dim, T2 > & middle,
const TensorT3< rank_2, dim, T3 > & right )
related

Full contraction of three tensors: Return a scalar number that is the result of a full contraction of a tensor left of rank rank_1, a tensor middle of rank $(\text{rank}_1+\text{rank}_2)$ and a tensor right of rank rank_2:

\[  \sum_{i_1,\ldots,i_{r1},j_1,\ldots,j_{r2}}
  \text{left}_{i_1,\ldots,i_{r1}}
  \text{middle}_{i_1,\ldots,i_{r1},j_1,\ldots,j_{r2}}
  \text{right}_{j_1,\ldots,j_{r2}}
\]

Note
Each of the three input tensors can be either a Tensor or SymmetricTensor.

Definition at line 2608 of file tensor.h.

◆ outer_product() [1/2]

Tensor< rank_1+rank_2, dim, typename ProductType< Number, OtherNumber >::type > outer_product ( const Tensor< rank_1, dim, Number > & src1,
const Tensor< rank_2, dim, OtherNumber > & src2 )
related

The outer product of two tensors of rank_1 and rank_2: Returns a tensor of rank $(\text{rank}_1 + \text{rank}_2)$:

\[  \text{result}_{i_1,\ldots,i_{r1},j_1,\ldots,j_{r2}}
  = \text{left}_{i_1,\ldots,i_{r1}}\,\text{right}_{j_1,\ldots,j_{r2}.}
\]

Definition at line 2637 of file tensor.h.

◆ cross_product_2d() [1/2]

Tensor< 1, dim, Number > cross_product_2d ( const Tensor< 1, dim, Number > & src)
related

Return the cross product in 2d. This is just a rotation by 90 degrees clockwise to compute the outer normal from a tangential vector. This function is defined for all space dimensions to allow for dimension independent programming (e.g. within switches over the space dimension), but may only be called if the actual dimension of the arguments is two (e.g. from the dim==2 case in the switch).

Definition at line 2669 of file tensor.h.

◆ cross_product_3d() [1/2]

Tensor< 1, dim, typename ProductType< Number1, Number2 >::type > cross_product_3d ( const Tensor< 1, dim, Number1 > & src1,
const Tensor< 1, dim, Number2 > & src2 )
related

Return the cross product of 2 vectors in 3d. This function is defined for all space dimensions to allow for dimension independent programming (e.g. within switches over the space dimension), but may only be called if the actual dimension of the arguments is three (e.g. from the dim==3 case in the switch).

Definition at line 2694 of file tensor.h.

◆ determinant() [1/8]

Number determinant ( const Tensor< 2, dim, Number > & t)
related

Compute the determinant of a tensor or rank 2.

Definition at line 2729 of file tensor.h.

◆ determinant() [2/8]

Number determinant ( const Tensor< 2, 1, Number > & t)
related

Specialization for dim==1.

Definition at line 2757 of file tensor.h.

◆ determinant() [3/8]

Number determinant ( const Tensor< 2, 2, Number > & t)
related

Specialization for dim==2.

Definition at line 2769 of file tensor.h.

◆ determinant() [4/8]

Number determinant ( const Tensor< 2, 3, Number > & t)
related

Specialization for dim==3.

Definition at line 2782 of file tensor.h.

◆ trace() [1/2]

Number trace ( const Tensor< 2, dim, Number > & d)
related

Compute and return the trace of a tensor of rank 2, i.e. the sum of its diagonal entries.

Definition at line 2803 of file tensor.h.

◆ invert() [1/2]

Tensor< 2, dim, Number > invert ( const Tensor< 2, dim, Number > & )
related

Compute and return the inverse of the given tensor. Since the compiler can perform the return value optimization, and since the size of the return object is known, it is acceptable to return the result by value, rather than by reference as a parameter.

Definition at line 2822 of file tensor.h.

◆ transpose() [1/2]

Tensor< 2, dim, Number > transpose ( const Tensor< 2, dim, Number > & t)
related

Return the transpose of the given tensor.

Definition at line 2904 of file tensor.h.

◆ adjugate() [1/2]

Tensor< 2, dim, Number > adjugate ( const Tensor< 2, dim, Number > & t)
related

Return the adjugate of the given tensor of rank 2. The adjugate of a tensor $\mathbf A$ is defined as

\[ \textrm{adj}\mathbf A
  \dealcoloneq \textrm{det}\mathbf A \; \mathbf{A}^{-1}
\; .
\]

Note
This requires that the tensor is invertible.

Definition at line 2935 of file tensor.h.

◆ cofactor() [1/2]

Tensor< 2, dim, Number > cofactor ( const Tensor< 2, dim, Number > & t)
related

Return the cofactor of the given tensor of rank 2. The cofactor of a tensor $\mathbf A$ is defined as

\[ \textrm{cof}\mathbf A
  \dealcoloneq \textrm{det}\mathbf A \; \mathbf{A}^{-T}
   = \left[ \textrm{adj}\mathbf A \right]^{T} \; .
\]

Note
This requires that the tensor is invertible.

Definition at line 2956 of file tensor.h.

◆ project_onto_orthogonal_tensors() [1/2]

Tensor< 2, dim, Number > project_onto_orthogonal_tensors ( const Tensor< 2, dim, Number > & A)
related

Return the nearest orthogonal matrix $\hat {\mathbf A}=\mathbf U \mathbf{V}^T$ by combining the products of the singular value decomposition (SVD) ${\mathbf A}=\mathbf U  \mathbf S \mathbf V^T$ for a given input ${\mathbf A}$, effectively replacing $\mathbf S$ with the identity matrix.

This is a (nonlinear) projection operation since when applied twice, we have $\hat{\hat{\mathbf A}}=\hat{\mathbf A}$ as is easy to see. (That is because the SVD of $\hat {\mathbf A}$ is simply $\mathbf U \mathbf I \mathbf{V}^T$.) Furthermore, $\hat {\mathbf A}$ is really an orthogonal matrix because orthogonal matrices have to satisfy ${\hat {\mathbf A}}^T \hat {\mathbf A}={\mathbf I}$, which here implies that

\begin{align*}  {\hat {\mathbf A}}^T \hat {\mathbf A}
  &=
  \left(\mathbf U \mathbf{V}^T\right)^T\left(\mathbf U \mathbf{V}^T\right)
  \\
  &=
  \mathbf V \mathbf{U}^T
  \mathbf U \mathbf{V}^T
  \\
  &=
  \mathbf V \left(\mathbf{U}^T
  \mathbf U\right) \mathbf{V}^T
  \\
  &=
  \mathbf V \mathbf I \mathbf{V}^T
  \\
  &=
  \mathbf V \mathbf{V}^T
  \\
  &=
  \mathbf I
\end{align*}

due to the fact that the $\mathbf U$ and $\mathbf V$ factors that come out of the SVD are themselves orthogonal matrices.

Parameters
AThe tensor for which to find the closest orthogonal tensor.
Template Parameters
NumberThe type used to store the entries of the tensor. Must be either float or double.
Precondition
In order to use this function, this program must be linked with the LAPACK library.
A must not be singular. This is because, conceptually, the problem to be solved here is trying to find a matrix $\hat{\mathbf A}$ that minimizes some kind of distance from $\mathbf A$ while satisfying the quadratic constraint ${\hat {\mathbf A}}^T \hat {\mathbf A}={\mathbf I}$. This is not so dissimilar to the kind of problem where one wants to find a vector $\hat{\mathbf x}\in{\mathbb R}^n$ that minimizes the quadratic objective function $\|\hat {\mathbf x} - \mathbf x\|^2$ for a given $\mathbf x$ subject to the constraint $\|\mathbf x\|^2=1$ – in other words, we are seeking the point $\hat{\mathbf x}$ on the unit sphere that is closest to $\mathbf x$. This problem has a solution for all $\mathbf x$ except if $\mathbf x=0$. The corresponding condition for the problem we are considering here is that $\mathbf A$ must not have a zero eigenvalue.

◆ l1_norm() [1/2]

Number l1_norm ( const Tensor< 2, dim, Number > & t)
related

Return the $l_1$ norm of the given rank-2 tensor, where $\|\mathbf T\|_1 = \max_j \sum_i |T_{ij}|$ (maximum of the sums over columns).

Definition at line 3039 of file tensor.h.

◆ linfty_norm() [1/2]

Number linfty_norm ( const Tensor< 2, dim, Number > & t)
related

Return the $l_\infty$ norm of the given rank-2 tensor, where $\|\mathbf T\|_\infty = \max_i \sum_j |T_{ij}|$ (maximum of the sums over rows).

Definition at line 3065 of file tensor.h.

◆ Tensor [2/2]

friend class Tensor
friend

Definition at line 882 of file tensor.h.

◆ Point< dim, Number >

friend class Point< dim, Number >
friend

Definition at line 882 of file tensor.h.

◆ operator-() [3/4]

DEAL_II_HOST_DEVICE_ALWAYS_INLINE Tensor< 0, dim, typename ProductType< Number, OtherNumber >::type > operator- ( const Tensor< 0, dim, Number > & p,
const Tensor< 0, dim, OtherNumber > & q )
related

Subtract two tensors of rank 0.

Note
This function can also be used in device code.

Definition at line 2094 of file tensor.h.

◆ operator-() [4/4]

Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > operator- ( const Tensor< rank, dim, Number > & p,
const Tensor< rank, dim, OtherNumber > & q )
related

Subtraction of two tensors of general rank.

Template Parameters
rankThe rank of both tensors.
Note
This function can also be used in device code.

Definition at line 2209 of file tensor.h.

◆ sum() [2/2]

Tensor< rank, dim, Number > sum ( const Tensor< rank, dim, Number > & local,
const MPI_Comm mpi_communicator )
related

Perform an MPI sum of the entries of a tensor.

◆ operator<<() [3/4]

std::ostream & operator<< ( std::ostream & out,
const Tensor< rank_, dim, Number > & p )
related

Output operator for tensors. Print the elements consecutively, with a space in between, two spaces between rank 1 subtensors, three between rank 2 and so on.

Definition at line 1949 of file tensor.h.

◆ operator<<() [4/4]

std::ostream & operator<< ( std::ostream & out,
const Tensor< 0, dim, Number > & p )
related

Output operator for tensors of rank 0. Since such tensors are scalars, we simply print this one value.

Definition at line 1971 of file tensor.h.

◆ operator*() [7/12]

ProductType< Other, Number >::type operator* ( const Other & object,
const Tensor< 0, dim, Number > & t )
related

Scalar multiplication of a tensor of rank 0 with an object from the left.

This function unwraps the underlying Number stored in the Tensor and multiplies object with it.

Note
This function can also be used in device code.

Definition at line 2000 of file tensor.h.

◆ operator*() [8/12]

ProductType< Number, Other >::type operator* ( const Tensor< 0, dim, Number > & t,
const Other & object )
related

Scalar multiplication of a tensor of rank 0 with an object from the right.

This function unwraps the underlying Number stored in the Tensor and multiplies object with it.

Note
This function can also be used in device code.

Definition at line 2020 of file tensor.h.

◆ operator*() [9/12]

ProductType< Number, OtherNumber >::type operator* ( const Tensor< 0, dim, Number > & src1,
const Tensor< 0, dim, OtherNumber > & src2 )
related

Scalar multiplication of two tensors of rank 0.

This function unwraps the underlying objects of type Number and OtherNumber that are stored within the Tensor and multiplies them. It returns an unwrapped number of product type.

Note
This function can also be used in device code.

Definition at line 2040 of file tensor.h.

◆ operator*() [10/12]

Tensor< rank, dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator* ( const Tensor< rank, dim, Number > & t,
const OtherNumber & factor )
related

Multiplication of a tensor of general rank with a scalar number from the right.

Only multiplication with a scalar number type (i.e., a floating point number, a complex floating point number, etc.) is allowed, see the documentation of EnableIfScalar for details.

Note
This function can also be used in device code.

Definition at line 2119 of file tensor.h.

◆ operator*() [11/12]

Tensor< rank, dim, typename ProductType< typename EnableIfScalar< Number >::type, OtherNumber >::type > operator* ( const Number & factor,
const Tensor< rank, dim, OtherNumber > & t )
related

Multiplication of a tensor of general rank with a scalar number from the left.

Only multiplication with a scalar number type (i.e., a floating point number, a complex floating point number, etc.) is allowed, see the documentation of EnableIfScalar for details.

Note
This function can also be used in device code.

Definition at line 2145 of file tensor.h.

◆ operator*() [12/12]

Tensor< rank_1+rank_2-2, dim, typenameProductType< Number, OtherNumber >::type >::tensor_type operator* ( const Tensor< rank_1, dim, Number > & src1,
const Tensor< rank_2, dim, OtherNumber > & src2 )
related

The dot product (single contraction) for tensors. This function return a tensor of rank $(\text{rank}_1 + \text{rank}_2 - 2)$ that is the contraction of the last index of a tensor src1 of rank rank_1 with the first index of a tensor src2 of rank rank_2:

\[  \text{result}_{i_1,\ldots,i_{r1},j_1,\ldots,j_{r2}}
  = \sum_{k}
    \text{left}_{i_1,\ldots,i_{r1}, k}
    \text{right}_{k, j_1,\ldots,j_{r2}}
\]

Note
For the Tensor class, the multiplication operator only performs a contraction over a single pair of indices. This is in contrast to the multiplication operator for SymmetricTensor, for which the corresponding operator*() performs a double contraction. The origin of the difference in how operator*() is implemented between Tensor and SymmetricTensor is that for the former, the product between two Tensor objects of same rank and dimension results in another Tensor object – that it, operator*() corresponds to the multiplicative group action within the group of tensors. On the other hand, there is no corresponding multiplicative group action with the set of symmetric tensors because, in general, the product of two symmetric tensors is a nonsymmetric tensor. As a consequence, for a mathematician, it is clear that operator*() for symmetric tensors must have a different meaning: namely the dot or scalar product that maps two symmetric tensors of rank 2 to a scalar. This corresponds to the double-dot (colon) operator whose meaning is then extended to the product of any two even-ranked symmetric tensors.
In case the contraction yields a tensor of rank 0, that is, if rank_1==rank_2==1, then a scalar number is returned as an unwrapped number type.

Definition at line 2321 of file tensor.h.

◆ operator/() [3/4]

Tensor< 0, dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator/ ( const Tensor< 0, dim, Number > & t,
const OtherNumber & factor )
related

Division of a tensor of rank 0 by a scalar number.

Note
This function can also be used in device code.

Definition at line 2061 of file tensor.h.

◆ operator/() [4/4]

Tensor< rank, dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator/ ( const Tensor< rank, dim, Number > & t,
const OtherNumber & factor )
related

Division of a tensor of general rank with a scalar number. See the discussion on operator*() above for more information about template arguments and the return type.

Note
This function can also be used in device code.

Definition at line 2168 of file tensor.h.

◆ operator+() [3/4]

DEAL_II_HOST_DEVICE_ALWAYS_INLINE Tensor< 0, dim, typename ProductType< Number, OtherNumber >::type > operator+ ( const Tensor< 0, dim, Number > & p,
const Tensor< 0, dim, OtherNumber > & q )
related

Add two tensors of rank 0.

Note
This function can also be used in device code.

Definition at line 2077 of file tensor.h.

◆ operator+() [4/4]

Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > operator+ ( const Tensor< rank, dim, Number > & p,
const Tensor< rank, dim, OtherNumber > & q )
related

Addition of two tensors of general rank.

Template Parameters
rankThe rank of both tensors.
Note
This function can also be used in device code.

Definition at line 2188 of file tensor.h.

◆ schur_product() [3/4]

Tensor< 0, dim, typename ProductType< Number, OtherNumber >::type > schur_product ( const Tensor< 0, dim, Number > & src1,
const Tensor< 0, dim, OtherNumber > & src2 )
related

Entrywise multiplication of two tensor objects of rank 0 (i.e. the multiplication of two scalar values).

Definition at line 2226 of file tensor.h.

◆ schur_product() [4/4]

Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > schur_product ( const Tensor< rank, dim, Number > & src1,
const Tensor< rank, dim, OtherNumber > & src2 )
related

Entrywise multiplication of two tensor objects of general rank.

This multiplication is also called "Hadamard-product" (c.f. https://en.wikipedia.org/wiki/Hadamard_product_(matrices)), and generates a new tensor of size <rank, dim>:

\[  \text{result}_{i, j}
  = \text{left}_{i, j}\circ
    \text{right}_{i, j}
\]

Template Parameters
rankThe rank of both tensors.

Definition at line 2255 of file tensor.h.

◆ contract() [2/2]

Tensor< rank_1+rank_2-2, dim, typenameProductType< Number, OtherNumber >::type >::tensor_type contract ( const Tensor< rank_1, dim, Number > & src1,
const Tensor< rank_2, dim, OtherNumber > & src2 )
related

Generic contraction of a pair of indices of two tensors of arbitrary rank: Return a tensor of rank $(\text{rank}_1 + \text{rank}_2 - 2)$ that is the contraction of index index_1 of a tensor src1 of rank rank_1 with the index index_2 of a tensor src2 of rank rank_2:

\[  \text{result}_{i_1,\ldots,i_{r1},j_1,\ldots,j_{r2}}
  = \sum_{k}
    \text{left}_{i_1,\ldots,k,\ldots,i_{r1}}
    \text{right}_{j_1,\ldots,k,\ldots,j_{r2}}
\]

If for example the first index (index_1==0) of a tensor t1 shall be contracted with the third index (index_2==2) of a tensor t2, this function should be invoked as

Note
The position of the index is counted from 0, i.e., $0\le\text{index}_i<\text{range}_i$.
In case the contraction yields a tensor of rank 0 the scalar number is returned as an unwrapped number type.

Definition at line 2415 of file tensor.h.

◆ double_contract() [2/2]

Tensor< rank_1+rank_2-4, dim, typenameProductType< Number, OtherNumber >::type >::tensor_type double_contract ( const Tensor< rank_1, dim, Number > & src1,
const Tensor< rank_2, dim, OtherNumber > & src2 )
related

Generic contraction of two pairs of indices of two tensors of arbitrary rank: Return a tensor of rank $(\text{rank}_1 + \text{rank}_2 - 4)$ that is the contraction of index index_1 with index index_2, and index index_3 with index index_4 of a tensor src1 of rank rank_1 and a tensor src2 of rank rank_2:

\[  \text{result}_{i_1,\ldots,i_{r1},j_1,\ldots,j_{r2}}
  = \sum_{k, l}
    \text{left}_{i_1,\ldots,k,\ldots,l,\ldots,i_{r1}}
    \text{right}_{j_1,\ldots,k,\ldots,l\ldots,j_{r2}}
\]

If for example the first index (index_1==0) shall be contracted with the third index (index_2==2), and the second index (index_3==1) with the first index (index_4==0) of a tensor t2, this function should be invoked as

Note
The position of the index is counted from 0, i.e., $0\le\text{index}_i<\text{range}_i$.
In case the contraction yields a tensor of rank 0 the scalar number is returned as an unwrapped number type.

Definition at line 2490 of file tensor.h.

◆ scalar_product() [2/2]

ProductType< Number, OtherNumber >::type scalar_product ( const Tensor< rank, dim, Number > & left,
const Tensor< rank, dim, OtherNumber > & right )
related

The scalar product, or (generalized) Frobenius inner product of two tensors of equal rank: Return a scalar number that is the result of a full contraction of a tensor left and right:

\[  \sum_{i_1,\ldots,i_r}
  \text{left}_{i_1,\ldots,i_r}
  \text{right}_{i_1,\ldots,i_r}
\]

Definition at line 2569 of file tensor.h.

◆ contract3() [2/2]

ProductType< T1, typenameProductType< T2, T3 >::type >::type contract3 ( const TensorT1< rank_1, dim, T1 > & left,
const TensorT2< rank_1+rank_2, dim, T2 > & middle,
const TensorT3< rank_2, dim, T3 > & right )
related

Full contraction of three tensors: Return a scalar number that is the result of a full contraction of a tensor left of rank rank_1, a tensor middle of rank $(\text{rank}_1+\text{rank}_2)$ and a tensor right of rank rank_2:

\[  \sum_{i_1,\ldots,i_{r1},j_1,\ldots,j_{r2}}
  \text{left}_{i_1,\ldots,i_{r1}}
  \text{middle}_{i_1,\ldots,i_{r1},j_1,\ldots,j_{r2}}
  \text{right}_{j_1,\ldots,j_{r2}}
\]

Note
Each of the three input tensors can be either a Tensor or SymmetricTensor.

Definition at line 2608 of file tensor.h.

◆ outer_product() [2/2]

Tensor< rank_1+rank_2, dim, typename ProductType< Number, OtherNumber >::type > outer_product ( const Tensor< rank_1, dim, Number > & src1,
const Tensor< rank_2, dim, OtherNumber > & src2 )
related

The outer product of two tensors of rank_1 and rank_2: Returns a tensor of rank $(\text{rank}_1 + \text{rank}_2)$:

\[  \text{result}_{i_1,\ldots,i_{r1},j_1,\ldots,j_{r2}}
  = \text{left}_{i_1,\ldots,i_{r1}}\,\text{right}_{j_1,\ldots,j_{r2}.}
\]

Definition at line 2637 of file tensor.h.

◆ cross_product_2d() [2/2]

Tensor< 1, dim, Number > cross_product_2d ( const Tensor< 1, dim, Number > & src)
related

Return the cross product in 2d. This is just a rotation by 90 degrees clockwise to compute the outer normal from a tangential vector. This function is defined for all space dimensions to allow for dimension independent programming (e.g. within switches over the space dimension), but may only be called if the actual dimension of the arguments is two (e.g. from the dim==2 case in the switch).

Definition at line 2669 of file tensor.h.

◆ cross_product_3d() [2/2]

Tensor< 1, dim, typename ProductType< Number1, Number2 >::type > cross_product_3d ( const Tensor< 1, dim, Number1 > & src1,
const Tensor< 1, dim, Number2 > & src2 )
related

Return the cross product of 2 vectors in 3d. This function is defined for all space dimensions to allow for dimension independent programming (e.g. within switches over the space dimension), but may only be called if the actual dimension of the arguments is three (e.g. from the dim==3 case in the switch).

Definition at line 2694 of file tensor.h.

◆ determinant() [5/8]

Number determinant ( const Tensor< 2, dim, Number > & t)
related

Compute the determinant of a tensor or rank 2.

Definition at line 2729 of file tensor.h.

◆ determinant() [6/8]

Number determinant ( const Tensor< 2, 1, Number > & t)
related

Specialization for dim==1.

Definition at line 2757 of file tensor.h.

◆ determinant() [7/8]

Number determinant ( const Tensor< 2, 2, Number > & t)
related

Specialization for dim==2.

Definition at line 2769 of file tensor.h.

◆ determinant() [8/8]

Number determinant ( const Tensor< 2, 3, Number > & t)
related

Specialization for dim==3.

Definition at line 2782 of file tensor.h.

◆ trace() [2/2]

Number trace ( const Tensor< 2, dim, Number > & d)
related

Compute and return the trace of a tensor of rank 2, i.e. the sum of its diagonal entries.

Definition at line 2803 of file tensor.h.

◆ invert() [2/2]

Tensor< 2, dim, Number > invert ( const Tensor< 2, dim, Number > & )
related

Compute and return the inverse of the given tensor. Since the compiler can perform the return value optimization, and since the size of the return object is known, it is acceptable to return the result by value, rather than by reference as a parameter.

Definition at line 2822 of file tensor.h.

◆ transpose() [2/2]

Tensor< 2, dim, Number > transpose ( const Tensor< 2, dim, Number > & t)
related

Return the transpose of the given tensor.

Definition at line 2904 of file tensor.h.

◆ adjugate() [2/2]

Tensor< 2, dim, Number > adjugate ( const Tensor< 2, dim, Number > & t)
related

Return the adjugate of the given tensor of rank 2. The adjugate of a tensor $\mathbf A$ is defined as

\[ \textrm{adj}\mathbf A
  \dealcoloneq \textrm{det}\mathbf A \; \mathbf{A}^{-1}
\; .
\]

Note
This requires that the tensor is invertible.

Definition at line 2935 of file tensor.h.

◆ cofactor() [2/2]

Tensor< 2, dim, Number > cofactor ( const Tensor< 2, dim, Number > & t)
related

Return the cofactor of the given tensor of rank 2. The cofactor of a tensor $\mathbf A$ is defined as

\[ \textrm{cof}\mathbf A
  \dealcoloneq \textrm{det}\mathbf A \; \mathbf{A}^{-T}
   = \left[ \textrm{adj}\mathbf A \right]^{T} \; .
\]

Note
This requires that the tensor is invertible.

Definition at line 2956 of file tensor.h.

◆ project_onto_orthogonal_tensors() [2/2]

Tensor< 2, dim, Number > project_onto_orthogonal_tensors ( const Tensor< 2, dim, Number > & A)
related

Return the nearest orthogonal matrix $\hat {\mathbf A}=\mathbf U \mathbf{V}^T$ by combining the products of the singular value decomposition (SVD) ${\mathbf A}=\mathbf U  \mathbf S \mathbf V^T$ for a given input ${\mathbf A}$, effectively replacing $\mathbf S$ with the identity matrix.

This is a (nonlinear) projection operation since when applied twice, we have $\hat{\hat{\mathbf A}}=\hat{\mathbf A}$ as is easy to see. (That is because the SVD of $\hat {\mathbf A}$ is simply $\mathbf U \mathbf I \mathbf{V}^T$.) Furthermore, $\hat {\mathbf A}$ is really an orthogonal matrix because orthogonal matrices have to satisfy ${\hat {\mathbf A}}^T \hat {\mathbf A}={\mathbf I}$, which here implies that

\begin{align*}  {\hat {\mathbf A}}^T \hat {\mathbf A}
  &=
  \left(\mathbf U \mathbf{V}^T\right)^T\left(\mathbf U \mathbf{V}^T\right)
  \\
  &=
  \mathbf V \mathbf{U}^T
  \mathbf U \mathbf{V}^T
  \\
  &=
  \mathbf V \left(\mathbf{U}^T
  \mathbf U\right) \mathbf{V}^T
  \\
  &=
  \mathbf V \mathbf I \mathbf{V}^T
  \\
  &=
  \mathbf V \mathbf{V}^T
  \\
  &=
  \mathbf I
\end{align*}

due to the fact that the $\mathbf U$ and $\mathbf V$ factors that come out of the SVD are themselves orthogonal matrices.

Parameters
AThe tensor for which to find the closest orthogonal tensor.
Template Parameters
NumberThe type used to store the entries of the tensor. Must be either float or double.
Precondition
In order to use this function, this program must be linked with the LAPACK library.
A must not be singular. This is because, conceptually, the problem to be solved here is trying to find a matrix $\hat{\mathbf A}$ that minimizes some kind of distance from $\mathbf A$ while satisfying the quadratic constraint ${\hat {\mathbf A}}^T \hat {\mathbf A}={\mathbf I}$. This is not so dissimilar to the kind of problem where one wants to find a vector $\hat{\mathbf x}\in{\mathbb R}^n$ that minimizes the quadratic objective function $\|\hat {\mathbf x} - \mathbf x\|^2$ for a given $\mathbf x$ subject to the constraint $\|\mathbf x\|^2=1$ – in other words, we are seeking the point $\hat{\mathbf x}$ on the unit sphere that is closest to $\mathbf x$. This problem has a solution for all $\mathbf x$ except if $\mathbf x=0$. The corresponding condition for the problem we are considering here is that $\mathbf A$ must not have a zero eigenvalue.

◆ l1_norm() [2/2]

Number l1_norm ( const Tensor< 2, dim, Number > & t)
related

Return the $l_1$ norm of the given rank-2 tensor, where $\|\mathbf T\|_1 = \max_j \sum_i |T_{ij}|$ (maximum of the sums over columns).

Definition at line 3039 of file tensor.h.

◆ linfty_norm() [2/2]

Number linfty_norm ( const Tensor< 2, dim, Number > & t)
related

Return the $l_\infty$ norm of the given rank-2 tensor, where $\|\mathbf T\|_\infty = \max_i \sum_j |T_{ij}|$ (maximum of the sums over rows).

Definition at line 3065 of file tensor.h.

Member Data Documentation

◆ dimension [1/2]

template<int dim, typename Number>
unsigned int Tensor< 0, dim, Number >::dimension = dim
staticconstexpr

Provide a way to get the dimension of an object without explicit knowledge of it's data type. Implementation is this way instead of providing a function dimension() because now it is possible to get the dimension at compile time without the expansion and preevaluation of an inlined function; the compiler may therefore produce more efficient code and you may use this value to declare other data types.

Definition at line 117 of file tensor.h.

◆ rank [1/2]

template<int dim, typename Number>
unsigned int Tensor< 0, dim, Number >::rank = 0
staticconstexpr

Publish the rank of this tensor to the outside world.

Definition at line 122 of file tensor.h.

◆ n_independent_components [1/2]

template<int dim, typename Number>
unsigned int Tensor< 0, dim, Number >::n_independent_components = 1
staticconstexpr

Number of independent components of a tensor of rank 0.

Definition at line 127 of file tensor.h.

◆ value

template<int dim, typename Number>
Number Tensor< 0, dim, Number >::value
private

The value of this scalar object.

Definition at line 387 of file tensor.h.

◆ dimension [2/2]

unsigned int Tensor< rank_, dim, Number >::dimension
staticconstexpr

Provide a way to get the dimension of an object without explicit knowledge of it's data type. Implementation is this way instead of providing a function dimension() because now it is possible to get the dimension at compile time without the expansion and preevaluation of an inlined function; the compiler may therefore produce more efficient code and you may use this value to declare other data types.

Definition at line 485 of file tensor.h.

◆ rank [2/2]

unsigned int Tensor< rank_, dim, Number >::rank
staticconstexpr

Publish the rank of this tensor to the outside world.

Definition at line 490 of file tensor.h.

◆ n_independent_components [2/2]

unsigned int Tensor< rank_, dim, Number >::n_independent_components
staticconstexpr

Number of independent components of a tensor of current rank. This is dim times the number of independent components of each sub-tensor, which equates to dim^rank.

This number can be used to loop over all of the entries of a tensor, using the unrolled_to_component_indices() function:

// Fill a tensor of arbitrary rank with ones:
for (unsigned int i=0; i<Tensor<rank,dim>::n_independent_components; ++i)
friend class Tensor
Definition tensor.h:391
static constexpr TableIndices< rank_ > unrolled_to_component_indices(const unsigned int i)

Definition at line 506 of file tensor.h.

◆ values

std::conditional_t<rank_ == 1, std::array<Number, dim>, std::array<Tensor<rank_ - 1, dim, Number>, dim> > Tensor< rank_, dim, Number >::values
private

Array of tensors holding the elements of the tensor. If this is a rank-1 tensor, then we simply need an array of scalars. Otherwise, it is an array of tensors one rank lower.

Definition at line 868 of file tensor.h.


The documentation for this class was generated from the following files: