12#include <util/space/Dimension.h>
16#include <util/mpi/MpiTraits.h>
55 explicit Tensor(
double scalar);
279 double trace()
const;
287 template <
class Archive>
288 void serialize(Archive& ar,
const unsigned int version);
321 static const int Width = 13;
324 static const int Precision = 5;
409 elem_[i] = t.elem_[i];
471 elem_[i] = t.elem_[i];
498 elem_[i] += dt.elem_[i];
509 elem_[i] -= dt.elem_[i];
570 elem_[i] = t1.elem_[i] + t2.elem_[i];
584 elem_[i] = t1.elem_[i] - t2.elem_[i];
598 elem_[i] = t.elem_[i]*s;
612 elem_[i] = t.elem_[i]/s;
625 trace += (*this)(i, i);
640 (*this)(i, i) = t(i, i);
643 for (j = 0; j < i; ++j) {
644 (*this)(i, j) = t(j, i);
645 (*this)(j, i) = t(i, j);
662 for (j = 0; j < i; ++j) {
663 save = (*this)(i, j);
664 (*this)(i, j) = (*
this)(j, i);
665 (*this)(j, i) = save;
683 (*this)(i, i) = t(i, i);
686 for (j = 0; j < i; ++j) {
687 ave = 0.5*( t(i, j) + t(j, i) );
706 for (j = 0; j < i; ++j) {
707 ave = 0.5*( (*this)(i, j) + (*
this)(j, i) );
718 template <
class Archive>
729#include <util/space/Vector.h>
static MPI::Datatype type
MPI Datatype.
static bool hasType
Is the MPI type initialized?
A Tensor represents a Cartesian tensor.
void operator/=(double s)
Divide this tensor by scalar s.
friend bool operator==(const Tensor &t1, const Tensor &t2)
Equality for Tensors.
Tensor & add(const Tensor &t1, const Tensor &t2)
Add tensors t1 and t2.
Tensor & multiply(const Tensor &t, double s)
Multiply a tensor t by a scalar s.
Tensor & symmetrize()
Symmetrize this tensor.
Tensor()
Default constructor.
Tensor & dyad(const Vector &v1, const Vector &v2)
Create dyad of two vectors.
Tensor & subtract(const Tensor &t1, const Tensor &t2)
Subtract tensor t2 from t1.
const double & operator()(int i, int j) const
Return one element by value.
friend std::ostream & operator<<(std::ostream &out, const Tensor &tensor)
ostream inserter for a Tensor.
Tensor & setColumn(int i, const Vector &r)
Set column i of this Tensor to elements of Vector r.
void operator-=(const Tensor &dt)
Subtract tensor dt from this tensor.
double trace() const
Return the trace of this tensor.
void operator*=(double s)
Multiply this tensor by scalar s.
Tensor & zero()
Set all elements of this tensor to zero.
Tensor & operator=(const Tensor &t)
Copy assignment.
friend std::istream & operator>>(std::istream &in, Tensor &tensor)
istream extractor for a Tensor.
Tensor & divide(const Tensor &t, double s)
Divide a Tensor t by a scalar s.
static const Tensor Zero
Constant Tensor with all zero elements.
void operator+=(const Tensor &dt)
Add tensor dt to this tensor.
Tensor & setRow(int i, const Vector &r)
Set row i of this Tensor to elements of Vector r.
static void initStatic()
Call to guarantee initialization of Zero and Identity tensors.
Tensor & identity()
Set this to the identity (unity) tensor.
static void commitMpiType()
Commit MPI datatype MpiTraits<Tensor>::type.
void serialize(Archive &ar, const unsigned int version)
Serialize this to/from an archive.
Tensor & transpose()
Transpose this tensor.
static const Tensor Identity
Constant idenity Tensor (diagonal diagonal elements all 1).
A Vector is a Cartesian vector.
File containing preprocessor macros for error handling.
const int Dimension
Dimensionality of space.
const int DimensionSq
Square of Dimensionality of space.
Utility classes for scientific computation.
bool operator==(Polynomial< T > const &a, Polynomial< T > const &b)
Equality operator for polynomials.
std::istream & operator>>(std::istream &in, Pair< Data > &pair)
Input a Pair from an istream.
std::ostream & operator<<(std::ostream &out, const Pair< Data > &pair)
Output a Pair to an ostream, without line breaks.
bool operator!=(Polynomial< T > const &a, Polynomial< T > const &b)
Inequality operator for polynomials.