|
| Tensor () |
|
template<typename OtherNumber > |
| Tensor (const Tensor< 0, dim, OtherNumber > &initializer) |
|
template<typename OtherNumber > |
| Tensor (const OtherNumber &initializer) |
|
Number * | begin_raw () |
|
constexpr const Number * | begin_raw () const |
|
Number * | end_raw () |
|
constexpr const Number * | end_raw () const |
|
| operator Number & () |
|
| operator const Number & () const |
|
template<typename OtherNumber > |
Tensor & | operator= (const Tensor< 0, dim, OtherNumber > &rhs) |
|
template<typename OtherNumber > |
Tensor & | operator= (const OtherNumber &d) |
|
template<typename OtherNumber > |
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 > |
Tensor & | operator+= (const Tensor< 0, dim, OtherNumber > &rhs) |
|
template<typename OtherNumber > |
Tensor & | operator-= (const Tensor< 0, dim, OtherNumber > &rhs) |
|
template<typename OtherNumber > |
Tensor & | operator*= (const OtherNumber &factor) |
|
template<typename OtherNumber > |
Tensor & | operator/= (const OtherNumber &factor) |
|
constexpr Tensor | operator- () const |
|
void | clear () |
|
real_type | norm () const |
|
real_type | norm_square () const |
|
template<class Archive > |
void | serialize (Archive &ar, const unsigned int version) |
|
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
-
dim | An 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. |
Number | The 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. |
- Author
- Wolfgang Bangerth, 2009, Matthias Maier, 2015
Definition at line 94 of file tensor.h.
template<int dim, typename Number >
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 125 of file tensor.h.
template<int dim, typename Number >
Tensor< 0, dim, Number >::operator Number & |
( |
| ) |
|
|
inline |
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 CUDA device code.
Definition at line 826 of file tensor.h.
template<int dim, typename Number >
Tensor< 0, dim, Number >::operator const Number & |
( |
| ) |
const |
|
inline |
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 CUDA device code.
Definition at line 839 of file tensor.h.
template<int dim, typename Number >
void Tensor< 0, dim, Number >::clear |
( |
| ) |
|
|
inline |
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 a virginial 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.
Definition at line 1019 of file tensor.h.