OpenMD 3.2
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 69 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 72 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 71 of file RectMatrix.hpp.

Constructor & Destructor Documentation

◆ RectMatrix() [1/4]

◆ 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 82 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 88 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 95 of file RectMatrix.hpp.

References RectMatrix().

◆ ~RectMatrix()

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

destructor

Definition at line 98 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 265 of file RectMatrix.hpp.

References RectMatrix().

Referenced by OpenMD::operator+(), and 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 276 of file RectMatrix.hpp.

References RectMatrix().

◆ 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 335 of file RectMatrix.hpp.

Referenced by OpenMD::operator/(), and 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 347 of file RectMatrix.hpp.

References RectMatrix().

◆ frobeniusNorm()

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

Definition at line 429 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 135 of file RectMatrix.hpp.

◆ getArrayPointer()

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

◆ 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 175 of file RectMatrix.hpp.

Referenced by OpenMD::GhostBend::calcForce().

◆ getNCol()

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

Definition at line 427 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 426 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 151 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 416 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 312 of file RectMatrix.hpp.

Referenced by OpenMD::operator*(), OpenMD::operator*(), and 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 324 of file RectMatrix.hpp.

References RectMatrix().

◆ 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 245 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 255 of file RectMatrix.hpp.

References RectMatrix().

◆ 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 240 of file RectMatrix.hpp.

References RectMatrix().

◆ 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 116 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 127 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 357 of file RectMatrix.hpp.

References mul(), and RectMatrix().

◆ 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 376 of file RectMatrix.hpp.

References add(), and RectMatrix().

◆ 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 387 of file RectMatrix.hpp.

References RectMatrix(), and 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 366 of file RectMatrix.hpp.

References div(), and RectMatrix().

◆ 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 101 of file RectMatrix.hpp.

References RectMatrix().

Referenced by OpenMD::SquareMatrix3< RealType >::operator=(), and OpenMD::SquareMatrix< RealType, 6 >::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 226 of file RectMatrix.hpp.

References OpenMD::equal(), and RectMatrix().

◆ 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 189 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 165 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 405 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 288 of file RectMatrix.hpp.

References RectMatrix().

Referenced by OpenMD::operator-(), and 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 300 of file RectMatrix.hpp.

References RectMatrix().

◆ 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 211 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 199 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 394 of file RectMatrix.hpp.

References RectMatrix().

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 440 of file RectMatrix.hpp.


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