PeriDEM 0.2.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
util::SymMatrix3 Struct Reference

A structure to represent 3d matrices. More...

#include <matrix.h>

Collaboration diagram for util::SymMatrix3:

Public Member Functions

 SymMatrix3 ()
 Constructor.
 
 SymMatrix3 (const util::Point &diagonal)
 Constructor.
 
 SymMatrix3 (const std::vector< double > &m)
 Constructor.
 
 SymMatrix3 (const std::vector< std::vector< double > > &m)
 Constructor.
 
 SymMatrix3 (const Matrix3 &m)
 Constructor.
 
 SymMatrix3 (const SymMatrix3 &m)
 Constructor.
 
std::string printStr (int nt=0, int lvl=0) const
 Returns the string containing printable information about the object.
 
void print (int nt=0, int lvl=0) const
 Prints the information about the object.
 
Point operator() (size_t i)
 Returns row of matrix.
 
Point operator() (size_t i) const
 Returns row of matrix.
 
float & operator() (size_t i, size_t j)
 Returns element of matrix.
 
const float & operator() (size_t i, size_t j) const
 Returns element of matrix.
 
float & get (size_t i)
 Returns row of matrix.
 
const float & get (size_t i) const
 Returns row of matrix.
 
void copy (double m[6]) const
 Copy.
 
util::Point dot (const util::Point &v)
 Computes the dot product of this matrix with another vector.
 
std::vector< double > dot (const std::vector< double > &v) const
 Computes the dot product of this matrix with another vector.
 
SymMatrix3 transpose () const
 Computes the tranpose of matrix.
 
double det () const
 Computes the determinant of matrix.
 
SymMatrix3 inv () const
 Computes the determinant of matrix.
 

Data Fields

Data members

0 - xx component 1 - yy component 2 - zz component 3 - yz component 4 - xz component 5 - xy component

float d_data [6] {}
 data
 

Detailed Description

A structure to represent 3d matrices.

Definition at line 258 of file matrix.h.

Constructor & Destructor Documentation

◆ SymMatrix3() [1/6]

util::SymMatrix3::SymMatrix3 ( )
inline

Constructor.

Definition at line 280 of file matrix.h.

280 {
281
282 d_data[0] = 0.;
283 d_data[1] = 0.;
284 d_data[2] = 0.;
285 d_data[3] = 0.;
286 d_data[4] = 0.;
287 d_data[5] = 0.;
288 };
float d_data[6]
data
Definition matrix.h:273

References d_data.

Referenced by inv().

Here is the caller graph for this function:

◆ SymMatrix3() [2/6]

util::SymMatrix3::SymMatrix3 ( const util::Point diagonal)
inline

Constructor.

Parameters
diagonalDiagonal vector

Definition at line 295 of file matrix.h.

295 {
296
297 d_data[0] = diagonal.d_x;
298 d_data[1] = diagonal.d_y;
299 d_data[2] = diagonal.d_z;
300
301 d_data[3] = 0.;
302 d_data[4] = 0.;
303 d_data[5] = 0.;
304 };
double d_y
the y coordinate
Definition point.h:36
double d_z
the z coordinate
Definition point.h:39
double d_x
the x coordinate
Definition point.h:33

References d_data, util::Point::d_x, util::Point::d_y, and util::Point::d_z.

◆ SymMatrix3() [3/6]

util::SymMatrix3::SymMatrix3 ( const std::vector< double > &  m)
inline

Constructor.

Parameters
mMatrix in vector template

Definition at line 311 of file matrix.h.

311 {
312
313 d_data[0] = m[0];
314 d_data[1] = m[1];
315 d_data[2] = m[2];
316 d_data[3] = m[3];
317 d_data[4] = m[4];
318 d_data[5] = m[5];
319 }

References d_data.

◆ SymMatrix3() [4/6]

util::SymMatrix3::SymMatrix3 ( const std::vector< std::vector< double > > &  m)
inline

Constructor.

Parameters
mMatrix

Definition at line 326 of file matrix.h.

326 {
327
328 d_data[0] = m[0][0];
329 d_data[1] = m[1][1];
330 d_data[2] = m[2][2];
331 d_data[3] = 0.5 * (m[1][2] + m[2][1]);
332 d_data[4] = 0.5 * (m[0][2] + m[2][0]);
333 d_data[5] = 0.5 * (m[0][1] + m[1][0]);
334 }

References d_data.

◆ SymMatrix3() [5/6]

util::SymMatrix3::SymMatrix3 ( const Matrix3 m)
inline

Constructor.

Parameters
mMatrix

Definition at line 341 of file matrix.h.

341 {
342
343 d_data[0] = m(0,0);
344 d_data[1] = m(1,1);
345 d_data[2] = m(2,2);
346 d_data[3] = 0.5 * (m(1,2) + m(2,1));
347 d_data[4] = 0.5 * (m(0,2) + m(2,0));
348 d_data[5] = 0.5 * (m(0,1) + m(1,0));
349 }

References d_data.

◆ SymMatrix3() [6/6]

util::SymMatrix3::SymMatrix3 ( const SymMatrix3 m)
inline

Constructor.

Parameters
mMatrix

Definition at line 356 of file matrix.h.

356 {
357
358 for (size_t i=0; i<6; i++)
359 d_data[i] = m.d_data[i];
360 }

References d_data.

Member Function Documentation

◆ copy()

void util::SymMatrix3::copy ( double  m[6]) const
inline

Copy.

Parameters
mSymmetric matrix in vector form

Definition at line 443 of file matrix.h.

443 {
444
445 for (size_t i=0; i<6; i++)
446 m[i] = d_data[i];
447 }

References d_data.

◆ det()

double util::SymMatrix3::det ( ) const
inline

Computes the determinant of matrix.

Returns
det Determinant

Definition at line 484 of file matrix.h.

484 {
485 return (*this)(0,0) * ((*this)(1,1) * (*this)(2,2) - (*this)(2,1) * (*this)(1,2)) -
486 (*this)(0,1) * ((*this)(1,0) * (*this)(2,2) - (*this)(2,0) * (*this)(1,2)) +
487 (*this)(0,2) * ((*this)(1,0) * (*this)(2,1) - (*this)(2,0) * (*this)(1,1));
488 }

Referenced by inv().

Here is the caller graph for this function:

◆ dot() [1/2]

std::vector< double > util::SymMatrix3::dot ( const std::vector< double > &  v) const
inline

Computes the dot product of this matrix with another vector.

Parameters
vA vector
Returns
Vector Resulting vector

Definition at line 460 of file matrix.h.

460 {
461
462 auto r = std::vector<double>(3,0.);
463 for (size_t i=0; i<3; i++)
464 for (size_t j=0; j<3; j++)
465 r[i] += (*this)(i,j) * v[j];
466
467 return r;
468 }

◆ dot() [2/2]

util::Point util::SymMatrix3::dot ( const util::Point v)
inline

Computes the dot product of this matrix with another vector.

Parameters
vA vector
Returns
Vector Resulting vector

Definition at line 454 of file matrix.h.

454 {
455
456 return {(*this)(0) * v, (*this)(1) * v, (*this)(2) * v};
457 }

◆ get() [1/2]

float & util::SymMatrix3::get ( size_t  i)
inline

Returns row of matrix.

Parameters
iRow id
Returns
Row Row

Definition at line 429 of file matrix.h.

429 {
430 return d_data[i];
431 }

References d_data.

◆ get() [2/2]

const float & util::SymMatrix3::get ( size_t  i) const
inline

Returns row of matrix.

Parameters
iRow id
Returns
Row Row

Definition at line 434 of file matrix.h.

434 {
435 return d_data[i];
436 }

References d_data.

◆ inv()

SymMatrix3 util::SymMatrix3::inv ( ) const
inline

Computes the determinant of matrix.

Returns
inv Inverse of m

Definition at line 495 of file matrix.h.

495 {
496
498
499 auto det_inv = 1. / this->det();
500
501 m(0,0) = det_inv *
502 ((*this)(1,1) * (*this)(2,2) - (*this)(2,1) * (*this)(1,2));
503 m(0,1) = -det_inv *
504 ((*this)(0,1) * (*this)(2,2) - (*this)(2,1) * (*this)(0,2));
505 m(0,2) = det_inv *
506 ((*this)(0,1) * (*this)(1,2) - (*this)(1,1) * (*this)(0,2));
507
508 m(1,0) = -det_inv *
509 ((*this)(1,0) * (*this)(2,2) - (*this)(2,0) * (*this)(1,2));
510 m(1,1) = det_inv *
511 ((*this)(0,0) * (*this)(2,2) - (*this)(2,0) * (*this)(0,2));
512 m(1,2) = -det_inv *
513 ((*this)(0,0) * (*this)(1,2) - (*this)(1,0) * (*this)(0,2));
514
515 m(2,0) = det_inv *
516 ((*this)(1,0) * (*this)(2,1) - (*this)(2,0) * (*this)(1,1));
517 m(2,1) = -det_inv *
518 ((*this)(0,0) * (*this)(2,1) - (*this)(2,0) * (*this)(0,1));
519 m(2,2) = det_inv *
520 ((*this)(0,0) * (*this)(1,1) - (*this)(1,0) * (*this)(0,1));
521
522 return m;
523 }
SymMatrix3()
Constructor.
Definition matrix.h:280
double det() const
Computes the determinant of matrix.
Definition matrix.h:484

References det(), and SymMatrix3().

Here is the call graph for this function:

◆ operator()() [1/4]

Point util::SymMatrix3::operator() ( size_t  i)
inline

Returns row of matrix.

Parameters
iRow id
Returns
Row Row

Definition at line 398 of file matrix.h.

398 {
399 return {(*this)(i, 0), (*this)(i, 1), (*this)(i, 2)};
400 }

◆ operator()() [2/4]

Point util::SymMatrix3::operator() ( size_t  i) const
inline

Returns row of matrix.

Parameters
iRow id
Returns
Row Row

Definition at line 403 of file matrix.h.

403 {
404 return {(*this)(i, 0), (*this)(i, 1), (*this)(i, 2)};
405 }

◆ operator()() [3/4]

float & util::SymMatrix3::operator() ( size_t  i,
size_t  j 
)
inline

Returns element of matrix.

Parameters
iRow id
jColumn id
Returns
Element Element of matrix

Definition at line 414 of file matrix.h.

414 {
415 return d_data[i == j ? i : 6 - i - j];
416 }

References d_data.

◆ operator()() [4/4]

const float & util::SymMatrix3::operator() ( size_t  i,
size_t  j 
) const
inline

Returns element of matrix.

Parameters
iRow id
jColumn id
Returns
Element Element of matrix

Definition at line 419 of file matrix.h.

419 {
420 return d_data[i == j ? i : 6 - i - j];
421 }

References d_data.

◆ print()

void util::SymMatrix3::print ( int  nt = 0,
int  lvl = 0 
) const
inline

Prints the information about the object.

Parameters
ntNumber of tabs to append before printing
lvlInformation level (higher means more information)

Definition at line 390 of file matrix.h.

390{ std::cout << printStr(nt, lvl); }
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.
Definition matrix.h:369

References printStr().

Here is the call graph for this function:

◆ printStr()

std::string util::SymMatrix3::printStr ( int  nt = 0,
int  lvl = 0 
) const
inline

Returns the string containing printable information about the object.

Parameters
ntNumber of tabs to append before printing
lvlInformation level (higher means more information)
Returns
string String containing printable information about the object

Definition at line 369 of file matrix.h.

369 {
370
371 std::string tabS = "";
372 for (int i = 0; i < nt; i++)
373 tabS += "\t";
374
375 std::ostringstream oss;
376 for (size_t i=0; i<3; i++)
377 oss << tabS << "[" << (*this)(i, 0) << ", " << (*this)(i, 1) << ", "
378 << (*this)(i, 2) << "]" << std::endl;
379 oss << std::endl;
380
381 return oss.str();
382 }

Referenced by print().

Here is the caller graph for this function:

◆ transpose()

SymMatrix3 util::SymMatrix3::transpose ( ) const
inline

Computes the tranpose of matrix.

Returns
Matrix Transpose of m

Definition at line 474 of file matrix.h.

474 {
475
476 return (*this);
477 }

Field Documentation

◆ d_data

float util::SymMatrix3::d_data[6] {}

data

Definition at line 273 of file matrix.h.

273{};

Referenced by copy(), get(), get(), operator()(), operator()(), SymMatrix3(), SymMatrix3(), SymMatrix3(), SymMatrix3(), SymMatrix3(), and SymMatrix3().


The documentation for this struct was generated from the following file: