|
PSCF v1.3.3
|
A Tensor represents a Cartesian tensor. More...
#include <Tensor.h>
Public Member Functions | |
Constructors | |
| Tensor () | |
| Default constructor. | |
| Tensor (const Tensor &t) | |
| Copy constructor. | |
| Tensor (double scalar) | |
| Constructor, initialize all elements to a scalar value. | |
| Tensor (const double a[][Dimension]) | |
| Construct Tensor from double [][Dimension] 2D C array. | |
Assignment | |
| Tensor & | operator= (const Tensor &t) |
| Copy assignment. | |
| Tensor & | operator= (const double a[][Dimension]) |
| Assignment from C double [Dimension][Dimension] 2D array. | |
Arithmetic Assignment | |
| void | operator+= (const Tensor &dt) |
| Add tensor dt to this tensor. | |
| void | operator-= (const Tensor &dt) |
| Subtract tensor dt from this tensor. | |
| void | operator*= (double s) |
| Multiply this tensor by scalar s. | |
| void | operator/= (double s) |
| Divide this tensor by scalar s. | |
Array Subscript | |
| const double & | operator() (int i, int j) const |
| Return one element by value. | |
| double & | operator() (int i, int j) |
| Return one element by non-const reference. | |
Tensor valued functions (result assigned to invoking object) | |
| Tensor & | zero () |
| Set all elements of this tensor to zero. | |
| Tensor & | identity () |
| Set this to the identity (unity) tensor. | |
| Tensor & | setRow (int i, const Vector &r) |
| Set row i of this Tensor to elements of Vector r. | |
| Tensor & | setColumn (int i, const Vector &r) |
| Set column i of this Tensor to elements of Vector r. | |
| Tensor & | add (const Tensor &t1, const Tensor &t2) |
| Add tensors t1 and t2. | |
| Tensor & | subtract (const Tensor &t1, const Tensor &t2) |
| Subtract tensor t2 from t1. | |
| Tensor & | multiply (const Tensor &t, double s) |
| Multiply a tensor t by a scalar s. | |
| Tensor & | divide (const Tensor &t, double s) |
| Divide a Tensor t by a scalar s. | |
| Tensor & | transpose (const Tensor &t) |
| Compute transpose of a tensor. | |
| Tensor & | transpose () |
| Transpose this tensor. | |
| Tensor & | symmetrize (const Tensor &t) |
| Compute symmetric part of a tensor t. | |
| Tensor & | symmetrize () |
| Symmetrize this tensor. | |
| Tensor & | dyad (const Vector &v1, const Vector &v2) |
| Create dyad of two vectors. | |
Miscellaneous | |
| double | trace () const |
| Return the trace of this tensor. | |
| template<class Archive> | |
| void | serialize (Archive &ar, const unsigned int version) |
| Serialize this to/from an archive. | |
Static Members | |
| static const Tensor | Zero = Tensor(0.0) |
| Constant Tensor with all zero elements. | |
| static const Tensor | Identity = Tensor().identity() |
| Constant idenity Tensor (diagonal diagonal elements all 1). | |
| static void | initStatic () |
| Call to guarantee initialization of Zero and Identity tensors. | |
| bool | operator== (const Tensor &t1, const Tensor &t2) |
| Equality for Tensors. | |
| bool | operator== (const Tensor &t1, const double t2[][Dimension]) |
| Equality of Tensor and 2D C array. | |
| std::istream & | operator>> (std::istream &in, Tensor &tensor) |
| istream extractor for a Tensor. | |
| std::ostream & | operator<< (std::ostream &out, const Tensor &tensor) |
| ostream inserter for a Tensor. | |
|
inline |
Default constructor.
Definition at line 399 of file Tensor.h.
Referenced by add(), divide(), dyad(), identity(), multiply(), operator+=(), operator-=(), operator<<, operator=(), operator=(), operator==, operator==, operator>>, setColumn(), setRow(), subtract(), symmetrize(), symmetrize(), Tensor(), transpose(), transpose(), and zero().
|
inline |
Copy constructor.
Definition at line 406 of file Tensor.h.
References Util::DimensionSq, and Tensor().
|
inlineexplicit |
Constructor, initialize all elements to a scalar value.
| scalar | initial value for all elements. |
Definition at line 417 of file Tensor.h.
References Util::DimensionSq.
|
inlineexplicit |
Construct Tensor from double [][Dimension] 2D C array.
| a | 2D array a[Dimension][Dimension] |
Definition at line 428 of file Tensor.h.
References Util::Dimension.
Copy assignment.
| t | Tensor to assign. |
Definition at line 468 of file Tensor.h.
References Util::DimensionSq, and Tensor().
|
inline |
Assignment from C double [Dimension][Dimension] 2D array.
| a | 2D array a[Dimension][Dimension] |
Definition at line 480 of file Tensor.h.
References Util::Dimension, and Tensor().
|
inline |
Add tensor dt to this tensor.
Upon return, *this = *this + dt.
| dt | tensor increment (input) |
Definition at line 495 of file Tensor.h.
References Util::DimensionSq, and Tensor().
|
inline |
Subtract tensor dt from this tensor.
Upon return, *this = *this - dt.
| dt | tensor increment (input) |
Definition at line 506 of file Tensor.h.
References Util::DimensionSq, and Tensor().
|
inline |
Multiply this tensor by scalar s.
Upon return, *this = (*this)*s.
| s | scalar multiplier |
Definition at line 517 of file Tensor.h.
References Util::DimensionSq.
|
inline |
Divide this tensor by scalar s.
Upon return, *this = (*this)/s.
| s | scalar divisor (input) |
Definition at line 528 of file Tensor.h.
References Util::DimensionSq.
|
inline |
Return one element by value.
| i | row element index |
| j | column element index |
Definition at line 539 of file Tensor.h.
References Util::Dimension.
|
inline |
Return one element by non-const reference.
| i | row element index |
| j | column element index |
Definition at line 552 of file Tensor.h.
References Util::Dimension.
|
inline |
Set all elements of this tensor to zero.
Definition at line 441 of file Tensor.h.
References Util::DimensionSq, and Tensor().
Referenced by Util::setToZero().
|
inline |
Set this to the identity (unity) tensor.
Definition at line 453 of file Tensor.h.
References Util::Dimension, Util::DimensionSq, and Tensor().
Add tensors t1 and t2.
Upon return, *this = t1 + t2.
| t1 | tensor |
| t2 | tensor |
Definition at line 567 of file Tensor.h.
References Util::DimensionSq, and Tensor().
Subtract tensor t2 from t1.
Upon return, *this == t1 - t2.
| t1 | tensor (input) |
| t2 | tensor (input) |
Definition at line 581 of file Tensor.h.
References Util::DimensionSq, and Tensor().
Multiply a tensor t by a scalar s.
Upon return, *this == v*s.
| t | tensor factor |
| s | scalar factor |
Definition at line 595 of file Tensor.h.
References Util::DimensionSq, and Tensor().
Divide a Tensor t by a scalar s.
Upon return, *this = v/s;
| t | tensor input |
| s | scalar denominator |
Definition at line 609 of file Tensor.h.
References Util::DimensionSq, and Tensor().
Compute transpose of a tensor.
Upon return, *this is the transpose of t
| t | input tensor |
Definition at line 636 of file Tensor.h.
References Util::Dimension, and Tensor().
|
inline |
Transpose this tensor.
Upon return, *this is transposed.
Definition at line 657 of file Tensor.h.
References Util::Dimension, and Tensor().
Compute symmetric part of a tensor t.
Upon return, *this = [t + t.transpose()]/2
| t | tensor input |
Definition at line 678 of file Tensor.h.
References Util::Dimension, and Tensor().
|
inline |
Symmetrize this tensor.
Upon return, this is symmetrized, equal to half the sum of the original tensor and its transpose.
Definition at line 701 of file Tensor.h.
References Util::Dimension, and Tensor().
Create dyad of two vectors.
Upon return, *this equals the dyad v1 ^ v2. Equivalently: (*this)(i , j) == v1[i]*v2[j]
| v1 | vector input |
| v2 | vector input |
Definition at line 763 of file Tensor.h.
References Util::Dimension, and Tensor().
|
inline |
Return the trace of this tensor.
Definition at line 621 of file Tensor.h.
References Util::Dimension, and trace().
Referenced by trace().
|
inline |
Serialize this to/from an archive.
| ar | archive |
| version | archive version id |
Definition at line 720 of file Tensor.h.
References Util::DimensionSq.
|
static |
Call to guarantee initialization of Zero and Identity tensors.
Call this function once to guarantee that this file is linked.
Definition at line 27 of file Tensor.cpp.
References UTIL_CHECK.
Referenced by Util::initStatic().
Equality for Tensors.
Definition at line 41 of file Tensor.cpp.
References Util::DimensionSq, and Tensor().
|
friend |
Equality of Tensor and 2D C array.
Definition at line 54 of file Tensor.cpp.
References Util::Dimension, and Tensor().
|
friend |
istream extractor for a Tensor.
Input elements of a tensor from stream, without line breaks.
| in | input stream |
| tensor | Tensor to be read from stream |
Definition at line 91 of file Tensor.cpp.
References Util::DimensionSq, and Tensor().
|
friend |
ostream inserter for a Tensor.
Output elements of a tensor to stream, without line breaks.
| out | output stream |
| tensor | Tensor to be written to stream |
Definition at line 102 of file Tensor.cpp.
References Util::DimensionSq, and Tensor().