![]() |
Reference documentation for deal.II version 8.1.0
|
#include <tensor_base.h>
Public Types | |
typedef Number | value_type |
typedef numbers::NumberTraits < Number >::real_type | real_type |
Public Member Functions | |
Tensor () | |
Tensor (const value_type &initializer) | |
Tensor (const Tensor< 0, dim, Number > &) | |
operator Number () const | |
operator Number & () | |
Tensor< 0, dim, Number > & | operator= (const Tensor< 0, dim, Number > &) |
Tensor< 0, dim, Number > & | operator= (const Number d) |
bool | operator== (const Tensor< 0, dim, Number > &) const |
bool | operator!= (const Tensor< 0, dim, Number > &) const |
Tensor< 0, dim, Number > & | operator+= (const Tensor< 0, dim, Number > &) |
Tensor< 0, dim, Number > & | operator-= (const Tensor< 0, dim, Number > &) |
Tensor< 0, dim, Number > & | operator*= (const Number factor) |
Tensor< 0, dim, Number > & | operator/= (const Number factor) |
Number | operator* (const Tensor< 0, dim, Number > &) const |
Tensor< 0, dim, Number > | operator+ (const Tensor< 0, dim, Number > &) const |
Tensor< 0, dim, Number > | operator- (const Tensor< 0, dim, Number > &) const |
Tensor< 0, dim, Number > | operator- () const |
real_type | norm () const |
real_type | norm_square () const |
void | clear () |
DeclException1 (ExcDimTooSmall, int,<< "dim must be positive, but was "<< arg1) | |
template<class Archive > | |
void | serialize (Archive &ar, const unsigned int version) |
Static Public Attributes | |
static const unsigned int | dimension = dim |
static const unsigned int | rank = 0 |
Private Attributes | |
Number | value |
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 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.
Definition at line 70 of file tensor_base.h.
typedef Number Tensor< 0, dim, Number >::value_type |
Type of stored objects. This is a Number for a rank 1 tensor.
Definition at line 103 of file tensor_base.h.
typedef numbers::NumberTraits<Number>::real_type Tensor< 0, dim, 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 typedef is used to represent the return type of norms.
Definition at line 119 of file tensor_base.h.
Tensor< 0, dim, Number >::Tensor | ( | const value_type & | initializer | ) |
Copy constructor, where the data is copied from a C-style array.
Tensor< 0, dim, Number >::Tensor | ( | const Tensor< 0, dim, Number > & | ) |
Copy constructor.
Tensor< 0, dim, Number >::operator Number | ( | ) | const |
Conversion to Number. Since rank-0 tensors are scalars, this is a natural operation.
Tensor< 0, dim, Number >::operator Number & | ( | ) |
Conversion to Number. Since rank-0 tensors are scalars, this is a natural operation.
This is the non-const conversion operator that returns a writable reference.
Tensor<0,dim,Number>& Tensor< 0, dim, Number >::operator= | ( | const Tensor< 0, dim, Number > & | ) |
Assignment operator.
Tensor<0,dim,Number>& Tensor< 0, dim, Number >::operator= | ( | const Number | d | ) |
Assignment operator.
bool Tensor< 0, dim, Number >::operator== | ( | const Tensor< 0, dim, Number > & | ) | const |
Test for equality of two tensors.
bool Tensor< 0, dim, Number >::operator!= | ( | const Tensor< 0, dim, Number > & | ) | const |
Test for inequality of two tensors.
Tensor<0,dim,Number>& Tensor< 0, dim, Number >::operator+= | ( | const Tensor< 0, dim, Number > & | ) |
Add another vector, i.e. move this point by the given offset.
Tensor<0,dim,Number>& Tensor< 0, dim, Number >::operator-= | ( | const Tensor< 0, dim, Number > & | ) |
Subtract another vector.
Tensor<0,dim,Number>& Tensor< 0, dim, Number >::operator*= | ( | const Number | factor | ) |
Scale the vector by factor
, i.e. multiply all coordinates by factor
.
Tensor<0,dim,Number>& Tensor< 0, dim, Number >::operator/= | ( | const Number | factor | ) |
Scale the vector by 1/factor
.
Number Tensor< 0, dim, Number >::operator* | ( | const Tensor< 0, dim, Number > & | ) | const |
Returns the scalar product of two vectors.
Tensor<0,dim,Number> Tensor< 0, dim, Number >::operator+ | ( | const Tensor< 0, dim, Number > & | ) | const |
Add two tensors. If possible, use operator +=
instead since this does not need to copy a point at least once.
Tensor<0,dim,Number> Tensor< 0, dim, Number >::operator- | ( | const Tensor< 0, dim, Number > & | ) | const |
Subtract two tensors. If possible, use operator +=
instead since this does not need to copy a point at least once.
Tensor<0,dim,Number> Tensor< 0, dim, Number >::operator- | ( | ) | const |
Tensor with inverted entries.
Return the Frobenius-norm of a tensor, i.e. the square root of the sum of squares of all entries. For the present case of rank-1 tensors, this equals the usual l2
norm of the vector.
Return the square of the Frobenius-norm of a tensor, i.e. the square root of the sum of squares of all entries.
This function mainly exists because it makes computing the norm simpler recursively, but may also be useful in other contexts.
void Tensor< 0, dim, Number >::clear | ( | ) |
Reset all values to zero.
Note that this is partly inconsistent with the semantics of the clear()
member functions of the STL 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.
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
|
static |
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 90 of file tensor_base.h.
Publish the rank of this tensor to the outside world.
Definition at line 96 of file tensor_base.h.
|
private |
The value of this scalar object.
Definition at line 301 of file tensor_base.h.