.TH "tensor" 2rheolef "Sat Mar 13 2021" "Version 7.1" "rheolef" \" -*- nroff -*- .ad l .nh .SH NAME tensor \- d-dimensional physical tensor (rheolef-7\&.1) .PP .SH "DESCRIPTION" .PP The \fCtensor\fP class defines a \fCd*d\fP matrix with floating coefficients\&. This class is suitable for defining tensors, i\&.e\&. \fBfield(2)\fP with \fCd*d\fP matrix values at each physical position\&. .PP It is represented as a bidimensional array of coordinates\&. The coordinate indexes start at zero and finishes at \fCd-1\fP, e\&.g\&. \fCa(0,0)\fP, \fCa(0,1)\fP, \&.\&.\&., \fCa(2,2)\fP\&. .PP The default constructor set all components to zero: .PP .nf tensor a; .fi .PP and this default could be overridden: .PP .nf tensor a = {{1, 2, 3.14}, {2, 6, 6.2 }, {5, 8, 9.0 }}; .fi .PP The standard linear algebra with scalars, vectors of R^3 (see the \fBpoint(2)\fP class) and \fCtensor\fP is supported\&. .PP The computation of eigenvalues and eigenvectors, together with the SVD decomposition are also provided for convenience\&. .SH "IMPLEMENTATION" .PP This documentation has been generated from file fem/geo_element/tensor\&.h .PP The \fCtensor\fP class is simply an alias to the \fC\fBtensor_basic\fP\fP class .PP .PP .nf typedef tensor_basic tensor; .fi .PP The \fC\fBtensor_basic\fP\fP class is a template class with the floating type as parameter: .PP .PP .nf template class tensor_basic { public: typedef size_t size_type; typedef T element_type; typedef T float_type; // allocators: tensor_basic (const T& init_val = 0); tensor_basic (T x[3][3]); tensor_basic (const tensor_basic& a); static tensor_basic eye (size_type d = 3); tensor_basic (const std::initializer_list >& il); // affectation: tensor_basic& operator= (const tensor_basic& a); tensor_basic& operator= (const T& val); // modifiers: void fill (const T& init_val); void reset (); void set_row (const point_basic& r, size_t i, size_t d = 3); void set_column (const point_basic& c, size_t j, size_t d = 3); // accessors: T& operator()(size_type i, size_type j); const T& operator()(size_type i, size_type j) const; point_basic row(size_type i) const; point_basic col(size_type i) const; size_t nrow() const; // = 3, for template matrix compatibility size_t ncol() const; // inputs/outputs: std::ostream& put (std::ostream& s, size_type d = 3) const; std::istream& get (std::istream&); // algebra: bool operator== (const tensor_basic&) const; bool operator!= (const tensor_basic& b) const { return ! operator== (b); } const tensor_basic& operator+ () const { return *this; } tensor_basic operator- () const; tensor_basic operator+ (const tensor_basic& b) const; tensor_basic operator- (const tensor_basic& b) const; tensor_basic operator* (const tensor_basic& b) const; tensor_basic operator* (const T& k) const; tensor_basic operator/ (const T& k) const; point_basic operator* (const point_basic&) const; point_basic trans_mult (const point_basic& x) const; tensor_basic& operator+= (const tensor_basic&); tensor_basic& operator-= (const tensor_basic&); tensor_basic& operator*= (const T& k); tensor_basic& operator/= (const T& k); T determinant (size_type d = 3) const; bool is_symmetric (size_type d = 3) const; // eigenvalues & eigenvectors: // a = q*d*q^T // a may be symmetric // where q=(q1,q2,q3) are eigenvectors in rows (othonormal matrix) // and d=(d1,d2,d3) are eigenvalues, sorted in decreasing order d1 >= d2 >= d3 // return d point_basic eig (tensor_basic& q, size_t dim = 3) const; point_basic eig (size_t dim = 3) const; // singular value decomposition: // a = u*s*v^T // a can be unsymmetric // where u=(u1,u2,u3) are left pseudo-eigenvectors in rows (othonormal matrix) // v=(v1,v2,v3) are right pseudo-eigenvectors in rows (othonormal matrix) // and s=(s1,s2,s3) are eigenvalues, sorted in decreasing order s1 >= s2 >= s3 // return s point_basic svd (tensor_basic& u, tensor_basic& v, size_t dim = 3) const; .fi .PP .PP .nf }; .fi .PP \fB\fP .RS 4 .RE .PP The linear algebra is completed by some classical operators and the matrix exponential: .PP .PP .nf template point_basic operator* (const point_basic& yt, const tensor_basic& a); template tensor_basic trans (const tensor_basic& a, size_t d = 3); template void prod (const tensor_basic& a, const tensor_basic& b, tensor_basic& result, size_t di=3, size_t dj=3, size_t dk=3); // tr(a) = a00 + a11 + a22 template U tr (const tensor_basic& a, size_t d=3); template U ddot (const tensor_basic&, const tensor_basic&); // a = u otimes v <==> aij = ui*vj template tensor_basic otimes (const point_basic& u, const point_basic& v, size_t d=3); template tensor_basic inv (const tensor_basic& a, size_t d = 3); template tensor_basic diag (const point_basic& d); template point_basic diag (const tensor_basic& a); template U determinant (const tensor_basic& A, size_t d = 3); template bool invert_3x3 (const tensor_basic& A, tensor_basic& result); // matrix exponential: template tensor_basic exp (const tensor_basic& a, size_t d = 3); // inputs/outputs: template inline std::istream& operator>> (std::istream& in, tensor_basic& a) { return a\&.get (in); } template inline std::ostream& operator<< (std::ostream& out, const tensor_basic& a) { return a\&.put (out); } // t += a otimes b template void cumul_otimes (tensor_basic& t, const point_basic& a, const point_basic& b, size_t na = 3); template void cumul_otimes (tensor_basic& t, const point_basic& a, const point_basic& b, size_t na, size_t nb); .fi .PP .SH AUTHOR Pierre Saramito .SH COPYRIGHT Copyright (C) 2000-2018 Pierre Saramito GPLv3+: GNU GPL version 3 or later . This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.