d-dimensional physical tensor
Description
The tensor
class defines a d*d
matrix with floating coefficients. This class is suitable for defining tensors, i.e. field
with d*d
matrix values at each physical position.
It is represented as a bidimensional array of coordinates. The coordinate indexes start at zero and finishes at d-1
, e.g. a(0,0)
, a(0,1)
, ..., a(2,2)
.
The default constructor set all components to zero:
tensor a;
and this default could be overridden:
tensor a = {{1, 2, 3.14},
{2, 6, 6.2 },
{5, 8, 9.0 }};
The standard linear algebra with scalars, vectors of R^3 (see the point
class) and tensor
is supported.
The computation of eigenvalues and eigenvectors, together with the SVD decomposition are also provided for convenience.
Implementation
This documentation has been generated from file fem/geo_element/tensor.h
The tensor
class is simply an alias to the tensor_basic
class
typedef tensor_basic<Float>
tensor;
The tensor_basic
class is a template class with the floating type as parameter:
template<class T>
class tensor_basic {
public:
tensor_basic (
const std::initializer_list<std::initializer_list<T> >& il);
tensor_basic<T>&
operator= (
const tensor_basic<T>&
a);
void fill (
const T& init_val);
std::istream&
get (std::istream&);
const tensor_basic<T>&
operator+ ()
const {
return *
this; }
tensor_basic<T>
operator+ (
const tensor_basic<T>&
b)
const;
tensor_basic<T>
operator- (
const tensor_basic<T>&
b)
const;
tensor_basic<T>
operator* (
const tensor_basic<T>&
b)
const;
tensor_basic<T>&
operator+= (
const tensor_basic<T>&);
tensor_basic<T>&
operator-= (
const tensor_basic<T>&);
The linear algebra is completed by some classical operators and the matrix exponential:
template <class U>
point_basic<U>
operator* (
const point_basic<U>& yt,
const tensor_basic<U>&
a);
template <class U>
tensor_basic<U>
trans (
const tensor_basic<U>&
a,
size_t d = 3);
template <class U>
void prod (
const tensor_basic<U>&
a,
const tensor_basic<U>&
b, tensor_basic<U>& result,
size_t di=3, size_t dj=3, size_t dk=3);
template <class U>
U
tr (
const tensor_basic<U>&
a,
size_t d=3);
template <class U>
U
ddot (
const tensor_basic<U>&,
const tensor_basic<U>&);
template <class U>
tensor_basic<U>
otimes (
const point_basic<U>&
u,
const point_basic<U>& v,
size_t d=3);
template <class U>
tensor_basic<U>
inv (
const tensor_basic<U>&
a,
size_t d = 3);
template <class U>
tensor_basic<U>
diag (
const point_basic<U>&
d);
template <class U>
point_basic<U>
diag (
const tensor_basic<U>&
a);
template <class U>
template <class U>
bool invert_3x3 (
const tensor_basic<U>& A, tensor_basic<U>& result);
template<class T>
tensor_basic<T>
exp (
const tensor_basic<T>&
a,
size_t d = 3);
template<class T>
inline
std::istream&
operator>> (std::istream& in, tensor_basic<T>&
a) {
template<class T>
inline
std::ostream&
operator<< (std::ostream&
out,
const tensor_basic<T>&
a) {
template<class T>
template<class T>