OpenMD 3.0
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
OpenMD::DynamicRectMatrix< Real > Class Template Reference

rectangular matrix class More...

#include "math/DynamicRectMatrix.hpp"

Public Types

using ElemType = Real
 
using ElemPoinerType = Real*
 
using SelfType = DynamicRectMatrix<Real>
 

Public Member Functions

 DynamicRectMatrix ()
 default constructor
 
 DynamicRectMatrix (unsigned int nrow, unsigned int ncol)
 
 DynamicRectMatrix (unsigned int nrow, unsigned int ncol, Real s)
 Constructs and initializes every element of this matrix to a scalar.
 
 DynamicRectMatrix (unsigned int nrow, unsigned int ncol, Real *array)
 
 DynamicRectMatrix (const SelfType &m)
 copy constructor
 
 ~DynamicRectMatrix ()
 destructor
 
DynamicRectMatrix< Real > operator= (const DynamicRectMatrix< Real > &m)
 copy assignment operator
 
Real & operator() (unsigned int i, unsigned int j)
 Returns the reference of a single element of this matrix.
 
Real operator() (unsigned int i, unsigned int j) const
 Returns the value of a single element of this matrix.
 
void getArray (Real *array)
 Copies the internal data to an array.
 
DynamicVector< Real > getRow (unsigned int row)
 Returns a row of this matrix as a vector.
 
void setRow (unsigned int row, const DynamicVector< Real > &v)
 Sets a row of this matrix.
 
DynamicVector< Real > getColumn (unsigned int col)
 Returns a column of this matrix as a vector.
 
void setColumn (unsigned int col, const DynamicVector< Real > &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 DynamicRectMatrix< Real > &m)
 Tests if this matrix is identical to matrix m.
 
bool operator!= (const DynamicRectMatrix< Real > &m)
 Tests if this matrix is not equal to matrix m.
 
void negate ()
 Negates the value of this matrix in place.
 
void negate (const DynamicRectMatrix< Real > &m)
 Sets the value of this matrix to the negation of matrix m.
 
void add (const DynamicRectMatrix< Real > &m)
 Sets the value of this matrix to the sum of itself and m (*this += m).
 
void add (const DynamicRectMatrix< Real > &m1, const DynamicRectMatrix< Real > &m2)
 Sets the value of this matrix to the sum of m1 and m2 (*this = m1 + m2).
 
void sub (const DynamicRectMatrix< Real > &m)
 Sets the value of this matrix to the difference of itself and m (*this -= m).
 
void sub (const DynamicRectMatrix< Real > &m1, const DynamicRectMatrix< Real > &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 DynamicRectMatrix< Real > &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 DynamicRectMatrix< Real > &m)
 Sets the value of this matrix to the scalar division of matrix m (*this = m /s).
 
DynamicRectMatrix< Real > operator*= (const Real s)
 Multiples a scalar onto every element of this matrix.
 
DynamicRectMatrix< Real > operator/= (const Real s)
 Divides every element of this matrix by a scalar.
 
DynamicRectMatrix< Real > operator+= (const DynamicRectMatrix< Real > m)
 Sets the value of this matrix to the sum of the other matrix and itself (*this += m).
 
DynamicRectMatrix< Real > operator-= (const DynamicRectMatrix< Real > m)
 Sets the value of this matrix to the differerence of itself and the other matrix (*this -= m)
 
DynamicRectMatrix< Real > transpose () const
 Return the transpose of this matrix.
 
unsigned int getNRow () const
 
unsigned int getNCol () const
 
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)
 

Protected Attributes

Real ** data_
 
unsigned int nrow_
 
unsigned int ncol_
 

Detailed Description

template<typename Real>
class OpenMD::DynamicRectMatrix< Real >

rectangular matrix class

Definition at line 67 of file DynamicRectMatrix.hpp.

Member Typedef Documentation

◆ ElemPoinerType

template<typename Real >
using OpenMD::DynamicRectMatrix< Real >::ElemPoinerType = Real*

Definition at line 70 of file DynamicRectMatrix.hpp.

◆ ElemType

template<typename Real >
using OpenMD::DynamicRectMatrix< Real >::ElemType = Real

Definition at line 69 of file DynamicRectMatrix.hpp.

◆ SelfType

template<typename Real >
using OpenMD::DynamicRectMatrix< Real >::SelfType = DynamicRectMatrix<Real>

Definition at line 71 of file DynamicRectMatrix.hpp.

Constructor & Destructor Documentation

◆ DynamicRectMatrix() [1/5]

template<typename Real >
OpenMD::DynamicRectMatrix< Real >::DynamicRectMatrix ( )
inline

default constructor

Definition at line 74 of file DynamicRectMatrix.hpp.

◆ DynamicRectMatrix() [2/5]

template<typename Real >
OpenMD::DynamicRectMatrix< Real >::DynamicRectMatrix ( unsigned int nrow,
unsigned int ncol )
inline

Definition at line 80 of file DynamicRectMatrix.hpp.

◆ DynamicRectMatrix() [3/5]

template<typename Real >
OpenMD::DynamicRectMatrix< Real >::DynamicRectMatrix ( unsigned int nrow,
unsigned int ncol,
Real s )
inline

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

Definition at line 89 of file DynamicRectMatrix.hpp.

◆ DynamicRectMatrix() [4/5]

template<typename Real >
OpenMD::DynamicRectMatrix< Real >::DynamicRectMatrix ( unsigned int nrow,
unsigned int ncol,
Real * array )
inline

Definition at line 96 of file DynamicRectMatrix.hpp.

◆ DynamicRectMatrix() [5/5]

template<typename Real >
OpenMD::DynamicRectMatrix< Real >::DynamicRectMatrix ( const SelfType & m)
inline

copy constructor

Definition at line 104 of file DynamicRectMatrix.hpp.

◆ ~DynamicRectMatrix()

template<typename Real >
OpenMD::DynamicRectMatrix< Real >::~DynamicRectMatrix ( )
inline

destructor

Definition at line 113 of file DynamicRectMatrix.hpp.

Member Function Documentation

◆ add() [1/2]

template<typename Real >
void OpenMD::DynamicRectMatrix< Real >::add ( const DynamicRectMatrix< Real > & m)
inline

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

Parameters
mthe other matrix

Definition at line 280 of file DynamicRectMatrix.hpp.

Referenced by OpenMD::operator+(), and OpenMD::DynamicRectMatrix< Real >::operator+=().

◆ add() [2/2]

template<typename Real >
void OpenMD::DynamicRectMatrix< Real >::add ( const DynamicRectMatrix< Real > & m1,
const DynamicRectMatrix< Real > & 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 292 of file DynamicRectMatrix.hpp.

◆ div() [1/2]

template<typename Real >
void OpenMD::DynamicRectMatrix< Real >::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 355 of file DynamicRectMatrix.hpp.

Referenced by OpenMD::operator/(), and OpenMD::DynamicRectMatrix< Real >::operator/=().

◆ div() [2/2]

template<typename Real >
void OpenMD::DynamicRectMatrix< Real >::div ( Real s,
const DynamicRectMatrix< Real > & 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 367 of file DynamicRectMatrix.hpp.

◆ getArray()

template<typename Real >
void OpenMD::DynamicRectMatrix< Real >::getArray ( Real * array)
inline

Copies the internal data to an array.

Parameters
arraythe pointer of destination array

Definition at line 153 of file DynamicRectMatrix.hpp.

◆ getColumn()

template<typename Real >
DynamicVector< Real > OpenMD::DynamicRectMatrix< Real >::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 191 of file DynamicRectMatrix.hpp.

◆ getNCol()

template<typename Real >
unsigned int OpenMD::DynamicRectMatrix< Real >::getNCol ( ) const
inline

Definition at line 426 of file DynamicRectMatrix.hpp.

◆ getNRow()

template<typename Real >
unsigned int OpenMD::DynamicRectMatrix< Real >::getNRow ( ) const
inline

Definition at line 425 of file DynamicRectMatrix.hpp.

◆ getRow()

template<typename Real >
DynamicVector< Real > OpenMD::DynamicRectMatrix< Real >::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 166 of file DynamicRectMatrix.hpp.

◆ getSubMatrix()

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

Definition at line 440 of file DynamicRectMatrix.hpp.

◆ mul() [1/2]

template<typename Real >
void OpenMD::DynamicRectMatrix< Real >::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 331 of file DynamicRectMatrix.hpp.

Referenced by OpenMD::operator*(), OpenMD::operator*(), and OpenMD::DynamicRectMatrix< Real >::operator*=().

◆ mul() [2/2]

template<typename Real >
void OpenMD::DynamicRectMatrix< Real >::mul ( Real s,
const DynamicRectMatrix< Real > & 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 343 of file DynamicRectMatrix.hpp.

◆ negate() [1/2]

template<typename Real >
void OpenMD::DynamicRectMatrix< Real >::negate ( )
inline

Negates the value of this matrix in place.

Definition at line 260 of file DynamicRectMatrix.hpp.

Referenced by OpenMD::operator-().

◆ negate() [2/2]

template<typename Real >
void OpenMD::DynamicRectMatrix< Real >::negate ( const DynamicRectMatrix< Real > & m)
inline

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

Parameters
mthe source matrix

Definition at line 270 of file DynamicRectMatrix.hpp.

◆ operator!=()

template<typename Real >
bool OpenMD::DynamicRectMatrix< Real >::operator!= ( const DynamicRectMatrix< Real > & 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 257 of file DynamicRectMatrix.hpp.

◆ operator()() [1/2]

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

Returns 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 135 of file DynamicRectMatrix.hpp.

◆ operator()() [2/2]

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

Returns 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 145 of file DynamicRectMatrix.hpp.

◆ operator*=()

template<typename Real >
DynamicRectMatrix< Real > OpenMD::DynamicRectMatrix< Real >::operator*= ( const Real s)
inline

Multiples a scalar onto every element of this matrix.

Parameters
sthe scalar value

Definition at line 378 of file DynamicRectMatrix.hpp.

References OpenMD::DynamicRectMatrix< Real >::mul().

◆ operator+=()

template<typename Real >
DynamicRectMatrix< Real > OpenMD::DynamicRectMatrix< Real >::operator+= ( const DynamicRectMatrix< Real > 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 397 of file DynamicRectMatrix.hpp.

References OpenMD::DynamicRectMatrix< Real >::add().

◆ operator-=()

template<typename Real >
DynamicRectMatrix< Real > OpenMD::DynamicRectMatrix< Real >::operator-= ( const DynamicRectMatrix< Real > 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 408 of file DynamicRectMatrix.hpp.

References OpenMD::DynamicRectMatrix< Real >::sub().

◆ operator/=()

template<typename Real >
DynamicRectMatrix< Real > OpenMD::DynamicRectMatrix< Real >::operator/= ( const Real s)
inline

Divides every element of this matrix by a scalar.

Parameters
sthe scalar value

Definition at line 387 of file DynamicRectMatrix.hpp.

References OpenMD::DynamicRectMatrix< Real >::div().

◆ operator=()

template<typename Real >
DynamicRectMatrix< Real > OpenMD::DynamicRectMatrix< Real >::operator= ( const DynamicRectMatrix< Real > & m)
inline

copy assignment operator

Definition at line 116 of file DynamicRectMatrix.hpp.

◆ operator==()

template<typename Real >
bool OpenMD::DynamicRectMatrix< Real >::operator== ( const DynamicRectMatrix< Real > & 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 242 of file DynamicRectMatrix.hpp.

References OpenMD::equal().

◆ setColumn()

template<typename Real >
void OpenMD::DynamicRectMatrix< Real >::setColumn ( unsigned int col,
const DynamicVector< Real > & v )
inline

Sets a column of this matrix.

Parameters
colthe column index
vthe vector to be set

Definition at line 205 of file DynamicRectMatrix.hpp.

◆ setRow()

template<typename Real >
void OpenMD::DynamicRectMatrix< Real >::setRow ( unsigned int row,
const DynamicVector< Real > & v )
inline

Sets a row of this matrix.

Parameters
rowthe row index
vthe vector to be set

Definition at line 180 of file DynamicRectMatrix.hpp.

◆ setSubMatrix()

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

Definition at line 429 of file DynamicRectMatrix.hpp.

◆ sub() [1/2]

template<typename Real >
void OpenMD::DynamicRectMatrix< Real >::sub ( const DynamicRectMatrix< Real > & m)
inline

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

Parameters
mthe other matrix

Definition at line 305 of file DynamicRectMatrix.hpp.

Referenced by OpenMD::operator-(), and OpenMD::DynamicRectMatrix< Real >::operator-=().

◆ sub() [2/2]

template<typename Real >
void OpenMD::DynamicRectMatrix< Real >::sub ( const DynamicRectMatrix< Real > & m1,
const DynamicRectMatrix< Real > & 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 318 of file DynamicRectMatrix.hpp.

◆ swapColumn()

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

swap two Columns of this matrix

Parameters
ithe first Column
jthe second Column

Definition at line 227 of file DynamicRectMatrix.hpp.

◆ swapRow()

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

swap two rows of this matrix

Parameters
ithe first row
jthe second row

Definition at line 215 of file DynamicRectMatrix.hpp.

◆ transpose()

template<typename Real >
DynamicRectMatrix< Real > OpenMD::DynamicRectMatrix< Real >::transpose ( ) const
inline

Return the transpose of this matrix.

Definition at line 415 of file DynamicRectMatrix.hpp.

Member Data Documentation

◆ data_

template<typename Real >
Real** OpenMD::DynamicRectMatrix< Real >::data_
protected

Definition at line 451 of file DynamicRectMatrix.hpp.

◆ ncol_

template<typename Real >
unsigned int OpenMD::DynamicRectMatrix< Real >::ncol_
protected

Definition at line 453 of file DynamicRectMatrix.hpp.

◆ nrow_

template<typename Real >
unsigned int OpenMD::DynamicRectMatrix< Real >::nrow_
protected

Definition at line 452 of file DynamicRectMatrix.hpp.


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