OpenMD 3.0
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
OpenMD::RectMatrix< Real, Row, Col > Class Template Reference

rectangular matrix class More...

#include "math/RectMatrix.hpp"

+ Inheritance diagram for OpenMD::RectMatrix< Real, Row, Col >:

Public Types

using ElemType = Real
 
using ElemPoinerType = Real*
 

Public Member Functions

 RectMatrix ()
 default constructor
 
 RectMatrix (Real s)
 Constructs and initializes every element of this matrix to a scalar.
 
 RectMatrix (Real *array)
 
 RectMatrix (const RectMatrix< Real, Row, Col > &m)
 copy constructor
 
 ~RectMatrix ()
 destructor
 
RectMatrix< Real, Row, Col > & operator= (const RectMatrix< Real, Row, Col > &m)
 copy assignment operator
 
Real & operator() (unsigned int i, unsigned int j)
 Return the reference of a single element of this matrix.
 
Real operator() (unsigned int i, unsigned int j) const
 Return the value of a single element of this matrix.
 
void getArray (Real *array)
 Copy the internal data to an array.
 
Real * getArrayPointer ()
 Returns the pointer of internal array.
 
Vector< Real, Row > getRow (unsigned int row)
 Returns a row of this matrix as a vector.
 
void setRow (unsigned int row, const Vector< Real, Row > &v)
 Sets a row of this matrix.
 
Vector< Real, Col > getColumn (unsigned int col)
 Returns a column of this matrix as a vector.
 
void setColumn (unsigned int col, const Vector< Real, Col > &v)
 Sets a column of this matrix.
 
void swapRow (unsigned int i, unsigned int j)
 swap two rows of this matrix
 
void swapColumn (unsigned int i, unsigned int j)
 swap two Columns of this matrix
 
bool operator== (const RectMatrix< Real, Row, Col > &m)
 Tests if this matrix is identical to matrix m.
 
bool operator!= (const RectMatrix< Real, Row, Col > &m)
 Tests if this matrix is not equal to matrix m.
 
void negate ()
 Negates the value of this matrix in place.
 
void negate (const RectMatrix< Real, Row, Col > &m)
 Sets the value of this matrix to the negation of matrix m.
 
void add (const RectMatrix< Real, Row, Col > &m)
 Sets the value of this matrix to the sum of itself and m (*this += m).
 
void add (const RectMatrix< Real, Row, Col > &m1, const RectMatrix< Real, Row, Col > &m2)
 Sets the value of this matrix to the sum of m1 and m2 (*this = m1 + m2).
 
void sub (const RectMatrix< Real, Row, Col > &m)
 Sets the value of this matrix to the difference of itself and m (*this -= m).
 
void sub (const RectMatrix< Real, Row, Col > &m1, const RectMatrix< Real, Row, Col > &m2)
 Sets the value of this matrix to the difference of matrix m1 and m2 (*this = m1 - m2).
 
void mul (Real s)
 Sets the value of this matrix to the scalar multiplication of itself (*this *= s).
 
void mul (Real s, const RectMatrix< Real, Row, Col > &m)
 Sets the value of this matrix to the scalar multiplication of matrix m (*this = s * m).
 
void div (Real s)
 Sets the value of this matrix to the scalar division of itself (*this /= s ).
 
void div (Real s, const RectMatrix< Real, Row, Col > &m)
 Sets the value of this matrix to the scalar division of matrix m (*this = m /s).
 
RectMatrix< Real, Row, Col > & operator*= (const Real s)
 Multiples a scalar into every element of this matrix.
 
RectMatrix< Real, Row, Col > & operator/= (const Real s)
 Divides every element of this matrix by a scalar.
 
RectMatrix< Real, Row, Col > & operator+= (const RectMatrix< Real, Row, Col > &m)
 Sets the value of this matrix to the sum of the other matrix and itself (*this += m).
 
RectMatrix< Real, Row, Col > & operator-= (const RectMatrix< Real, Row, Col > &m)
 Sets the value of this matrix to the differerence of itself and the other matrix (*this -= m)
 
RectMatrix< Real, Col, Row > transpose () const
 Return the transpose of this matrix.
 
template<class MatrixType >
void setSubMatrix (unsigned int beginRow, unsigned int beginCol, const MatrixType &m)
 
template<class MatrixType >
void getSubMatrix (unsigned int beginRow, unsigned int beginCol, MatrixType &m)
 
unsigned int getNRow () const
 
unsigned int getNCol () const
 
Real frobeniusNorm ()
 

Protected Attributes

Real data_ [Row][Col]
 

Detailed Description

template<typename Real, unsigned int Row, unsigned int Col>
class OpenMD::RectMatrix< Real, Row, Col >

rectangular matrix class

Definition at line 66 of file RectMatrix.hpp.

Member Typedef Documentation

◆ ElemPoinerType

template<typename Real , unsigned int Row, unsigned int Col>
using OpenMD::RectMatrix< Real, Row, Col >::ElemPoinerType = Real*

Definition at line 69 of file RectMatrix.hpp.

◆ ElemType

template<typename Real , unsigned int Row, unsigned int Col>
using OpenMD::RectMatrix< Real, Row, Col >::ElemType = Real

Definition at line 68 of file RectMatrix.hpp.

Constructor & Destructor Documentation

◆ RectMatrix() [1/4]

template<typename Real , unsigned int Row, unsigned int Col>
OpenMD::RectMatrix< Real, Row, Col >::RectMatrix ( )
inline

default constructor

Definition at line 72 of file RectMatrix.hpp.

◆ RectMatrix() [2/4]

template<typename Real , unsigned int Row, unsigned int Col>
OpenMD::RectMatrix< Real, Row, Col >::RectMatrix ( Real s)
inline

Constructs and initializes every element of this matrix to a scalar.

Definition at line 79 of file RectMatrix.hpp.

◆ RectMatrix() [3/4]

template<typename Real , unsigned int Row, unsigned int Col>
OpenMD::RectMatrix< Real, Row, Col >::RectMatrix ( Real * array)
inline

Definition at line 85 of file RectMatrix.hpp.

◆ RectMatrix() [4/4]

template<typename Real , unsigned int Row, unsigned int Col>
OpenMD::RectMatrix< Real, Row, Col >::RectMatrix ( const RectMatrix< Real, Row, Col > & m)
inline

copy constructor

Definition at line 92 of file RectMatrix.hpp.

◆ ~RectMatrix()

template<typename Real , unsigned int Row, unsigned int Col>
OpenMD::RectMatrix< Real, Row, Col >::~RectMatrix ( )
inline

destructor

Definition at line 95 of file RectMatrix.hpp.

Member Function Documentation

◆ add() [1/2]

template<typename Real , unsigned int Row, unsigned int Col>
void OpenMD::RectMatrix< Real, Row, Col >::add ( const RectMatrix< Real, Row, Col > & m)
inline

Sets the value of this matrix to the sum of itself and m (*this += m).

Parameters
mthe other matrix

Definition at line 262 of file RectMatrix.hpp.

Referenced by OpenMD::operator+(), and OpenMD::RectMatrix< Real, Row, Col >::operator+=().

◆ add() [2/2]

template<typename Real , unsigned int Row, unsigned int Col>
void OpenMD::RectMatrix< Real, Row, Col >::add ( const RectMatrix< Real, Row, Col > & m1,
const RectMatrix< Real, Row, Col > & m2 )
inline

Sets the value of this matrix to the sum of m1 and m2 (*this = m1 + m2).

Parameters
m1the first matrix
m2the second matrix

Definition at line 273 of file RectMatrix.hpp.

◆ div() [1/2]

template<typename Real , unsigned int Row, unsigned int Col>
void OpenMD::RectMatrix< Real, Row, Col >::div ( Real s)
inline

Sets the value of this matrix to the scalar division of itself (*this /= s ).

Parameters
sthe scalar value

Definition at line 332 of file RectMatrix.hpp.

Referenced by OpenMD::operator/(), and OpenMD::RectMatrix< Real, Row, Col >::operator/=().

◆ div() [2/2]

template<typename Real , unsigned int Row, unsigned int Col>
void OpenMD::RectMatrix< Real, Row, Col >::div ( Real s,
const RectMatrix< Real, Row, Col > & m )
inline

Sets the value of this matrix to the scalar division of matrix m (*this = m /s).

Parameters
sthe scalar value
mthe matrix

Definition at line 344 of file RectMatrix.hpp.

◆ frobeniusNorm()

template<typename Real , unsigned int Row, unsigned int Col>
Real OpenMD::RectMatrix< Real, Row, Col >::frobeniusNorm ( )
inline

Definition at line 426 of file RectMatrix.hpp.

◆ getArray()

template<typename Real , unsigned int Row, unsigned int Col>
void OpenMD::RectMatrix< Real, Row, Col >::getArray ( Real * array)
inline

Copy the internal data to an array.

Parameters
arraythe pointer of destination array

Definition at line 132 of file RectMatrix.hpp.

◆ getArrayPointer()

template<typename Real , unsigned int Row, unsigned int Col>
Real * OpenMD::RectMatrix< Real, Row, Col >::getArrayPointer ( )
inline

Returns the pointer of internal array.

Definition at line 141 of file RectMatrix.hpp.

Referenced by OpenMD::Thermo::getInertiaTensor().

◆ getColumn()

template<typename Real , unsigned int Row, unsigned int Col>
Vector< Real, Col > OpenMD::RectMatrix< Real, Row, Col >::getColumn ( unsigned int col)
inline

Returns a column of this matrix as a vector.

Returns
a column of this matrix as a vector
Parameters
colthe column index

Definition at line 172 of file RectMatrix.hpp.

◆ getNCol()

template<typename Real , unsigned int Row, unsigned int Col>
unsigned int OpenMD::RectMatrix< Real, Row, Col >::getNCol ( ) const
inline

Definition at line 424 of file RectMatrix.hpp.

◆ getNRow()

template<typename Real , unsigned int Row, unsigned int Col>
unsigned int OpenMD::RectMatrix< Real, Row, Col >::getNRow ( ) const
inline

Definition at line 423 of file RectMatrix.hpp.

◆ getRow()

template<typename Real , unsigned int Row, unsigned int Col>
Vector< Real, Row > OpenMD::RectMatrix< Real, Row, Col >::getRow ( unsigned int row)
inline

Returns a row of this matrix as a vector.

Returns
a row of this matrix as a vector
Parameters
rowthe row index

Definition at line 148 of file RectMatrix.hpp.

Referenced by OpenMD::SquareMatrix3< Real >::diagonalize().

◆ getSubMatrix()

template<typename Real , unsigned int Row, unsigned int Col>
template<class MatrixType >
void OpenMD::RectMatrix< Real, Row, Col >::getSubMatrix ( unsigned int beginRow,
unsigned int beginCol,
MatrixType & m )
inline

Definition at line 413 of file RectMatrix.hpp.

◆ mul() [1/2]

template<typename Real , unsigned int Row, unsigned int Col>
void OpenMD::RectMatrix< Real, Row, Col >::mul ( Real s)
inline

Sets the value of this matrix to the scalar multiplication of itself (*this *= s).

Parameters
sthe scalar value

Definition at line 309 of file RectMatrix.hpp.

Referenced by OpenMD::operator*(), OpenMD::operator*(), and OpenMD::RectMatrix< Real, Row, Col >::operator*=().

◆ mul() [2/2]

template<typename Real , unsigned int Row, unsigned int Col>
void OpenMD::RectMatrix< Real, Row, Col >::mul ( Real s,
const RectMatrix< Real, Row, Col > & m )
inline

Sets the value of this matrix to the scalar multiplication of matrix m (*this = s * m).

Parameters
sthe scalar value
mthe matrix

Definition at line 321 of file RectMatrix.hpp.

◆ negate() [1/2]

template<typename Real , unsigned int Row, unsigned int Col>
void OpenMD::RectMatrix< Real, Row, Col >::negate ( )
inline

Negates the value of this matrix in place.

Definition at line 242 of file RectMatrix.hpp.

Referenced by OpenMD::operator-().

◆ negate() [2/2]

template<typename Real , unsigned int Row, unsigned int Col>
void OpenMD::RectMatrix< Real, Row, Col >::negate ( const RectMatrix< Real, Row, Col > & m)
inline

Sets the value of this matrix to the negation of matrix m.

Parameters
mthe source matrix

Definition at line 252 of file RectMatrix.hpp.

◆ operator!=()

template<typename Real , unsigned int Row, unsigned int Col>
bool OpenMD::RectMatrix< Real, Row, Col >::operator!= ( const RectMatrix< Real, Row, Col > & m)
inline

Tests if this matrix is not equal to matrix m.

Returns
true if this matrix is not equal to the matrix m, return false otherwise
Parameters
mmatrix to be compared

Definition at line 237 of file RectMatrix.hpp.

◆ operator()() [1/2]

template<typename Real , unsigned int Row, unsigned int Col>
Real & OpenMD::RectMatrix< Real, Row, Col >::operator() ( unsigned int i,
unsigned int j )
inline

Return the reference of a single element of this matrix.

Returns
the reference of a single element of this matrix
Parameters
irow index
jColumn index

Definition at line 113 of file RectMatrix.hpp.

◆ operator()() [2/2]

template<typename Real , unsigned int Row, unsigned int Col>
Real OpenMD::RectMatrix< Real, Row, Col >::operator() ( unsigned int i,
unsigned int j ) const
inline

Return the value of a single element of this matrix.

Returns
the value of a single element of this matrix
Parameters
irow index
jColumn index

Definition at line 124 of file RectMatrix.hpp.

◆ operator*=()

template<typename Real , unsigned int Row, unsigned int Col>
RectMatrix< Real, Row, Col > & OpenMD::RectMatrix< Real, Row, Col >::operator*= ( const Real s)
inline

Multiples a scalar into every element of this matrix.

Parameters
sthe scalar value

Definition at line 354 of file RectMatrix.hpp.

References OpenMD::RectMatrix< Real, Row, Col >::mul().

◆ operator+=()

template<typename Real , unsigned int Row, unsigned int Col>
RectMatrix< Real, Row, Col > & OpenMD::RectMatrix< Real, Row, Col >::operator+= ( const RectMatrix< Real, Row, Col > & m)
inline

Sets the value of this matrix to the sum of the other matrix and itself (*this += m).

Parameters
mthe other matrix

Definition at line 373 of file RectMatrix.hpp.

References OpenMD::RectMatrix< Real, Row, Col >::add().

◆ operator-=()

template<typename Real , unsigned int Row, unsigned int Col>
RectMatrix< Real, Row, Col > & OpenMD::RectMatrix< Real, Row, Col >::operator-= ( const RectMatrix< Real, Row, Col > & m)
inline

Sets the value of this matrix to the differerence of itself and the other matrix (*this -= m)

Parameters
mthe other matrix

Definition at line 384 of file RectMatrix.hpp.

References OpenMD::RectMatrix< Real, Row, Col >::sub().

◆ operator/=()

template<typename Real , unsigned int Row, unsigned int Col>
RectMatrix< Real, Row, Col > & OpenMD::RectMatrix< Real, Row, Col >::operator/= ( const Real s)
inline

Divides every element of this matrix by a scalar.

Parameters
sthe scalar value

Definition at line 363 of file RectMatrix.hpp.

References OpenMD::RectMatrix< Real, Row, Col >::div().

◆ operator=()

template<typename Real , unsigned int Row, unsigned int Col>
RectMatrix< Real, Row, Col > & OpenMD::RectMatrix< Real, Row, Col >::operator= ( const RectMatrix< Real, Row, Col > & m)
inline

copy assignment operator

Definition at line 98 of file RectMatrix.hpp.

Referenced by OpenMD::SquareMatrix< Real, Dim >::operator=().

◆ operator==()

template<typename Real , unsigned int Row, unsigned int Col>
bool OpenMD::RectMatrix< Real, Row, Col >::operator== ( const RectMatrix< Real, Row, Col > & m)
inline

Tests if this matrix is identical to matrix m.

Returns
true if this matrix is equal to the matrix m, return false otherwise
Parameters
mmatrix to be compared
Todo
replace operator == by template function equal

Definition at line 223 of file RectMatrix.hpp.

References OpenMD::equal().

◆ setColumn()

template<typename Real , unsigned int Row, unsigned int Col>
void OpenMD::RectMatrix< Real, Row, Col >::setColumn ( unsigned int col,
const Vector< Real, Col > & v )
inline

Sets a column of this matrix.

Parameters
colthe column index
vthe vector to be set

Definition at line 186 of file RectMatrix.hpp.

◆ setRow()

template<typename Real , unsigned int Row, unsigned int Col>
void OpenMD::RectMatrix< Real, Row, Col >::setRow ( unsigned int row,
const Vector< Real, Row > & v )
inline

Sets a row of this matrix.

Parameters
rowthe row index
vthe vector to be set

Definition at line 162 of file RectMatrix.hpp.

Referenced by OpenMD::SquareMatrix3< Real >::diagonalize().

◆ setSubMatrix()

template<typename Real , unsigned int Row, unsigned int Col>
template<class MatrixType >
void OpenMD::RectMatrix< Real, Row, Col >::setSubMatrix ( unsigned int beginRow,
unsigned int beginCol,
const MatrixType & m )
inline

Definition at line 402 of file RectMatrix.hpp.

◆ sub() [1/2]

template<typename Real , unsigned int Row, unsigned int Col>
void OpenMD::RectMatrix< Real, Row, Col >::sub ( const RectMatrix< Real, Row, Col > & m)
inline

Sets the value of this matrix to the difference of itself and m (*this -= m).

Parameters
mthe other matrix

Definition at line 285 of file RectMatrix.hpp.

Referenced by OpenMD::operator-(), and OpenMD::RectMatrix< Real, Row, Col >::operator-=().

◆ sub() [2/2]

template<typename Real , unsigned int Row, unsigned int Col>
void OpenMD::RectMatrix< Real, Row, Col >::sub ( const RectMatrix< Real, Row, Col > & m1,
const RectMatrix< Real, Row, Col > & m2 )
inline

Sets the value of this matrix to the difference of matrix m1 and m2 (*this = m1 - m2).

Parameters
m1the first matrix
m2the second matrix

Definition at line 297 of file RectMatrix.hpp.

◆ swapColumn()

template<typename Real , unsigned int Row, unsigned int Col>
void OpenMD::RectMatrix< Real, Row, Col >::swapColumn ( unsigned int i,
unsigned int j )
inline

swap two Columns of this matrix

Parameters
ithe first Column
jthe second Column

Definition at line 208 of file RectMatrix.hpp.

◆ swapRow()

template<typename Real , unsigned int Row, unsigned int Col>
void OpenMD::RectMatrix< Real, Row, Col >::swapRow ( unsigned int i,
unsigned int j )
inline

swap two rows of this matrix

Parameters
ithe first row
jthe second row

Definition at line 196 of file RectMatrix.hpp.

Referenced by OpenMD::SquareMatrix3< Real >::diagonalize().

◆ transpose()

template<typename Real , unsigned int Row, unsigned int Col>
RectMatrix< Real, Col, Row > OpenMD::RectMatrix< Real, Row, Col >::transpose ( ) const
inline

Return the transpose of this matrix.

Definition at line 391 of file RectMatrix.hpp.

Member Data Documentation

◆ data_

template<typename Real , unsigned int Row, unsigned int Col>
Real OpenMD::RectMatrix< Real, Row, Col >::data_[Row][Col]
protected

Definition at line 437 of file RectMatrix.hpp.


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