High Performance Plasticity  0.5.0
hpp::Tensor4< T > Class Template Reference

#include <tensor.h>

Public Member Functions

 Tensor4 ()
 Default constructor. More...
 
 Tensor4 (unsigned int n1, unsigned int n2, unsigned int n3, unsigned int n4)
 Constructor for Tensor2D It is responsible for setting the dimensions of the tensor, including the total number of elements. It is also responsible for allocating memory for the underlying array, and zeroing it. More...
 
 ~Tensor4 ()
 Destructor for Tensor2D It is responsible for freeing and invalidating the underlying array. More...
 
 Tensor4 (const Tensor2< T > &A)
 
Tensor4< T > & operator= (const Tensor4< T > &input)
 
 Tensor4 (const Tensor4< T > &input)
 
unsigned int getNVals () const
 
T & operator() (unsigned int i, unsigned int j, unsigned int k, unsigned int l)
 
T & operator() (unsigned int flatIdx)
 
getVal (unsigned int i, unsigned int j, unsigned int k, unsigned int l) const
 
getValFlat (unsigned int flatIdx) const
 
frobeniusNorm () const
 
void invInPlace ()
 
Tensor4< T > inv () const
 
void printToStream (std::ostream &out)
 
unsigned int getn1 () const
 
unsigned int getn2 () const
 
unsigned int getn3 () const
 
unsigned int getn4 () const
 

Protected Attributes

unsigned int n1 = 0
 
unsigned int n2 = 0
 
unsigned int n3 = 0
 
unsigned int n4 = 0
 
unsigned int nVals = 0
 
std::valarray< T > vals
 

Private Member Functions

void initialize (unsigned int n1, unsigned int n2, unsigned int n3, unsigned int n4)
 
unsigned int flat (unsigned int i, unsigned int j, unsigned int k, unsigned int l) const
 Flatten the four indices of the tensor. More...
 
idx4d unflat (unsigned int idx)
 Unflatten the four indices of the tensor. More...
 
void copyValues (const Tensor4< T > &input)
 

Private Attributes

friend Tensor2< T >
 

Friends

template<typename U , unsigned int M, unsigned int N, unsigned int P, unsigned int Q>
class Tensor4CUDA
 
template<typename U >
bool areSameShape (const Tensor4< U > &A, const Tensor4< U > &B)
 
template<typename U >
void assertSameShape (const Tensor4< U > &A, const Tensor4< U > &B)
 
template<typename U >
bool operator== (const Tensor4< U > &A, const Tensor4< U > &B)
 
template<typename U >
bool operator!= (const Tensor4< U > &A, const Tensor4< U > &B)
 
template<typename U >
void assertCompatibleForContraction (const Tensor4< U > &A, const Tensor2< U > &B)
 
template<typename U >
void assertCompatibleForContraction (const Tensor4< U > &A, const Tensor2< U > &B, const Tensor2< U > &C)
 
template<typename U >
Tensor2< U > contract (const Tensor4< U > &A, const Tensor2< U > &B)
 
template<typename U >
void contractInPlace (const Tensor4< U > &A, const Tensor2< U > &B, Tensor2< U > &C)
 
template<typename U >
void assertCompatibleForContraction (const Tensor4< U > &A, const Tensor4< U > &B)
 
template<typename U >
Tensor4< U > contract (const Tensor4< U > &A, const Tensor4< U > &B)
 
template<typename U >
void assertCompatibleForOuterProduct (const Tensor2< U > &A, const Tensor2< U > &B, const Tensor4< U > &C)
 
template<typename U >
void outerInPlace (const Tensor2< U > &A, const Tensor2< U > &B, Tensor4< U > &C)
 
template<typename U >
Tensor4< U > operator+ (const Tensor4< U > &A, const Tensor4< U > &B)
 
template<typename U >
Tensor4< U > operator+ (const Tensor4< U > &A, const U &B)
 
template<typename U >
Tensor4< U > operator+ (const U &A, const Tensor4< U > &B)
 
template<typename U >
void operator+= (Tensor4< U > &A, const U &B)
 
template<typename U >
void operator+= (Tensor4< U > &A, const Tensor4< U > &B)
 
template<typename U >
Tensor4< U > operator- (const Tensor4< U > &A)
 
template<typename U >
Tensor4< U > operator- (const Tensor4< U > &A, const Tensor4< U > &B)
 
template<typename U >
Tensor4< U > operator- (const Tensor4< U > &A, const U &B)
 
template<typename U >
Tensor4< U > operator- (const U &A, const Tensor4< U > &B)
 
template<typename U >
void operator-= (Tensor4< U > &A, const U &B)
 
template<typename U >
void operator-= (Tensor4< U > &A, const Tensor4< U > &B)
 
template<typename U >
Tensor4< U > operator* (const Tensor4< U > &A, const U &B)
 
template<typename U >
Tensor4< U > operator* (const U &A, const Tensor4< U > &B)
 
template<typename U >
void operator*= (Tensor4< U > &A, const U &B)
 
template<typename U >
Tensor4< U > operator/ (const Tensor4< U > &A, const U &B)
 
template<typename U >
void operator/= (Tensor4< U > &A, const U &B)
 

Detailed Description

template<typename T>
class hpp::Tensor4< T >

Author
Michael Malahe
Date
07/10/16

Constructor & Destructor Documentation

template<typename T >
hpp::Tensor4< T >::Tensor4 ( )

Default constructor.

Sets dimensions to zero

template<typename T >
hpp::Tensor4< T >::Tensor4 ( unsigned int  n1,
unsigned int  n2,
unsigned int  n3,
unsigned int  n4 
)

Constructor for Tensor2D It is responsible for setting the dimensions of the tensor, including the total number of elements. It is also responsible for allocating memory for the underlying array, and zeroing it.

Parameters
n1the first dimension of the tensor
n2the second dimension of the tensor
n3the third dimension of the tensor
n4the fourth dimension of the tensor
template<typename T >
hpp::Tensor4< T >::~Tensor4 ( )

Destructor for Tensor2D It is responsible for freeing and invalidating the underlying array.

template<typename T>
hpp::Tensor4< T >::Tensor4 ( const Tensor2< T > &  A)
explicit
template<typename T>
hpp::Tensor4< T >::Tensor4 ( const Tensor4< T > &  input)

Member Function Documentation

template<typename T>
void hpp::Tensor4< T >::copyValues ( const Tensor4< T > &  input)
private
template<typename T >
unsigned int hpp::Tensor4< T >::flat ( unsigned int  i,
unsigned int  j,
unsigned int  k,
unsigned int  l 
) const
inlineprivate

Flatten the four indices of the tensor.

This is currently done in row-major order.

Parameters
ithe first index
jthe second index
kthe thrid index
lthe fourth index
Returns
the flattened index
template<typename T >
T hpp::Tensor4< T >::frobeniusNorm ( ) const
template<typename T>
unsigned int hpp::Tensor4< T >::getn1 ( ) const
inline
template<typename T>
unsigned int hpp::Tensor4< T >::getn2 ( ) const
inline
template<typename T>
unsigned int hpp::Tensor4< T >::getn3 ( ) const
inline
template<typename T>
unsigned int hpp::Tensor4< T >::getn4 ( ) const
inline
template<typename T>
unsigned int hpp::Tensor4< T >::getNVals ( ) const
inline
template<typename T >
T hpp::Tensor4< T >::getVal ( unsigned int  i,
unsigned int  j,
unsigned int  k,
unsigned int  l 
) const
inline
template<typename T >
T hpp::Tensor4< T >::getValFlat ( unsigned int  flatIdx) const
inline
template<typename T >
void hpp::Tensor4< T >::initialize ( unsigned int  n1,
unsigned int  n2,
unsigned int  n3,
unsigned int  n4 
)
private
template<typename T >
Tensor4< T > hpp::Tensor4< T >::inv ( ) const
template<typename T >
void hpp::Tensor4< T >::invInPlace ( )
template<typename T >
T & hpp::Tensor4< T >::operator() ( unsigned int  i,
unsigned int  j,
unsigned int  k,
unsigned int  l 
)
inline
template<typename T >
T & hpp::Tensor4< T >::operator() ( unsigned int  flatIdx)
inline
template<typename T>
Tensor4< T > & hpp::Tensor4< T >::operator= ( const Tensor4< T > &  input)
template<typename T >
void hpp::Tensor4< T >::printToStream ( std::ostream &  out)
template<typename T >
idx4d hpp::Tensor4< T >::unflat ( unsigned int  flat_idx)
inlineprivate

Unflatten the four indices of the tensor.

This is currently done in row-major order.

Parameters
flat_idxidx the flattened index
Returns
an idx4d instance with the unflattened indices

Friends And Related Function Documentation

template<typename T>
template<typename U >
bool areSameShape ( const Tensor4< U > &  A,
const Tensor4< U > &  B 
)
friend
template<typename T>
template<typename U >
void assertCompatibleForContraction ( const Tensor4< U > &  A,
const Tensor2< U > &  B 
)
friend
template<typename T>
template<typename U >
void assertCompatibleForContraction ( const Tensor4< U > &  A,
const Tensor2< U > &  B,
const Tensor2< U > &  C 
)
friend
template<typename T>
template<typename U >
void assertCompatibleForContraction ( const Tensor4< U > &  A,
const Tensor4< U > &  B 
)
friend
template<typename T>
template<typename U >
void assertCompatibleForOuterProduct ( const Tensor2< U > &  A,
const Tensor2< U > &  B,
const Tensor4< U > &  C 
)
friend
template<typename T>
template<typename U >
void assertSameShape ( const Tensor4< U > &  A,
const Tensor4< U > &  B 
)
friend
template<typename T>
template<typename U >
Tensor2<U> contract ( const Tensor4< U > &  A,
const Tensor2< U > &  B 
)
friend
template<typename T>
template<typename U >
Tensor4<U> contract ( const Tensor4< U > &  A,
const Tensor4< U > &  B 
)
friend
template<typename T>
template<typename U >
void contractInPlace ( const Tensor4< U > &  A,
const Tensor2< U > &  B,
Tensor2< U > &  C 
)
friend
template<typename T>
template<typename U >
bool operator!= ( const Tensor4< U > &  A,
const Tensor4< U > &  B 
)
friend
template<typename T>
template<typename U >
Tensor4<U> operator* ( const Tensor4< U > &  A,
const U &  B 
)
friend
template<typename T>
template<typename U >
Tensor4<U> operator* ( const U &  A,
const Tensor4< U > &  B 
)
friend
template<typename T>
template<typename U >
void operator*= ( Tensor4< U > &  A,
const U &  B 
)
friend
template<typename T>
template<typename U >
Tensor4<U> operator+ ( const Tensor4< U > &  A,
const Tensor4< U > &  B 
)
friend
template<typename T>
template<typename U >
Tensor4<U> operator+ ( const Tensor4< U > &  A,
const U &  B 
)
friend
template<typename T>
template<typename U >
Tensor4<U> operator+ ( const U &  A,
const Tensor4< U > &  B 
)
friend
template<typename T>
template<typename U >
void operator+= ( Tensor4< U > &  A,
const U &  B 
)
friend
template<typename T>
template<typename U >
void operator+= ( Tensor4< U > &  A,
const Tensor4< U > &  B 
)
friend
template<typename T>
template<typename U >
Tensor4<U> operator- ( const Tensor4< U > &  A)
friend
template<typename T>
template<typename U >
Tensor4<U> operator- ( const Tensor4< U > &  A,
const Tensor4< U > &  B 
)
friend
template<typename T>
template<typename U >
Tensor4<U> operator- ( const Tensor4< U > &  A,
const U &  B 
)
friend
template<typename T>
template<typename U >
Tensor4<U> operator- ( const U &  A,
const Tensor4< U > &  B 
)
friend
template<typename T>
template<typename U >
void operator-= ( Tensor4< U > &  A,
const U &  B 
)
friend
template<typename T>
template<typename U >
void operator-= ( Tensor4< U > &  A,
const Tensor4< U > &  B 
)
friend
template<typename T>
template<typename U >
Tensor4<U> operator/ ( const Tensor4< U > &  A,
const U &  B 
)
friend
template<typename T>
template<typename U >
void operator/= ( Tensor4< U > &  A,
const U &  B 
)
friend
template<typename T>
template<typename U >
bool operator== ( const Tensor4< U > &  A,
const Tensor4< U > &  B 
)
friend
template<typename T>
template<typename U >
void outerInPlace ( const Tensor2< U > &  A,
const Tensor2< U > &  B,
Tensor4< U > &  C 
)
friend
template<typename T>
template<typename U , unsigned int M, unsigned int N, unsigned int P, unsigned int Q>
friend class Tensor4CUDA
friend

Member Data Documentation

template<typename T>
unsigned int hpp::Tensor4< T >::n1 = 0
protected
template<typename T>
unsigned int hpp::Tensor4< T >::n2 = 0
protected
template<typename T>
unsigned int hpp::Tensor4< T >::n3 = 0
protected
template<typename T>
unsigned int hpp::Tensor4< T >::n4 = 0
protected
template<typename T>
unsigned int hpp::Tensor4< T >::nVals = 0
protected
template<typename T>
friend hpp::Tensor4< T >::Tensor2< T >
private
template<typename T>
std::valarray<T> hpp::Tensor4< T >::vals
protected

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