12 #include <util/mpi/MpiStructBuilder.h> 31 UTIL_THROW(
"Tensor::initStatic called more than once");
38 #define UTIL_TENSOR_EPSILON 1.0E-8 46 if ( fabs(t1.elem_[i] - t2.elem_[i]) > UTIL_TENSOR_EPSILON) {
60 if ( fabs(t1(i, j) - a2[i][j]) > UTIL_TENSOR_EPSILON) {
72 {
return (t2 == a1); }
74 #undef UTIL_TENSOR_EPSILON 80 {
return !(t1 == t2); }
84 {
return !(t1 == a2); }
88 {
return !(t2 == a1); }
96 in >> tensor.elem_[i];
107 out.setf(std::ios::scientific);
108 out.width(Tensor::Width);
109 out.precision(Tensor::Precision);
110 out << tensor.elem_[i];
127 if (!MpiTraits<Tensor>::hasType) {
135 builder.
addMember(&tensor(i, j), MPI::DOUBLE);
138 builder.
commit(MpiTraits<Tensor>::type);
139 MpiTraits<Tensor>::hasType =
true;
void addMember(void *memberAddress, MPI::Datatype type, int count=1)
Add a new member variable to the type map.
const int Dimension
Dimensionality of space.
static void initStatic()
Call to guarantee initialization of Zero and Identity tensors.
File containing preprocessor macros for error handling.
Tensor & identity()
Set this to the identity (unity) tensor.
friend std::istream & operator>>(std::istream &in, Tensor &tensor)
istream extractor for a Tensor.
A Tensor represents a Cartesian tensor.
void setBase(void *objectAddress)
Set address of an class instance.
void commit(MPI::Datatype &newType)
Build and commit a user-defined MPI Struct datatype.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
static void commitMpiType()
Commit MPI datatype MpiTraits<Tensor>::type.
Utility classes for scientific computation.
A MpiStructBuilder objects is used to create an MPI Struct datatype.
const int DimensionSq
Square of Dimensionality of space.
friend bool operator==(const Tensor &t1, const Tensor &t2)
Equality for Tensors.
static const Tensor Identity
Constant idenity Tensor (diagonal diagonal elements all 1).
static const Tensor Zero
Constant Tensor with all zero elements.
friend std::ostream & operator<<(std::ostream &out, const Tensor &tensor)
ostream inserter for a Tensor.
bool operator!=(const PointSymmetry &A, const PointSymmetry &B)
Are two PointSymmetry objects not equivalent?