Classes | |
class | ExcDimTooSmall |
Public Types | |
typedef double | value_type |
typedef double | array_type [(dim!=0)?dim:100000000] |
Public Member Functions | |
Tensor (const bool initialize=true) | |
Tensor (const array_type &initializer) | |
Tensor (const Tensor< 1, dim > &) | |
double | operator[] (const unsigned int index) const |
double & | operator[] (const unsigned int index) |
Tensor< 1, dim > & | operator= (const Tensor< 1, dim > &) |
Tensor< 1, dim > & | operator= (const double d) |
bool | operator== (const Tensor< 1, dim > &) const |
bool | operator!= (const Tensor< 1, dim > &) const |
Tensor< 1, dim > & | operator+= (const Tensor< 1, dim > &) |
Tensor< 1, dim > & | operator-= (const Tensor< 1, dim > &) |
Tensor< 1, dim > & | operator*= (const double factor) |
Tensor< 1, dim > & | operator/= (const double factor) |
double | operator* (const Tensor< 1, dim > &) const |
Tensor< 1, dim > | operator+ (const Tensor< 1, dim > &) const |
Tensor< 1, dim > | operator- (const Tensor< 1, dim > &) const |
Tensor< 1, dim > | operator- () const |
double | norm () const |
double | norm_square () const |
void | clear () |
void | unroll (Vector< double > &result) const |
Static Public Member Functions | |
static unsigned int | memory_consumption () |
Static Public Attributes | |
static const unsigned int | dimension = dim |
static const unsigned int | rank = 1 |
Private Member Functions | |
void | unroll_recursion (Vector< double > &result, unsigned int &start_index) const |
Private Attributes | |
double | values [(dim!=0)?(dim):1] |
Friends | |
class | ::Tensor |
class | Point< dim > |
Tensor<rank,dim>
class. It handles tensors with one index, i.e. vectors, of fixed dimension and provides the basis for the functionality needed for tensors of higher rank.
Within deal.II, the distinction between this class and its derived class Point
is that we use the Point
class mainly to denote the points that make up geometric objects. As such, they have a small number of additional operations over general tensors of rank 1 for which we use the Tensor<1,dim>
class. In particular, there is a distance() function to compute the Euclidian distance between two points in space.
However, the Point
class is really only used where the coordinates of an object can be thought to possess the dimension of a length. For all other uses, such as the gradient of a scalar function (which is a tensor of rank 1, or vector, with as many elements as a point object, but with different physical units), we use the Tensor<1,dim>
class.
typedef double Tensor< 1, dim >::value_type |
Type of stored objects. This is a double for a rank 1 tensor.
typedef double Tensor< 1, dim >::array_type[(dim!=0)?dim:100000000] |
Declare an array type which can be used to initialize statically an object of this type.
Avoid warning about zero-sized array for dim==0
by choosing lunatic value that is likely to overflow memory limits.
Constructor. Initialize all entries to zero if initialize==true
; this is the default behaviour.
Tensor< 1, dim >::Tensor | ( | const array_type & | initializer | ) |
Copy constructor, where the data is copied from a C-style array.
Read access to the index
th coordinate.
Note that the derived Point
class also provides access through the ()
operator for backcompatibility.
Read and write access to the index
th coordinate.
Note that the derived Point
class also provides access through the ()
operator for backcompatibility.
Assignment operator.
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.
Test for equality of two tensors.
Test for inequality of two tensors.
Add another vector, i.e. move this point by the given offset.
Subtract another vector.
Scale the vector by factor
, i.e. multiply all coordinates by factor
.
Scale the vector by 1/factor
.
Returns the scalar product of two vectors.
Reimplemented in Point< dim >, Point< N >, Point< 2 >, and Point< spacedim >.
Add two tensors. If possible, use operator +=
instead since this does not need to copy a point at least once.
Reimplemented in Point< dim >, Point< N >, Point< 2 >, and Point< spacedim >.
Subtract two tensors. If possible, use operator +=
instead since this does not need to copy a point at least once.
Reimplemented in Point< dim >, Point< N >, Point< 2 >, and Point< spacedim >.
Tensor with inverted entries.
Reimplemented in Point< dim >, Point< N >, Point< 2 >, and Point< spacedim >.
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< 1, dim >::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.
Referenced by Tensor< rank_, dim >::contract().
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 marches fastest.
Determine an estimate for the memory consumption (in bytes) of this object.
void Tensor< 1, dim >::unroll_recursion | ( | Vector< double > & | result, | |
unsigned int & | start_index | |||
) | const [private] |
Help function for unroll. If we have detected an access control bug in the compiler, this function is declared public, otherwise private. Do not attempt to use this function from outside in any case, even if it should be public for your compiler.
friend class ::Tensor [friend] |
Make the following classes friends to this class. In principle, it would suffice if otherrank==2, but that is not possible in C++ at present.
Also, it would be sufficient to make the function unroll_loops a friend, but that seems to be impossible as well.
friend class Point< dim > [friend] |
Point is allowed access to the coordinates. This is supposed to improve speed.
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.
Publish the rank of this tensor to the outside world.
Store the values in a simple array. For dim==0
store one element, because otherways the compiler would choke. We catch this case in the constructor to disallow the creation of such an object.