Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes
Tensor< 0, dim > Class Template Reference

List of all members.

Public Types

typedef double value_type

Public Member Functions

 Tensor ()
 Tensor (const value_type &initializer)
 Tensor (const Tensor< 0, dim > &)
 operator double () const
 operator double & ()
Tensor< 0, dim > & operator= (const Tensor< 0, dim > &)
Tensor< 0, dim > & operator= (const double d)
bool operator== (const Tensor< 0, dim > &) const
bool operator!= (const Tensor< 0, dim > &) const
Tensor< 0, dim > & operator+= (const Tensor< 0, dim > &)
Tensor< 0, dim > & operator-= (const Tensor< 0, dim > &)
Tensor< 0, dim > & operator*= (const double factor)
Tensor< 0, dim > & operator/= (const double factor)
double operator* (const Tensor< 0, dim > &) const
Tensor< 0, dim > operator+ (const Tensor< 0, dim > &) const
Tensor< 0, dim > operator- (const Tensor< 0, dim > &) const
Tensor< 0, dim > operator- () const
double norm () const
double norm_square () const
void clear ()
template<class Archive >
void serialize (Archive &ar, const unsigned int version)

Static Public Member Functions

::ExceptionBase & ExcDimTooSmall (int arg1) throw (errortext << "dim must be positive, but was " << arg1 )

Static Public Attributes

static const unsigned int dimension = dim
static const unsigned int rank = 0

Private Attributes

double value

Detailed Description

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

This class is a specialized version of the Tensor<rank,dim> 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>, 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. double) for all purposes but is part of the Tensor template family.

Author:
Wolfgang Bangerth, 2009

Member Typedef Documentation

template<int dim>
typedef double Tensor< 0, dim >::value_type

Type of stored objects. This is a double for a rank 1 tensor.


Constructor & Destructor Documentation

template<int dim>
Tensor< 0, dim >::Tensor ( )

Constructor. Set to zero.

template<int dim>
Tensor< 0, dim >::Tensor ( const value_type &  initializer)

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

template<int dim>
Tensor< 0, dim >::Tensor ( const Tensor< 0, dim > &  )

Copy constructor.


Member Function Documentation

template<int dim>
Tensor< 0, dim >::operator double ( ) const

Conversion to double. Since rank-0 tensors are scalars, this is a natural operation.

template<int dim>
Tensor< 0, dim >::operator double & ( )

Conversion to double. Since rank-0 tensors are scalars, this is a natural operation.

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

template<int dim>
Tensor<0,dim>& Tensor< 0, dim >::operator= ( const Tensor< 0, dim > &  )

Assignment operator.

template<int dim>
Tensor<0,dim>& Tensor< 0, dim >::operator= ( const double  d)

Assignment operator.

template<int dim>
bool Tensor< 0, dim >::operator== ( const Tensor< 0, dim > &  ) const

Test for equality of two tensors.

template<int dim>
bool Tensor< 0, dim >::operator!= ( const Tensor< 0, dim > &  ) const

Test for inequality of two tensors.

template<int dim>
Tensor<0,dim>& Tensor< 0, dim >::operator+= ( const Tensor< 0, dim > &  )

Add another vector, i.e. move this point by the given offset.

template<int dim>
Tensor<0,dim>& Tensor< 0, dim >::operator-= ( const Tensor< 0, dim > &  )

Subtract another vector.

template<int dim>
Tensor<0,dim>& Tensor< 0, dim >::operator*= ( const double  factor)

Scale the vector by factor, i.e. multiply all coordinates by factor.

template<int dim>
Tensor<0,dim>& Tensor< 0, dim >::operator/= ( const double  factor)

Scale the vector by 1/factor.

template<int dim>
double Tensor< 0, dim >::operator* ( const Tensor< 0, dim > &  ) const

Returns the scalar product of two vectors.

template<int dim>
Tensor<0,dim> Tensor< 0, dim >::operator+ ( const Tensor< 0, dim > &  ) const

Add two tensors. If possible, use operator += instead since this does not need to copy a point at least once.

template<int dim>
Tensor<0,dim> Tensor< 0, dim >::operator- ( const Tensor< 0, dim > &  ) const

Subtract two tensors. If possible, use operator += instead since this does not need to copy a point at least once.

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

Tensor with inverted entries.

template<int dim>
double Tensor< 0, dim >::norm ( ) const

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.

template<int dim>
double Tensor< 0, dim >::norm_square ( ) const

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.

template<int dim>
void Tensor< 0, 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.

template<int dim>
template<class Archive >
void Tensor< 0, dim >::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


Member Data Documentation

template<int dim>
const unsigned int Tensor< 0, dim >::dimension = dim [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.

template<int dim>
const unsigned int Tensor< 0, dim >::rank = 0 [static]

Publish the rank of this tensor to the outside world.

template<int dim>
double Tensor< 0, dim >::value [private]

The value of this scalar object.


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

deal.II documentation generated on Fri Aug 12 2011 15:01:07 by doxygen 1.7.4