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;
see the tensor page for the full documentation
The tensor_basic
class is a template class with the floating type as parameter:
template<class T>
class tensor_basic {
public:
tensor_basic (
const T& init_val = 0);
tensor_basic (
T x[3][3]);
tensor_basic (const tensor_basic<T>& a);
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);
void set_row (
const point_basic<T>& r,
size_t i,
size_t d = 3);
void set_column (
const point_basic<T>& c,
size_t j,
size_t d = 3);
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;
point_basic<T>
operator* (
const point_basic<T>&)
const;
point_basic<T>
trans_mult (
const point_basic<T>& x)
const;
tensor_basic<T>&
operator+= (
const tensor_basic<T>&);
tensor_basic<T>&
operator-= (
const tensor_basic<T>&);
point_basic<T>
eig (tensor_basic<T>& q,
size_t dim = 3)
const;
point_basic<T>
eig (
size_t dim = 3)
const;
point_basic<T>
svd (tensor_basic<T>&
u, tensor_basic<T>& v,
size_t dim = 3)
const;
field::size_type size_type
std::ostream & put(std::ostream &s, size_type d=3) const
T & operator()(size_type i, size_type j)
tensor_basic< T > & operator=(const tensor_basic< T > &a)
std::istream & get(std::istream &)
point_basic< T > trans_mult(const point_basic< T > &x) const
tensor_basic< T > & operator+=(const tensor_basic< T > &)
point_basic< T > col(size_type i) const
T determinant(size_type d=3) const
tensor_basic< T > & operator*=(const T &k)
tensor_basic< T > operator*(const tensor_basic< T > &b) const
bool is_symmetric(size_type d=3) const
point_basic< T > eig(tensor_basic< T > &q, size_t dim=3) const
const tensor_basic< T > & operator+() const
tensor_basic< T > operator-() const
tensor_basic< T > operator/(const T &k) const
void fill(const T &init_val)
bool operator!=(const tensor_basic< T > &b) const
void set_row(const point_basic< T > &r, size_t i, size_t d=3)
tensor_basic< T > & operator-=(const tensor_basic< T > &)
bool operator==(const tensor_basic< T > &) const
tensor_basic< T > & operator/=(const T &k)
point_basic< T > row(size_type i) const
point_basic< T > svd(tensor_basic< T > &u, tensor_basic< T > &v, size_t dim=3) const
void set_column(const point_basic< T > &c, size_t j, size_t d=3)
solver_basic< Float > eye()
see the eye page for the full documentation
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) {
return a.get (in); }
template<class T>
inline
std::ostream&
operator<< (std::ostream& out,
const tensor_basic<T>& a) {
return a.put (out); }
template<class T>
void cumul_otimes (tensor_basic<T>& t,
const point_basic<T>& a,
const point_basic<T>& b,
size_t na = 3);
template<class T>
void cumul_otimes (tensor_basic<T>& t,
const point_basic<T>& a,
const point_basic<T>& b,
size_t na,
size_t nb);
tensor_basic< T > inv(const tensor_basic< T > &a, size_t d)
tensor_basic< U > otimes(const point_basic< U > &u, const point_basic< U > &v, size_t d=3)
T ddot(const tensor_basic< T > &a, const tensor_basic< T > &b)
ddot(x,y): see the expression page for the full documentation
U tr(const tensor_basic< U > &a, size_t d=3)
std::ostream & operator<<(std::ostream &os, const catchmark &m)
U determinant(const tensor_basic< U > &A, size_t d=3)
void prod(const tensor_basic< T > &a, const tensor_basic< T > &b, tensor_basic< T > &result, size_t di, size_t dj, size_t dk)
std::istream & operator>>(std::istream &is, const catchmark &m)
csr< T, M > diag(const vec< T, M > &d)
void cumul_otimes(tensor_basic< T > &t, const point_basic< T > &a, const point_basic< T > &b, size_t na, size_t nb)
csr< T, sequential > trans(const csr< T, sequential > &a)
trans(a): see the form page for the full documentation
csr< T, sequential > operator*(const T &lambda, const csr< T, sequential > &a)
bool invert_3x3(const tensor_basic< T > &A, tensor_basic< T > &result)