OpenWalnut  1.4.0
Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
WTensorBase< order, dim, Data_T > Class Template Reference

Normal tensor base class. More...

#include <WTensorBase.h>

+ Inheritance diagram for WTensorBase< order, dim, Data_T >:

Public Types

enum  { dataSize = WPower< dim, order >::value }
 Declare a compile-time constant as enum and not as static constant. More...
 

Public Member Functions

 WTensorBase ()
 Standard constructor. More...
 
 WTensorBase (WTensorBase const &t)
 Copy constructor. More...
 
 WTensorBase (WTensorBaseSym< order, dim, Data_T > const &t)
 Copy construct a WTensorBase from a WTensorBaseSym. More...
 
WTensorBase const & operator= (WTensorBase const &t)
 Copy operator. More...
 
WTensorBase const & operator= (WTensorBaseSym< order, dim, Data_T > const &t)
 Copy operator. More...
 
std::size_t getDimension () const
 Get the dimension of this tensor. More...
 
std::size_t getOrder () const
 Get the order of this tensor. More...
 
template<typename Index_T >
Data_T & operator[] (std::vector< Index_T > const &indices)
 Get the element at a specific position. More...
 
template<typename Index_T >
Data_T const & operator[] (std::vector< Index_T > const &indices) const
 Get the element at a specific position. More...
 
template<typename Index_T >
Data_T & operator[] (Index_T indices[])
 Get the element at a specific position. More...
 
template<typename Index_T >
Data_T const & operator[] (Index_T indices[]) const
 Get the element at a specific position. More...
 
bool operator== (WTensorBase const &other) const
 Compare this WTensorBase to another one. More...
 
bool operator!= (WTensorBase const &other) const
 Compare this WTensorBase to another one. More...
 

Private Member Functions

 BOOST_STATIC_ASSERT (dim!=0)
 For dim == 0, create an artificial compiler error. More...
 

Static Private Member Functions

template<typename Index_T >
static std::size_t getPos (Index_T pos[])
 Calculate the position of the element in the data vector. More...
 

Private Attributes

boost::array< Data_T, dataSizem_data
 Stores all elements. More...
 

Friends

class WTensorBase< order+1, dim, Data_T >
 
class ::WTensorBaseTest
 
class ::WTensorFuncTest
 

Detailed Description

template<std::size_t order, std::size_t dim, typename Data_T>
class WTensorBase< order, dim, Data_T >

Normal tensor base class.

Template Parameters
orderThe order of the tensor.
dimThe dimension of the tensor, i.e. the number of components in each direction.
Data_TThe datatype of the components, double by default.
Notes:
The type Data_T may not throw exceptions on construction, destruction or during any assignment operator.
Notes:
The dimension may not be 0.
See also
WTensor

Definition at line 164 of file WTensorBase.h.

Member Enumeration Documentation

template<std::size_t order, std::size_t dim, typename Data_T>
anonymous enum

Declare a compile-time constant as enum and not as static constant.

Enumerator
dataSize 

The number of elements to store.

Definition at line 299 of file WTensorBase.h.

Constructor & Destructor Documentation

template<std::size_t order, std::size_t dim, typename Data_T >
WTensorBase< order, dim, Data_T >::WTensorBase ( )

Standard constructor.

All elements are set to Data_T().

Definition at line 325 of file WTensorBase.h.

References WTensorBase< order, dim, Data_T >::m_data.

template<std::size_t order, std::size_t dim, typename Data_T >
WTensorBase< order, dim, Data_T >::WTensorBase ( WTensorBase< order, dim, Data_T > const &  t)

Copy constructor.

Parameters
tThe tensor to copy from.

Definition at line 331 of file WTensorBase.h.

template<std::size_t order, std::size_t dim, typename Data_T>
WTensorBase< order, dim, Data_T >::WTensorBase ( WTensorBaseSym< order, dim, Data_T > const &  t)
explicit

Copy construct a WTensorBase from a WTensorBaseSym.

Parameters
tThe symmetric tensor to copy from.

Definition at line 337 of file WTensorBase.h.

Member Function Documentation

template<std::size_t order, std::size_t dim, typename Data_T>
WTensorBase< order, dim, Data_T >::BOOST_STATIC_ASSERT ( dim!  = 0)
private

For dim == 0, create an artificial compiler error.

template<std::size_t order, std::size_t dim, typename Data_T >
std::size_t WTensorBase< order, dim, Data_T >::getDimension ( ) const

Get the dimension of this tensor.

Returns
The dimension of this tensor.

Definition at line 365 of file WTensorBase.h.

template<std::size_t order, std::size_t dim, typename Data_T >
std::size_t WTensorBase< order, dim, Data_T >::getOrder ( ) const

Get the order of this tensor.

Returns
The order of this tensor.

Definition at line 371 of file WTensorBase.h.

template<std::size_t order, std::size_t dim, typename Data_T >
template<typename Index_T >
std::size_t WTensorBase< order, dim, Data_T >::getPos ( Index_T  pos[])
inlinestaticprivate

Calculate the position of the element in the data vector.

The function is build recursively at compile-time.

Parameters
posAn array of indices.
Returns
The position of the element.

Definition at line 378 of file WTensorBase.h.

Referenced by WTensorBase< order, dim, Data_T >::operator[]().

template<std::size_t order, std::size_t dim, typename Data_T >
bool WTensorBase< order, dim, Data_T >::operator!= ( WTensorBase< order, dim, Data_T > const &  other) const

Compare this WTensorBase to another one.

Parameters
otherThe WBensorBase to compare to.
Returns
True, iff this tensors' elements are not equal to another tensors' elements.

Definition at line 424 of file WTensorBase.h.

References WTensorBase< order, dim, Data_T >::m_data.

template<std::size_t order, std::size_t dim, typename Data_T >
WTensorBase< order, dim, Data_T > const & WTensorBase< order, dim, Data_T >::operator= ( WTensorBase< order, dim, Data_T > const &  t)

Copy operator.

Parameters
tThe tensor to copy from.
Returns
*this.

Definition at line 343 of file WTensorBase.h.

References WTensorBase< order, dim, Data_T >::m_data.

Referenced by WTensor< order, dim, Data_T >::operator=(), and WTensor< order, dim, Data_T >::WTensor().

template<std::size_t order, std::size_t dim, typename Data_T>
WTensorBase< order, dim, Data_T > const & WTensorBase< order, dim, Data_T >::operator= ( WTensorBaseSym< order, dim, Data_T > const &  t)

Copy operator.

Parameters
tThe symmetric tensor to copy from.
Returns
*this.

Definition at line 350 of file WTensorBase.h.

References WTensorBase< order, dim, Data_T >::dataSize.

template<std::size_t order, std::size_t dim, typename Data_T >
bool WTensorBase< order, dim, Data_T >::operator== ( WTensorBase< order, dim, Data_T > const &  other) const

Compare this WTensorBase to another one.

Parameters
otherThe WBensorBase to compare to.
Returns
True, iff this tensors' elements are equal to another tensors' elements.

Definition at line 418 of file WTensorBase.h.

References WTensorBase< order, dim, Data_T >::m_data.

template<std::size_t order, std::size_t dim, typename Data_T >
template<typename Index_T >
Data_T & WTensorBase< order, dim, Data_T >::operator[] ( std::vector< Index_T > const &  indices)

Get the element at a specific position.

Parameters
indicesA std::vector of indices that has a size of at least order.
Returns
A reference to the element.

Definition at line 385 of file WTensorBase.h.

Referenced by WTensorBase< order, dim, Data_T >::operator[]().

template<std::size_t order, std::size_t dim, typename Data_T >
template<typename Index_T >
Data_T const & WTensorBase< order, dim, Data_T >::operator[] ( std::vector< Index_T > const &  indices) const

Get the element at a specific position.

Parameters
indicesA std::vector of indices that has a size of at least order.
Returns
A reference to the element.

Definition at line 392 of file WTensorBase.h.

References WTensorBase< order, dim, Data_T >::operator[]().

template<std::size_t order, std::size_t dim, typename Data_T >
template<typename Index_T >
Data_T & WTensorBase< order, dim, Data_T >::operator[] ( Index_T  indices[])

Get the element at a specific position.

Parameters
indicesAn array of indices that has a size of at least order.
Returns
A reference to the element.
Notes:
The array must have a length of at least order.

Definition at line 400 of file WTensorBase.h.

template<std::size_t order, std::size_t dim, typename Data_T >
template<typename Index_T >
Data_T const & WTensorBase< order, dim, Data_T >::operator[] ( Index_T  indices[]) const

Get the element at a specific position.

Parameters
indicesAn array of indices that has a size of at least order.
Returns
A reference to the element.
Notes:
The array must have a length of at least order.

Definition at line 407 of file WTensorBase.h.

References WTensorBase< order, dim, Data_T >::getPos(), and WTensorBase< order, dim, Data_T >::m_data.

Member Data Documentation

template<std::size_t order, std::size_t dim, typename Data_T>
boost::array< Data_T, dataSize > WTensorBase< order, dim, Data_T >::m_data
private

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