MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Matrix3D Class Reference

Implementation of a 3D matrix. More...

#include <Matrix.h>

Public Member Functions

 Matrix3D ()
 default constructor More...
 
 Matrix3D (Mdouble xx, Mdouble xy, Mdouble xz, Mdouble yx, Mdouble yy, Mdouble yz, Mdouble zx, Mdouble zy, Mdouble zz)
 Alternative constructor, which let you define all elements. More...
 
 Matrix3D (const SmallMatrix< 3, 3 > &matrix)
 Alternative constructor, which takes a matrix of the same size. More...
 
void setZero ()
 Sets all elements to zero. More...
 
double trace () const
 Sum of the diagonal elements. More...
 
Vec3D diag () const
 The diagonal elements. More...
 
double deviator () const
 Deviator. More...
 
Matrix3D operator+ (const Matrix3D &A) const
 Matrix addition. More...
 
Matrix3D operator- (const Matrix3D &A) const
 Matrix subtraction. More...
 
Matrix3D operator+ (Mdouble a) const
 Scalar addition. More...
 
Matrix3D operator- (Mdouble a) const
 Scalar subtraction. More...
 
Matrix3D operator* (Mdouble a) const
 Scalar multiplication. More...
 
Vec3D operator* (const Vec3D &a) const
 Vector multiplication. More...
 
Matrix3D operator* (const Matrix3D &a) const
 Matrix multiplication. More...
 
Matrix3D operator/ (Mdouble a) const
 Scalar division. More...
 
Matrix3Doperator+= (const Matrix3D &A)
 Matrix addition. More...
 
Matrix3Doperator-= (const Matrix3D &A)
 Matrix substraction. More...
 
Matrix3Doperator/= (Mdouble a)
 Scalar division. More...
 
Vec3D ldivide (const Vec3D &b)
 A.ldivide(b) computes the solution x to A*x=b. More...
 
Matrix3D getCylindricalTensorField (const Vec3D &p) const
 Returns the matrix in cylindrical coordinates. More...
 

Static Public Member Functions

static Matrix3D square (const Matrix3D &A)
 Calculates the pointwise square. More...
 
static Matrix3D sqrt (const Matrix3D &A)
 Calculates the pointwise square root. More...
 
static Matrix3D dyadic (const Vec3D &a, const Vec3D &b)
 Calculates the dyadic product of a two Vec3D: \(a \otimes b\). More...
 
static Matrix3D cross (const Vec3D &a, const Matrix3D &b)
 'Special' cross product; CP of vector with each column of a matrix More...
 
static Matrix3D inverse (const Matrix3D &A)
 Computes the inverse of a matrix. More...
 

Public Attributes

Mdouble XX
 all nine matrix elements More...
 
Mdouble XY
 
Mdouble XZ
 
Mdouble YX
 
Mdouble YY
 
Mdouble YZ
 
Mdouble ZX
 
Mdouble ZY
 
Mdouble ZZ
 

Friends

std::ostream & operator<< (std::ostream &os, const Matrix3D &A)
 Add elements to ostream. More...
 
std::istream & operator>> (std::istream &is, Matrix3D &A)
 Add elements to istream. More...
 

Detailed Description

Implementation of a 3D matrix.

Definition at line 37 of file Matrix.h.

Constructor & Destructor Documentation

Matrix3D::Matrix3D ( )

default constructor

default constructor, which is empty (i.e., only creates the object)

Definition at line 34 of file Matrix.cc.

References setZero().

Referenced by cross(), dyadic(), getCylindricalTensorField(), operator*(), operator+(), operator-(), operator/(), sqrt(), and square().

35 {
36  setZero();
37 }
void setZero()
Sets all elements to zero.
Definition: Matrix.cc:75
Matrix3D::Matrix3D ( Mdouble  xx,
Mdouble  xy,
Mdouble  xz,
Mdouble  yx,
Mdouble  yy,
Mdouble  yz,
Mdouble  zx,
Mdouble  zy,
Mdouble  zz 
)

Alternative constructor, which let you define all elements.

Alternative constructor. Let's you specify ALL 9 elements of the 3x3 matrix.

Parameters
[in][all]xx/xy/xz /yx/yy/yz /zx/zy/zz are all nine elements (left-to-right, top-to-bottom) of the 3D matrix.

Definition at line 45 of file Matrix.cc.

References XX, XY, XZ, YX, YY, YZ, ZX, ZY, and ZZ.

47 {
48  XX = xx;
49  XY = xy;
50  XZ = xz;
51  YX = yx;
52  YY = yy;
53  YZ = yz;
54  ZX = zx;
55  ZY = zy;
56  ZZ = zz;
57 }
Mdouble XY
Definition: Matrix.h:43
Mdouble ZY
Definition: Matrix.h:43
Mdouble XZ
Definition: Matrix.h:43
Mdouble ZX
Definition: Matrix.h:43
Mdouble ZZ
Definition: Matrix.h:43
Mdouble YZ
Definition: Matrix.h:43
Mdouble YX
Definition: Matrix.h:43
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43
Matrix3D::Matrix3D ( const SmallMatrix< 3, 3 > &  matrix)

Alternative constructor, which takes a matrix of the same size.

Definition at line 59 of file Matrix.cc.

References XX, XY, XZ, YX, YY, YZ, ZX, ZY, and ZZ.

60 {
61  XX = matrix(0, 0);
62  XY = matrix(0, 1);
63  XZ = matrix(0, 2);
64  YX = matrix(1, 0);
65  YY = matrix(1, 1);
66  YZ = matrix(1, 2);
67  ZX = matrix(2, 0);
68  ZY = matrix(2, 1);
69  ZZ = matrix(2, 2);
70 }
Mdouble XY
Definition: Matrix.h:43
Mdouble ZY
Definition: Matrix.h:43
Mdouble XZ
Definition: Matrix.h:43
Mdouble ZX
Definition: Matrix.h:43
Mdouble ZZ
Definition: Matrix.h:43
Mdouble YZ
Definition: Matrix.h:43
Mdouble YX
Definition: Matrix.h:43
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43

Member Function Documentation

Matrix3D Matrix3D::cross ( const Vec3D a,
const Matrix3D B 
)
static

'Special' cross product; CP of vector with each column of a matrix

Returns a matrix, who's columns are the inner product of a given vector with the corresponding columns of a given matrix

Parameters
[in]avector
[in]Bmatrix
Returns
Resulting matrix

Definition at line 337 of file Matrix.cc.

References Matrix3D(), Vec3D::X, XX, XY, XZ, Vec3D::Y, YX, YY, YZ, Vec3D::Z, ZX, ZY, and ZZ.

338 {
339  return Matrix3D(
340  a.Y * B.ZX - a.Z * B.YX, a.Y * B.ZY - a.Z * B.YY, a.Y * B.ZZ - a.Z * B.YZ,
341  a.Z * B.XX - a.X * B.ZX, a.Z * B.XY - a.X * B.ZY, a.Z * B.XZ - a.X * B.ZZ,
342  a.X * B.YX - a.Y * B.XX, a.X * B.YY - a.Y * B.XY, a.X * B.YZ - a.Y * B.XZ);
343 }
Mdouble XY
Definition: Matrix.h:43
Mdouble X
the vector components
Definition: Vector.h:65
Mdouble ZY
Definition: Matrix.h:43
Mdouble XZ
Definition: Matrix.h:43
Mdouble ZX
Definition: Matrix.h:43
Mdouble ZZ
Definition: Matrix.h:43
Mdouble YZ
Definition: Matrix.h:43
Mdouble YX
Definition: Matrix.h:43
Mdouble Y
Definition: Vector.h:65
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43
Mdouble Z
Definition: Vector.h:65
Matrix3D()
default constructor
Definition: Matrix.cc:34
Mdouble Matrix3D::deviator ( ) const

Deviator.

Returns an invariant of the deviatoric tensor, scaled such that it is equal to shear stress for the stress tensor.

Returns
resulting scalar

Definition at line 103 of file Matrix.cc.

References mathsFunc::square(), trace(), XX, XY, XZ, YX, YY, YZ, ZX, ZY, and ZZ.

104 {
105  const Mdouble P = trace() / 3.0;
106  return std::sqrt(0.5 * (mathsFunc::square(XX - P) + mathsFunc::square(YY - P) + mathsFunc::square(ZZ - P)) +
108 }
Mdouble XY
Definition: Matrix.h:43
double trace() const
Sum of the diagonal elements.
Definition: Matrix.cc:84
Mdouble ZY
Definition: Matrix.h:43
double Mdouble
Definition: GeneralDefine.h:34
Mdouble XZ
Definition: Matrix.h:43
Mdouble ZX
Definition: Matrix.h:43
Mdouble ZZ
Definition: Matrix.h:43
Mdouble YZ
Definition: Matrix.h:43
Mdouble YX
Definition: Matrix.h:43
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43
T square(const T val)
squares a number
Definition: ExtendedMath.h:104
Vec3D Matrix3D::diag ( ) const

The diagonal elements.

Returns the sum of the diagonal elements of the matrix.

Returns
The trace of the matrix divided by 3 as an Mdouble

Definition at line 93 of file Matrix.cc.

References XX, YY, and ZZ.

94 {
95  return Vec3D(XX, YY, ZZ);
96 }
Mdouble ZZ
Definition: Matrix.h:43
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43
Definition: Vector.h:49
Matrix3D Matrix3D::dyadic ( const Vec3D a,
const Vec3D b 
)
static

Calculates the dyadic product of a two Vec3D: \(a \otimes b\).

Dyadic product of two vectors

Parameters
[in]afirst vector
[in]bsecond vector
Returns
Resulting matrix

Definition at line 323 of file Matrix.cc.

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

Referenced by CGFields::GradVelocityField::addParticleDifferentialStatistics(), DPMBase::getKineticStress(), DPMBase::getStaticStress(), and CGFields::StandardFields::setFields().

324 {
325  return Matrix3D(a.X * b.X, a.X * b.Y, a.X * b.Z,
326  a.Y * b.X, a.Y * b.Y, a.Y * b.Z,
327  a.Z * b.X, a.Z * b.Y, a.Z * b.Z);
328 }
Mdouble X
the vector components
Definition: Vector.h:65
Mdouble Y
Definition: Vector.h:65
Mdouble Z
Definition: Vector.h:65
Matrix3D()
default constructor
Definition: Matrix.cc:34
Matrix3D Matrix3D::getCylindricalTensorField ( const Vec3D p) const

Returns the matrix in cylindrical coordinates.

Transforms the (Cartesian) vector to cylindrical coordinates. See https://en.wikipedia.org/wiki/Vector_fields_in_cylindrical_and_spherical_coordinates

Returns
Transformed vector

Definition at line 394 of file Matrix.cc.

References Matrix3D(), Vec3D::X, XX, XY, XZ, Vec3D::Y, YX, YY, YZ, ZX, ZY, and ZZ.

Referenced by CGFields::StandardFields::setCylindricalFields().

395 {
396  //define sin(A)=y/r, cos(A)=x/r
397  const Mdouble r = std::sqrt(p.X * p.X + p.Y * p.Y);
398  Mdouble s = p.Y / r;
399  Mdouble c = p.X / r;
400  if (r == 0)
401  {
402  s = 0;
403  c = 1;
404  }
405  const Matrix3D M = Matrix3D(XX * c + XY * s, -XX * s + XY * c, XZ,
406  YX * c + YY * s, -YX * s + YY * c, YZ,
407  ZX * c + ZY * s, -ZX * s + ZY * c, ZZ);
408  return Matrix3D(M.XX * c + M.YX * s, -M.XX * s + M.YX * c, M.ZX,
409  M.XY * c + M.YY * s, -M.XY * s + M.YY * c, M.ZY,
410  M.XZ * c + M.YZ * s, -M.XZ * s + M.YZ * c, M.ZZ);
411 }
Mdouble XY
Definition: Matrix.h:43
Mdouble X
the vector components
Definition: Vector.h:65
Mdouble ZY
Definition: Matrix.h:43
double Mdouble
Definition: GeneralDefine.h:34
Mdouble XZ
Definition: Matrix.h:43
Mdouble ZX
Definition: Matrix.h:43
Mdouble ZZ
Definition: Matrix.h:43
Mdouble YZ
Definition: Matrix.h:43
Mdouble YX
Definition: Matrix.h:43
Mdouble Y
Definition: Vector.h:65
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43
Implementation of a 3D matrix.
Definition: Matrix.h:37
Matrix3D()
default constructor
Definition: Matrix.cc:34
Matrix3D Matrix3D::inverse ( const Matrix3D A)
static

Computes the inverse of a matrix.

Parameters
[in]AMatrix that should be inverted.
Returns
Inverse of matrix A.

Definition at line 349 of file Matrix.cc.

References XX, XY, XZ, YX, YY, YZ, ZX, ZY, and ZZ.

350 {
351  Matrix3D result;
352  Mdouble det;
353  det = 1. / (A.XX * (A.YY * A.ZZ - A.YZ * A.ZY)
354  + A.XY * (A.YZ * A.ZX - A.YX * A.ZZ)
355  + A.XZ * (A.YX * A.ZY - A.YY * A.ZX));
356  result.XX = (A.YY * A.ZZ - A.YZ * A.ZY) * det;
357  result.XY = -(A.XY * A.ZZ - A.XZ * A.ZY) * det;
358  result.XZ = (A.XY * A.YZ - A.XZ * A.YY) * det;
359  result.YX = -(A.YX * A.ZZ - A.YZ * A.ZX) * det;
360  result.YY = (A.XX * A.ZZ - A.XZ * A.ZX) * det;
361  result.YZ = -(A.XX * A.YZ - A.XZ * A.YX) * det;
362  result.ZX = (A.YX * A.ZY - A.YY * A.ZX) * det;
363  result.ZY = -(A.XX * A.ZY - A.XY * A.ZX) * det;
364  result.ZZ = (A.XX * A.YY - A.XY * A.YX) * det;
365  return result;
366 }
Mdouble XY
Definition: Matrix.h:43
Mdouble ZY
Definition: Matrix.h:43
double Mdouble
Definition: GeneralDefine.h:34
Mdouble XZ
Definition: Matrix.h:43
Mdouble ZX
Definition: Matrix.h:43
Mdouble ZZ
Definition: Matrix.h:43
Mdouble YZ
Definition: Matrix.h:43
Mdouble YX
Definition: Matrix.h:43
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43
Implementation of a 3D matrix.
Definition: Matrix.h:37
Vec3D Matrix3D::ldivide ( const Vec3D b)

A.ldivide(b) computes the solution x to A*x=b.

Solve the linear system Ax = b: A.ldivide(b) computes the solution x to A*x=b.

Parameters
[in]bRight-handside in Ax = b, as a const-reference to a Vec3D
Returns
The solution x of Ax = b as a Vec3D.

Definition at line 373 of file Matrix.cc.

References Vec3D::X, XX, XY, XZ, Vec3D::Y, YX, YY, YZ, Vec3D::Z, ZX, ZY, and ZZ.

Referenced by BasicIntersectionOfWalls::getDistanceAndNormal().

374 {
375  Mdouble invdet = 1. / (XX * (YY * ZZ - YZ * ZY)
376  + XY * (YZ * ZX - YX * ZZ)
377  + XZ * (YX * ZY - YY * ZX));
378  return Vec3D(+(XY * YZ - YY * XZ) * b.Z
379  - (ZY * YZ - ZZ * YY) * b.X
380  + (ZY * XZ - ZZ * XY) * b.Y,
381  -(XX * YZ - XZ * YX) * b.Z
382  + (ZX * YZ - ZZ * YX) * b.X
383  - (ZX * XZ - XX * ZZ) * b.Y,
384  +(XX * YY - YX * XY) * b.Z
385  - (ZX * YY - YX * ZY) * b.X
386  + (ZX * XY - XX * ZY) * b.Y) * invdet;
387 }
Mdouble XY
Definition: Matrix.h:43
Mdouble X
the vector components
Definition: Vector.h:65
Mdouble ZY
Definition: Matrix.h:43
double Mdouble
Definition: GeneralDefine.h:34
Mdouble XZ
Definition: Matrix.h:43
Mdouble ZX
Definition: Matrix.h:43
Mdouble ZZ
Definition: Matrix.h:43
Mdouble YZ
Definition: Matrix.h:43
Mdouble YX
Definition: Matrix.h:43
Mdouble Y
Definition: Vector.h:65
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43
Definition: Vector.h:49
Mdouble Z
Definition: Vector.h:65
Matrix3D Matrix3D::operator* ( Mdouble  a) const

Scalar multiplication.

Multiplication with scalar

Parameters
[in]aScalar to be multiplied with
Returns
resulting matrix

Definition at line 164 of file Matrix.cc.

References Matrix3D(), XX, XY, XZ, YX, YY, YZ, ZX, ZY, and ZZ.

165 {
166  return Matrix3D(XX * a, XY * a, XZ * a,
167  YX * a, YY * a, YZ * a,
168  ZX * a, ZY * a, ZZ * a);
169 }
Mdouble XY
Definition: Matrix.h:43
Mdouble ZY
Definition: Matrix.h:43
Mdouble XZ
Definition: Matrix.h:43
Mdouble ZX
Definition: Matrix.h:43
Mdouble ZZ
Definition: Matrix.h:43
Mdouble YZ
Definition: Matrix.h:43
Mdouble YX
Definition: Matrix.h:43
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43
Matrix3D()
default constructor
Definition: Matrix.cc:34
Vec3D Matrix3D::operator* ( const Vec3D a) const

Vector multiplication.

Multiplication with vector

Parameters
[in]aVector to be multiplied with
Returns
Resulting vector

Definition at line 176 of file Matrix.cc.

References Vec3D::X, XX, XY, XZ, Vec3D::Y, YX, YY, YZ, Vec3D::Z, ZX, ZY, and ZZ.

177 {
178  return Vec3D(XX * a.X + XY * a.Y + XZ * a.Z,
179  YX * a.X + YY * a.Y + YZ * a.Z,
180  ZX * a.X + ZY * a.Y + ZZ * a.Z);
181 }
Mdouble XY
Definition: Matrix.h:43
Mdouble X
the vector components
Definition: Vector.h:65
Mdouble ZY
Definition: Matrix.h:43
Mdouble XZ
Definition: Matrix.h:43
Mdouble ZX
Definition: Matrix.h:43
Mdouble ZZ
Definition: Matrix.h:43
Mdouble YZ
Definition: Matrix.h:43
Mdouble YX
Definition: Matrix.h:43
Mdouble Y
Definition: Vector.h:65
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43
Definition: Vector.h:49
Mdouble Z
Definition: Vector.h:65
Matrix3D Matrix3D::operator* ( const Matrix3D a) const

Matrix multiplication.

Todo:
check

Definition at line 184 of file Matrix.cc.

References Matrix3D(), XX, XY, XZ, YX, YY, YZ, ZX, ZY, and ZZ.

185 {
186  return Matrix3D(XX * a.XX + XY * a.YX + XZ * a.ZX,
187  XX * a.XY + XY * a.YY + XZ * a.ZY,
188  XX * a.XZ + XY * a.YZ + XZ * a.ZZ,
189  YX * a.XX + YY * a.YX + YZ * a.ZX,
190  YX * a.XY + YY * a.YY + YZ * a.ZY,
191  YX * a.XZ + YY * a.YZ + YZ * a.ZZ,
192  ZX * a.XX + ZY * a.YX + ZZ * a.ZX,
193  ZX * a.XY + ZY * a.YY + ZZ * a.ZY,
194  ZX * a.XZ + ZY * a.YZ + ZZ * a.ZZ
195  );
196 }
Mdouble XY
Definition: Matrix.h:43
Mdouble ZY
Definition: Matrix.h:43
Mdouble XZ
Definition: Matrix.h:43
Mdouble ZX
Definition: Matrix.h:43
Mdouble ZZ
Definition: Matrix.h:43
Mdouble YZ
Definition: Matrix.h:43
Mdouble YX
Definition: Matrix.h:43
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43
Matrix3D()
default constructor
Definition: Matrix.cc:34
Matrix3D Matrix3D::operator+ ( const Matrix3D A) const

Matrix addition.

Addition of this matrix with given one

Parameters
[in]AMatrix to be added
Returns
resulting matrix

Definition at line 115 of file Matrix.cc.

References Matrix3D(), XX, XY, XZ, YX, YY, YZ, ZX, ZY, and ZZ.

116 {
117  return Matrix3D(XX + A.XX, XY + A.XY, XZ + A.XZ,
118  YX + A.YX, YY + A.YY, YZ + A.YZ,
119  ZX + A.ZX, ZY + A.ZY, ZZ + A.ZZ);
120 }
Mdouble XY
Definition: Matrix.h:43
Mdouble ZY
Definition: Matrix.h:43
Mdouble XZ
Definition: Matrix.h:43
Mdouble ZX
Definition: Matrix.h:43
Mdouble ZZ
Definition: Matrix.h:43
Mdouble YZ
Definition: Matrix.h:43
Mdouble YX
Definition: Matrix.h:43
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43
Matrix3D()
default constructor
Definition: Matrix.cc:34
Matrix3D Matrix3D::operator+ ( Mdouble  a) const

Scalar addition.

Addition of scalar

Parameters
[in]aScalar to be added
Returns
resulting matrix

Definition at line 140 of file Matrix.cc.

References Matrix3D(), XX, XY, XZ, YX, YY, YZ, ZX, ZY, and ZZ.

141 {
142  return Matrix3D(XX + a, XY + a, XZ + a,
143  YX + a, YY + a, YZ + a,
144  ZX + a, ZY + a, ZZ + a);
145 }
Mdouble XY
Definition: Matrix.h:43
Mdouble ZY
Definition: Matrix.h:43
Mdouble XZ
Definition: Matrix.h:43
Mdouble ZX
Definition: Matrix.h:43
Mdouble ZZ
Definition: Matrix.h:43
Mdouble YZ
Definition: Matrix.h:43
Mdouble YX
Definition: Matrix.h:43
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43
Matrix3D()
default constructor
Definition: Matrix.cc:34
Matrix3D & Matrix3D::operator+= ( const Matrix3D A)

Matrix addition.

Adds all elements of a given matrix to its own

Parameters
[in]A3D matrix to be added
Returns
(reference to) resulting (this) matrix

Definition at line 241 of file Matrix.cc.

References XX, XY, XZ, YX, YY, YZ, ZX, ZY, and ZZ.

242 {
243  XX += A.XX;
244  XY += A.XY;
245  XZ += A.XZ;
246  YX += A.YX;
247  YY += A.YY;
248  YZ += A.YZ;
249  ZX += A.ZX;
250  ZY += A.ZY;
251  ZZ += A.ZZ;
252  return *this;
253 }
Mdouble XY
Definition: Matrix.h:43
Mdouble ZY
Definition: Matrix.h:43
Mdouble XZ
Definition: Matrix.h:43
Mdouble ZX
Definition: Matrix.h:43
Mdouble ZZ
Definition: Matrix.h:43
Mdouble YZ
Definition: Matrix.h:43
Mdouble YX
Definition: Matrix.h:43
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43
Matrix3D Matrix3D::operator- ( const Matrix3D A) const

Matrix subtraction.

Substraction of given matrix from this one

Parameters
[in]AMatrix to be subtracted
Returns
resulting matrix

Definition at line 128 of file Matrix.cc.

References Matrix3D(), XX, XY, XZ, YX, YY, YZ, ZX, ZY, and ZZ.

129 {
130  return Matrix3D(XX - A.XX, XY - A.XY, XZ - A.XZ,
131  YX - A.YX, YY - A.YY, YZ - A.YZ,
132  ZX - A.ZX, ZY - A.ZY, ZZ - A.ZZ);
133 }
Mdouble XY
Definition: Matrix.h:43
Mdouble ZY
Definition: Matrix.h:43
Mdouble XZ
Definition: Matrix.h:43
Mdouble ZX
Definition: Matrix.h:43
Mdouble ZZ
Definition: Matrix.h:43
Mdouble YZ
Definition: Matrix.h:43
Mdouble YX
Definition: Matrix.h:43
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43
Matrix3D()
default constructor
Definition: Matrix.cc:34
Matrix3D Matrix3D::operator- ( Mdouble  a) const

Scalar subtraction.

Substraction of scalar

Parameters
[in]aScalar to be subtracted
Returns
resulting matrix

Definition at line 152 of file Matrix.cc.

References Matrix3D(), XX, XY, XZ, YX, YY, YZ, ZX, ZY, and ZZ.

153 {
154  return Matrix3D(XX - a, XY - a, XZ - a,
155  YX - a, YY - a, YZ - a,
156  ZX - a, ZY - a, ZZ - a);
157 }
Mdouble XY
Definition: Matrix.h:43
Mdouble ZY
Definition: Matrix.h:43
Mdouble XZ
Definition: Matrix.h:43
Mdouble ZX
Definition: Matrix.h:43
Mdouble ZZ
Definition: Matrix.h:43
Mdouble YZ
Definition: Matrix.h:43
Mdouble YX
Definition: Matrix.h:43
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43
Matrix3D()
default constructor
Definition: Matrix.cc:34
Matrix3D & Matrix3D::operator-= ( const Matrix3D A)

Matrix substraction.

Substract all elements of a given matrix from its own

Parameters
[in]A3D matrix to be subtracted
Returns
(reference to) resulting (this) matrix

Definition at line 260 of file Matrix.cc.

References XX, XY, XZ, YX, YY, YZ, ZX, ZY, and ZZ.

261 {
262  XX -= A.XX;
263  XY -= A.XY;
264  XZ -= A.XZ;
265  YX -= A.YX;
266  YY -= A.YY;
267  YZ -= A.YZ;
268  ZX -= A.ZX;
269  ZY -= A.ZY;
270  ZZ -= A.ZZ;
271  return *this;
272 }
Mdouble XY
Definition: Matrix.h:43
Mdouble ZY
Definition: Matrix.h:43
Mdouble XZ
Definition: Matrix.h:43
Mdouble ZX
Definition: Matrix.h:43
Mdouble ZZ
Definition: Matrix.h:43
Mdouble YZ
Definition: Matrix.h:43
Mdouble YX
Definition: Matrix.h:43
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43
Matrix3D Matrix3D::operator/ ( Mdouble  a) const

Scalar division.

Division by a scalar

Parameters
[in]ascalar to be divided by
Returns
resulting matrix

Definition at line 203 of file Matrix.cc.

References Matrix3D(), XX, XY, XZ, YX, YY, YZ, ZX, ZY, and ZZ.

204 {
205  return Matrix3D(XX / a, XY / a, XZ / a,
206  YX / a, YY / a, YZ / a,
207  ZX / a, ZY / a, ZZ / a);
208 }
Mdouble XY
Definition: Matrix.h:43
Mdouble ZY
Definition: Matrix.h:43
Mdouble XZ
Definition: Matrix.h:43
Mdouble ZX
Definition: Matrix.h:43
Mdouble ZZ
Definition: Matrix.h:43
Mdouble YZ
Definition: Matrix.h:43
Mdouble YX
Definition: Matrix.h:43
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43
Matrix3D()
default constructor
Definition: Matrix.cc:34
Matrix3D & Matrix3D::operator/= ( Mdouble  a)

Scalar division.

Division by a scalar

Parameters
[in]ascalar to be divided by
Returns
(reference to) resulting (this) matrix

Definition at line 279 of file Matrix.cc.

References XX, XY, XZ, YX, YY, YZ, ZX, ZY, and ZZ.

280 {
281  XX /= a;
282  XY /= a;
283  XZ /= a;
284  YX /= a;
285  YY /= a;
286  YZ /= a;
287  ZX /= a;
288  ZY /= a;
289  ZZ /= a;
290  return *this;
291 }
Mdouble XY
Definition: Matrix.h:43
Mdouble ZY
Definition: Matrix.h:43
Mdouble XZ
Definition: Matrix.h:43
Mdouble ZX
Definition: Matrix.h:43
Mdouble ZZ
Definition: Matrix.h:43
Mdouble YZ
Definition: Matrix.h:43
Mdouble YX
Definition: Matrix.h:43
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43
void Matrix3D::setZero ( )

Sets all elements to zero.

Sets all elements to zero.

Definition at line 75 of file Matrix.cc.

References XX, XY, XZ, YX, YY, YZ, ZX, ZY, and ZZ.

Referenced by Matrix3D(), CGFields::GradVelocityField::setZero(), CGFields::StandardFields::setZero(), and StressStrainControlBoundary::StressStrainControlBoundary().

76 {
77  XX = XY = XZ = YX = YY = YZ = ZX = ZY = ZZ = 0.0;
78 }
Mdouble XY
Definition: Matrix.h:43
Mdouble ZY
Definition: Matrix.h:43
Mdouble XZ
Definition: Matrix.h:43
Mdouble ZX
Definition: Matrix.h:43
Mdouble ZZ
Definition: Matrix.h:43
Mdouble YZ
Definition: Matrix.h:43
Mdouble YX
Definition: Matrix.h:43
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43
Matrix3D Matrix3D::sqrt ( const Matrix3D A)
static

Calculates the pointwise square root.

Takes the square root of all the elements in given matrix

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

Definition at line 310 of file Matrix.cc.

References Matrix3D(), XX, XY, XZ, YX, YY, YZ, ZX, ZY, and ZZ.

311 {
312  return Matrix3D(std::sqrt(A.XX), std::sqrt(A.XY), std::sqrt(A.XZ),
313  std::sqrt(A.YX), std::sqrt(A.YY), std::sqrt(A.YZ),
314  std::sqrt(A.ZX), std::sqrt(A.ZY), std::sqrt(A.ZZ));
315 }
Mdouble XY
Definition: Matrix.h:43
Mdouble ZY
Definition: Matrix.h:43
Mdouble XZ
Definition: Matrix.h:43
Mdouble ZX
Definition: Matrix.h:43
Mdouble ZZ
Definition: Matrix.h:43
Mdouble YZ
Definition: Matrix.h:43
Mdouble YX
Definition: Matrix.h:43
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43
Matrix3D()
default constructor
Definition: Matrix.cc:34
Matrix3D Matrix3D::square ( const Matrix3D A)
static

Calculates the pointwise square.

Squares all the elements in given matrix

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

Definition at line 298 of file Matrix.cc.

References Matrix3D(), mathsFunc::square(), XX, XY, XZ, YX, YY, YZ, ZX, ZY, and ZZ.

Referenced by CGFields::GradVelocityField::getSquared(), and CGFields::StandardFields::getSquared().

299 {
303 }
Mdouble XY
Definition: Matrix.h:43
Mdouble ZY
Definition: Matrix.h:43
Mdouble XZ
Definition: Matrix.h:43
Mdouble ZX
Definition: Matrix.h:43
Mdouble ZZ
Definition: Matrix.h:43
Mdouble YZ
Definition: Matrix.h:43
Mdouble YX
Definition: Matrix.h:43
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43
T square(const T val)
squares a number
Definition: ExtendedMath.h:104
Matrix3D()
default constructor
Definition: Matrix.cc:34
Mdouble Matrix3D::trace ( ) const

Sum of the diagonal elements.

Returns the sum of the diagonal elements of the matrix.

Returns
The trace of the matrix divided by 3 as an Mdouble

Definition at line 84 of file Matrix.cc.

References XX, YY, and ZZ.

Referenced by deviator().

85 {
86  return XX + YY + ZZ;
87 }
Mdouble ZZ
Definition: Matrix.h:43
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const Matrix3D A 
)
friend

Add elements to ostream.

Adds all elements of a matrix to an ostream

Parameters
[out]osoutput stream
[in]A3D matrix
Returns
output stream with matrix elements added

Definition at line 216 of file Matrix.cc.

217 {
218  os << A.XX << ' ' << A.XY << ' ' << A.XZ << ' '
219  << A.YX << ' ' << A.YY << ' ' << A.YZ << ' '
220  << A.ZX << ' ' << A.ZY << ' ' << A.ZZ;
221  return os;
222 }
Mdouble XY
Definition: Matrix.h:43
Mdouble ZY
Definition: Matrix.h:43
Mdouble XZ
Definition: Matrix.h:43
Mdouble ZX
Definition: Matrix.h:43
Mdouble ZZ
Definition: Matrix.h:43
Mdouble YZ
Definition: Matrix.h:43
Mdouble YX
Definition: Matrix.h:43
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43
std::istream& operator>> ( std::istream &  is,
Matrix3D A 
)
friend

Add elements to istream.

Reads the elements of a matrix from an istream

Parameters
[in,out]isinput stream
[out]A3D matrix
Returns
is input stream after the read operation.

Definition at line 230 of file Matrix.cc.

231 {
232  is >> A.XX >> A.XY >> A.XZ >> A.YX >> A.YY >> A.YZ >> A.ZX >> A.ZY >> A.ZZ;
233  return is;
234 }
Mdouble XY
Definition: Matrix.h:43
Mdouble ZY
Definition: Matrix.h:43
Mdouble XZ
Definition: Matrix.h:43
Mdouble ZX
Definition: Matrix.h:43
Mdouble ZZ
Definition: Matrix.h:43
Mdouble YZ
Definition: Matrix.h:43
Mdouble YX
Definition: Matrix.h:43
Mdouble XX
all nine matrix elements
Definition: Matrix.h:43
Mdouble YY
Definition: Matrix.h:43

Member Data Documentation


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