MercuryDPM  Alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MatrixSymmetric.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2014, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 #ifndef MATRIXSYMMETRIC_H
27 #define MATRIXSYMMETRIC_H
28 
29 #include <cmath>
30 #include <sstream>
31 #include "Matrix.h"
32 
37 {
38 public:
42  Mdouble XX, XY, XZ, YY, YZ, ZZ;
43 
47  operator Matrix3D() const;
48 
53 
57  MatrixSymmetric3D(const Mdouble xx, const Mdouble xy, const Mdouble xz, const Mdouble yy, const Mdouble yz, const Mdouble zz);
58 
62  void setZero();
63 
67  Mdouble trace() const;
68 
73 
78 
82  MatrixSymmetric3D operator +(const Mdouble a) const;
83 
87  MatrixSymmetric3D operator -(const Mdouble a) const;
88 
92  friend Vec3D operator *(const MatrixSymmetric3D& A, const Vec3D& b);
93 
97  MatrixSymmetric3D operator *(const Mdouble a) const;
98 
102  MatrixSymmetric3D operator /(const Mdouble a) const;
103 
107  friend std::ostream& operator<<(std::ostream& os, const MatrixSymmetric3D& A);
108 
112  friend std::istream& operator>>(std::istream& is, MatrixSymmetric3D& A);
113 
118 
123 
128 
133 
137  static MatrixSymmetric3D sqrt(const MatrixSymmetric3D& A);
138 
142  static MatrixSymmetric3D selfDyadic(const Vec3D& a);
143 
147  static MatrixSymmetric3D symmetrisedDyadic(const Vec3D& a, const Vec3D& b);
148 };
149 
150 #endif
static MatrixSymmetric3D square(const MatrixSymmetric3D &A)
Calculates the pointwise square.
MatrixSymmetric3D & operator-=(const MatrixSymmetric3D &A)
Matrix substraction.
friend std::istream & operator>>(std::istream &is, MatrixSymmetric3D &A)
Add elements to an istream.
double Mdouble
friend std::ostream & operator<<(std::ostream &os, const MatrixSymmetric3D &A)
Add elements to an ostream.
MatrixSymmetric3D operator+(const MatrixSymmetric3D &A) const
Matrix addition.
MatrixSymmetric3D & operator/=(const Mdouble a)
Scalar division.
void setZero()
Sets all elements to zero.
MatrixSymmetric3D operator-(const MatrixSymmetric3D &A) const
Matrix substraction.
MatrixSymmetric3D & operator+=(const MatrixSymmetric3D &A)
Matrix addition.
static MatrixSymmetric3D symmetrisedDyadic(const Vec3D &a, const Vec3D &b)
Calculates the symmetrised dyadic product of two Vec3D: .
static MatrixSymmetric3D selfDyadic(const Vec3D &a)
Calculates the dyadic product of a Vec3D with itself: .
MatrixSymmetric3D operator/(const Mdouble a) const
Scalar division.
MatrixSymmetric3D()
Default constructor.
friend Vec3D operator*(const MatrixSymmetric3D &A, const Vec3D &b)
Vector multiplication.
Implementation of a 3D matrix.
Definition: Matrix.h:36
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
Mdouble trace() const
Returns the MEAN of the diagonal elements (i.e. the trace divided by three).
static MatrixSymmetric3D sqrt(const MatrixSymmetric3D &A)
Calculates the pointwise square root.
Implementation of a 3D symmetric matrix.
Mdouble XX
The six distinctive matrix elements.