MercuryDPM  Alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MatrixSymmetric3D Class Reference

Implementation of a 3D symmetric matrix. More...

#include <MatrixSymmetric.h>

Public Member Functions

 operator Matrix3D () const
 Casting operator; casts MatrixSymmetric3D to Matrix3D. More...
 
 MatrixSymmetric3D ()
 Default constructor. More...
 
 MatrixSymmetric3D (const Mdouble xx, const Mdouble xy, const Mdouble xz, const Mdouble yy, const Mdouble yz, const Mdouble zz)
 Alternative constructor, with all (6) elements as arguments. More...
 
void setZero ()
 Sets all elements to zero. More...
 
Mdouble trace () const
 Returns the MEAN of the diagonal elements (i.e. the trace divided by three). More...
 
MatrixSymmetric3D operator+ (const MatrixSymmetric3D &A) const
 Matrix addition. More...
 
MatrixSymmetric3D operator- (const MatrixSymmetric3D &A) const
 Matrix substraction. More...
 
MatrixSymmetric3D operator+ (const Mdouble a) const
 Scalar addition. More...
 
MatrixSymmetric3D operator- (const Mdouble a) const
 Scalar substraction. More...
 
MatrixSymmetric3D operator* (const Mdouble a) const
 Scalar multiplication. More...
 
MatrixSymmetric3D operator/ (const Mdouble a) const
 Scalar division. More...
 
MatrixSymmetric3Doperator+= (const MatrixSymmetric3D &A)
 Matrix addition. More...
 
MatrixSymmetric3Doperator-= (const MatrixSymmetric3D &A)
 Matrix substraction. More...
 
MatrixSymmetric3Doperator/= (const Mdouble a)
 Scalar division. More...
 

Static Public Member Functions

static MatrixSymmetric3D square (const MatrixSymmetric3D &A)
 Calculates the pointwise square. More...
 
static MatrixSymmetric3D sqrt (const MatrixSymmetric3D &A)
 Calculates the pointwise square root. More...
 
static MatrixSymmetric3D selfDyadic (const Vec3D &a)
 Calculates the dyadic product of a Vec3D with itself: $a \otimes a$. More...
 
static MatrixSymmetric3D symmetrisedDyadic (const Vec3D &a, const Vec3D &b)
 Calculates the symmetrised dyadic product of two Vec3D: $ \frac{1}{2}(a \otimes b + b \otimes a) $. More...
 

Public Attributes

Mdouble XX
 The six distinctive matrix elements. More...
 
Mdouble XY
 
Mdouble XZ
 
Mdouble YY
 
Mdouble YZ
 
Mdouble ZZ
 

Friends

Vec3D operator* (const MatrixSymmetric3D &A, const Vec3D &b)
 Vector multiplication. More...
 
std::ostream & operator<< (std::ostream &os, const MatrixSymmetric3D &A)
 Add elements to an ostream. More...
 
std::istream & operator>> (std::istream &is, MatrixSymmetric3D &A)
 Add elements to an istream. More...
 

Detailed Description

Implementation of a 3D symmetric matrix.

Definition at line 36 of file MatrixSymmetric.h.

Constructor & Destructor Documentation

MatrixSymmetric3D::MatrixSymmetric3D ( )

Default constructor.

Default constructor

Definition at line 42 of file MatrixSymmetric.cc.

Referenced by operator*(), operator+(), operator-(), operator/(), selfDyadic(), sqrt(), square(), and symmetrisedDyadic().

43 {
44 }
MatrixSymmetric3D::MatrixSymmetric3D ( const Mdouble  xx,
const Mdouble  xy,
const Mdouble  xz,
const Mdouble  yy,
const Mdouble  yz,
const Mdouble  zz 
)

Alternative constructor, with all (6) elements as arguments.

Alternative constructor, lets you define all (6) elements

Parameters
[in]xxinitializer for an element of the matrix
[in]xyinitializer for an element of the matrix
[in]xzinitializer for an element of the matrix
[in]yyinitializer for an element of the matrix
[in]yzinitializer for an element of the matrix
[in]zzinitializer for an element of the matrix

Definition at line 55 of file MatrixSymmetric.cc.

References XX, XY, XZ, YY, YZ, and ZZ.

56 {
57  XX = xx;
58  XY = xy;
59  XZ = xz;
60  YY = yy;
61  YZ = yz;
62  ZZ = zz;
63 }
Mdouble XX
The six distinctive matrix elements.

Member Function Documentation

MatrixSymmetric3D::operator Matrix3D ( ) const

Casting operator; casts MatrixSymmetric3D to Matrix3D.

This operator casts a MatrixSymmetric3D object to a Matrix3D object when needed.

Returns
The output is a symmetric matrix of type Matrix3D.

Definition at line 34 of file MatrixSymmetric.cc.

References XY, XZ, and YZ.

35 {
36  return Matrix3D(XX, XY, XZ, XY, YY, YZ, XZ, YZ, ZZ);
37 }
Implementation of a 3D matrix.
Definition: Matrix.h:36
Mdouble XX
The six distinctive matrix elements.
MatrixSymmetric3D MatrixSymmetric3D::operator* ( const Mdouble  a) const

Scalar multiplication.

Scalar multiplication

Parameters
[in]athe scalar
Returns
The multiplication result

Definition at line 142 of file MatrixSymmetric.cc.

References MatrixSymmetric3D(), XX, XY, XZ, YY, YZ, and ZZ.

143  {
144  return MatrixSymmetric3D(XX * a, XY * a, XZ * a,
145  YY * a, YZ * a, ZZ * a);
146 }
MatrixSymmetric3D()
Default constructor.
Mdouble XX
The six distinctive matrix elements.
MatrixSymmetric3D MatrixSymmetric3D::operator+ ( const MatrixSymmetric3D A) const

Matrix addition.

Addition of symmetric 3D matrices

Parameters
[in]Asymmetric matrix to be added
Returns
Result of the addition

Definition at line 88 of file MatrixSymmetric.cc.

References MatrixSymmetric3D(), XX, XY, XZ, YY, YZ, and ZZ.

89  {
90  return MatrixSymmetric3D(XX + A.XX, XY + A.XY, XZ + A.XZ, YY + A.YY, YZ + A.YZ, ZZ + A.ZZ);
91 }
MatrixSymmetric3D()
Default constructor.
Mdouble XX
The six distinctive matrix elements.
MatrixSymmetric3D MatrixSymmetric3D::operator+ ( const Mdouble  a) const

Scalar addition.

Addition of a scalar

Parameters
[in]ascalar to be added
Returns
Result of the addition

Definition at line 108 of file MatrixSymmetric.cc.

References MatrixSymmetric3D(), XX, XY, XZ, YY, YZ, and ZZ.

109  {
110  return MatrixSymmetric3D(XX + a, XY + a, XZ + a, YY + a, YZ + a, ZZ + a);
111 }
MatrixSymmetric3D()
Default constructor.
Mdouble XX
The six distinctive matrix elements.
MatrixSymmetric3D & MatrixSymmetric3D::operator+= ( const MatrixSymmetric3D A)

Matrix addition.

Matrix addition

Parameters
[in]Athe matrix to be added to this one
Returns
(reference to) this matrix, i.e. the result of the addition

Definition at line 187 of file MatrixSymmetric.cc.

References XX, XY, XZ, YY, YZ, and ZZ.

188 {
189  XX += A.XX;
190  XY += A.XY;
191  XZ += A.XZ;
192  YY += A.YY;
193  YZ += A.YZ;
194  ZZ += A.ZZ;
195  return *this;
196 }
Mdouble XX
The six distinctive matrix elements.
MatrixSymmetric3D MatrixSymmetric3D::operator- ( const MatrixSymmetric3D A) const

Matrix substraction.

Substraction of symmetric 3D matrices

Parameters
[in]Asymmetric matrix to be substracted
Returns
Result of the substraction

Definition at line 98 of file MatrixSymmetric.cc.

References MatrixSymmetric3D(), XX, XY, XZ, YY, YZ, and ZZ.

99  {
100  return MatrixSymmetric3D(XX - A.XX, XY - A.XY, XZ - A.XZ, YY - A.YY, YZ - A.YZ, ZZ - A.ZZ);
101 }
MatrixSymmetric3D()
Default constructor.
Mdouble XX
The six distinctive matrix elements.
MatrixSymmetric3D MatrixSymmetric3D::operator- ( const Mdouble  a) const

Scalar substraction.

Substraction of a scalar

Parameters
[in]ascalar to be substracted
Returns
Result of the substraction

Definition at line 118 of file MatrixSymmetric.cc.

References MatrixSymmetric3D(), XX, XY, XZ, YY, YZ, and ZZ.

119  {
120  return MatrixSymmetric3D(XX - a, XY - a, XZ - a, YY - a, YZ - a, ZZ - a);
121 }
MatrixSymmetric3D()
Default constructor.
Mdouble XX
The six distinctive matrix elements.
MatrixSymmetric3D & MatrixSymmetric3D::operator-= ( const MatrixSymmetric3D A)

Matrix substraction.

Matrix substraction

Parameters
[in]Athe matrix to be substracted
Returns
(reference to) this matrix, which is the result of the substraction

Definition at line 203 of file MatrixSymmetric.cc.

References XX, XY, XZ, YY, YZ, and ZZ.

204 {
205  XX -= A.XX;
206  XY -= A.XY;
207  XZ -= A.XZ;
208  YY -= A.YY;
209  YZ -= A.YZ;
210  ZZ -= A.ZZ;
211  return *this;
212 }
Mdouble XX
The six distinctive matrix elements.
MatrixSymmetric3D MatrixSymmetric3D::operator/ ( const Mdouble  a) const

Scalar division.

Scalar division

Parameters
[in]athe scalar to be divided by
Returns
The division result

Definition at line 153 of file MatrixSymmetric.cc.

References MatrixSymmetric3D(), XX, XY, XZ, YY, YZ, and ZZ.

154  {
155  return MatrixSymmetric3D(XX / a, XY / a, XZ / a, YY / a, YZ / a, ZZ / a);
156 }
MatrixSymmetric3D()
Default constructor.
Mdouble XX
The six distinctive matrix elements.
MatrixSymmetric3D & MatrixSymmetric3D::operator/= ( const Mdouble  a)

Scalar division.

Scalar division

Parameters
[in]athe scalar to be divided by
Returns
(reference to) this matrix, which is the result of the division

Definition at line 219 of file MatrixSymmetric.cc.

References XX, XY, XZ, YY, YZ, and ZZ.

220 {
221  XX /= a;
222  XY /= a;
223  XZ /= a;
224  YY /= a;
225  YZ /= a;
226  ZZ /= a;
227  return *this;
228 }
Mdouble XX
The six distinctive matrix elements.
MatrixSymmetric3D MatrixSymmetric3D::selfDyadic ( const Vec3D a)
static

Calculates the dyadic product of a Vec3D with itself: $a \otimes a$.

Calculates the dyadic product of a 3D vector with itself, which (obviously) results in a symmetric 3D matrix. NB: this is a STATIC function!

Parameters
[in]athe 3D vector
Returns
the resulting symmetric 3D matrix.

Definition at line 259 of file MatrixSymmetric.cc.

References MatrixSymmetric3D(), Vec3D::X, Vec3D::Y, and Vec3D::Z.

260 {
261  return MatrixSymmetric3D(a.X * a.X, a.X * a.Y, a.X * a.Z, a.Y * a.Y, a.Y * a.Z, a.Z * a.Z);
262 }
Mdouble X
the vector components
Definition: Vector.h:52
Mdouble Y
Definition: Vector.h:52
MatrixSymmetric3D()
Default constructor.
Mdouble Z
Definition: Vector.h:52
void MatrixSymmetric3D::setZero ( )

Sets all elements to zero.

Sets all elements of the symmetric matrix to 0.

Definition at line 68 of file MatrixSymmetric.cc.

References XX, XY, XZ, YY, YZ, and ZZ.

69 {
70  XX = XY = XZ = YY = YZ = ZZ = 0.0;
71 }
Mdouble XX
The six distinctive matrix elements.
MatrixSymmetric3D MatrixSymmetric3D::sqrt ( const MatrixSymmetric3D A)
static

Calculates the pointwise square root.

Pointwise square roots the matrix, i.e. takes the sq. root of each element. NB: this is a STATIC function!

Parameters
[in]AThe matrix to be pointwise square rooted
Returns
Resulting matrix

Definition at line 247 of file MatrixSymmetric.cc.

References MatrixSymmetric3D(), XX, XY, XZ, YY, YZ, and ZZ.

248 {
249  return MatrixSymmetric3D(std::sqrt(A.XX), std::sqrt(A.XY), std::sqrt(A.XZ), std::sqrt(A.YY), std::sqrt(A.YZ), std::sqrt(A.ZZ));
250 }
MatrixSymmetric3D()
Default constructor.
Mdouble XX
The six distinctive matrix elements.
MatrixSymmetric3D MatrixSymmetric3D::square ( const MatrixSymmetric3D A)
static

Calculates the pointwise square.

Pointwise squares the matrix, i.e. takes the square of each element. NB: is a STATIC function!

Parameters
[in]AThe matrix to be pointwise squared
Returns
Resulting matrix

Definition at line 236 of file MatrixSymmetric.cc.

References MatrixSymmetric3D(), mathsFunc::square(), XX, XY, XZ, YY, YZ, and ZZ.

237 {
239 }
T square(T val)
squares a number
Definition: ExtendedMath.h:91
MatrixSymmetric3D()
Default constructor.
Mdouble XX
The six distinctive matrix elements.
MatrixSymmetric3D MatrixSymmetric3D::symmetrisedDyadic ( const Vec3D a,
const Vec3D b 
)
static

Calculates the symmetrised dyadic product of two Vec3D: $ \frac{1}{2}(a \otimes b + b \otimes a) $.

Calculates the dyadic product of two 3D vectors, and 'symmetrises' the resulting matrix by taking the average of each pair of opposing non-diagonal elements. NB: this is a STATIC function!

Parameters
[in]athe first 3D vector
[in]bthe second 3D vector
Returns
the resulting symmetric 3D matrix

Definition at line 273 of file MatrixSymmetric.cc.

References MatrixSymmetric3D(), Vec3D::X, Vec3D::Y, and Vec3D::Z.

274 {
275  return MatrixSymmetric3D(a.X * b.X, 0.5 * (a.X * b.Y + b.X * a.Y), 0.5 * (a.X * b.Z + b.X * a.Z), a.Y * b.Y, 0.5 * (a.Y * b.Z + b.Y * a.Z), a.Z * b.Z);
276 }
Mdouble X
the vector components
Definition: Vector.h:52
Mdouble Y
Definition: Vector.h:52
MatrixSymmetric3D()
Default constructor.
Mdouble Z
Definition: Vector.h:52
Mdouble MatrixSymmetric3D::trace ( ) const

Returns the MEAN of the diagonal elements (i.e. the trace divided by three).

Returns the MEAN of the diagonal matrix elements, which is technically the trace divided by the number of diagonal elements.

Returns
The mean of the diagonal elements.

Definition at line 78 of file MatrixSymmetric.cc.

References XX, YY, and ZZ.

79 {
80  return (XX + YY + ZZ) / 3;
81 }
Mdouble XX
The six distinctive matrix elements.

Friends And Related Function Documentation

Vec3D operator* ( const MatrixSymmetric3D A,
const Vec3D b 
)
friend

Vector multiplication.

Multiplication of a symmetric 3D matrix with a vector (global operator, friend of this class)

Parameters
[in]Athe matrix
[in]bthe vector
Returns
The multiplication result

Definition at line 130 of file MatrixSymmetric.cc.

131 {
132  return Vec3D(A.XX * b.X + A.XY * b.Y + A.XZ * b.Z,
133  A.XY * b.X + A.YY * b.Y + A.YZ * b.Z,
134  A.XZ * b.X + A.YZ * b.Y + A.ZZ * b.Z);
135 }
Mdouble X
the vector components
Definition: Vector.h:52
Mdouble Y
Definition: Vector.h:52
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
Mdouble Z
Definition: Vector.h:52
Mdouble XX
The six distinctive matrix elements.
std::ostream& operator<< ( std::ostream &  os,
const MatrixSymmetric3D A 
)
friend

Add elements to an ostream.

Adds all elements of a symmetric 3D matrix to an ostream

Parameters
[in,out]osoutput stream
[in]Athe matrix
Returns
(reference to) output stream with matrix elements added

Definition at line 164 of file MatrixSymmetric.cc.

165 {
166  os << A.XX << ' ' << A.XY << ' ' << A.XZ << " " << A.YY << ' ' << A.YZ << " " << A.ZZ;
167  return os;
168 }
Mdouble XX
The six distinctive matrix elements.
std::istream& operator>> ( std::istream &  is,
MatrixSymmetric3D A 
)
friend

Add elements to an istream.

Reads the elements of a symmetric 3D matrix from an istream

Parameters
[in,out]isinput stream,
[out]Athe matrix
Returns
(reference to) input stream from with matrix elements were read

Definition at line 176 of file MatrixSymmetric.cc.

177 {
178  is >> A.XX >> A.XY >> A.XZ >> A.YY >> A.YZ >> A.ZZ;
179  return is;
180 }
Mdouble XX
The six distinctive matrix elements.

Member Data Documentation

Mdouble MatrixSymmetric3D::XX

The documentation for this class was generated from the following files: