LA::NRSMat< T > Class Template Reference

#include <smat.h>

List of all members.

Public Member Functions

 ~NRSMat ()
 NRSMat ()
 default constructor of null-matrix
 NRSMat (const int n, const GPUID loc=undefined)
 default constructor
 NRSMat (const T &a, const int n)
 constructor initializing the matrix being created by given scalar value
 NRSMat (const T *a, const int n)
 constructor initializing the matrix being created by data located at given memory position
 NRSMat (const NRSMat &rhs)
 copy constructor
 NRSMat (const typename LA_traits_complex< T >::NRSMat_Noncomplex_type &rhs, bool imagpart=false)
 constructor converting real matrix to its complex counterpart
 NRSMat (const NRMat< T > &rhs)
 constructor creating symmetric part of a general matrix
 NRSMat (const NRVec< T > &rhs, const int n)
 construct symmetric matrix by filling the lower triangle with data stored in a vector
NRSMatoperator= (const NRSMat &rhs)
 assignment operator performing shallow copy
NRSMatoperator|= (const NRSMat &rhs)
 assignment operator performing deep copy
void randomize (const typename LA_traits< T >::normtype &x)
 fill the matrix with pseudorandom numbers (uniform distribution)
NRSMatoperator= (const T &a)
 assign scalar value to diagonal elements
int getcount () const
GPUID getlocation () const
void moveto (const GPUID dest)
const bool operator!= (const NRSMat &rhs) const
 relational operator for testing nonequality
const bool operator== (const NRSMat &rhs) const
 relational operator for testing equality
NRSMatoperator*= (const T &a)
NRSMatoperator+= (const T &a)
NRSMatoperator-= (const T &a)
NRSMatoperator+= (const NRSMat &rhs)
NRSMatoperator-= (const NRSMat &rhs)
const NRSMat operator- () const
const NRSMat operator* (const T &a) const
const NRSMat operator+ (const T &a) const
const NRSMat operator- (const T &a) const
const NRSMat operator+ (const NRSMat &rhs) const
const NRSMat operator- (const NRSMat &rhs) const
const NRMat< T > operator+ (const NRMat< T > &rhs) const
const NRMat< T > operator- (const NRMat< T > &rhs) const
const NRMat< T > operator* (const NRSMat &rhs) const
const NRMat< T > operator* (const NRMat< T > &rhs) const
const T dot (const NRSMat &rhs) const
const T dot (const NRVec< T > &rhs) const
const NRVec< T > operator* (const NRVec< T > &rhs) const
const NRVec< complex< T > > operator* (const NRVec< complex< T > > &rhs) const
const T * diagonalof (NRVec< T > &, const bool divide=0, bool cache=false) const
void gemv (const T beta, NRVec< T > &r, const char trans, const T alpha, const NRVec< T > &x) const
void gemv (const T beta, NRVec< complex< T > > &r, const char trans, const T alpha, const NRVec< complex< T > > &x) const
const T & operator[] (const int ij) const
T & operator[] (const int ij)
const T & operator() (const int i, const int j) const
T & operator() (const int i, const int j)
int nrows () const
int ncols () const
int size () const
bool transp (const int i, const int j) const
const LA_traits< T >::normtype norm (const T scalar=(T) 0) const
void axpy (const T alpha, const NRSMat &x)
const T amax () const
const T amin () const
const T trace () const
void get (int fd, bool dimensions=1, bool transp=0)
void put (int fd, bool dimensions=1, bool transp=0) const
void copyonwrite ()
void clear ()
void resize (const int n)
 operator T * ()
 operator const T * () const
void fprintf (FILE *f, const char *format, const int modulo) const
void fscanf (FILE *f, const char *format)
 NRSMat (const SparseMat< T > &rhs)
 NRSMat (const SparseSMat< T > &rhs)
void simplify ()
bool issymmetric () const
template<>
const NRSMat< double > operator- () const
template<>
const NRSMat< complex< double > > operator- () const
template<>
void randomize (const double &x)
template<>
void randomize (const double &x)
template<>
const NRMat< double > operator* (const NRMat< double > &rhs) const
template<>
const NRMat< complex< double > > operator* (const NRMat< complex< double > > &rhs) const
template<>
const NRMat< double > operator* (const NRSMat< double > &rhs) const
template<>
const NRMat< complex< double > > operator* (const NRSMat< complex< double > > &rhs) const
template<>
const double dot (const NRSMat< double > &rhs) const
template<>
const complex< double > dot (const NRSMat< complex< double > > &rhs) const
template<>
const double dot (const NRVec< double > &rhs) const
template<>
const complex< double > dot (const NRVec< complex< double > > &rhs) const
template<>
const double norm (const double scalar) const
template<>
const double norm (const complex< double > scalar) const
template<>
void axpy (const double alpha, const NRSMat< double > &x)
template<>
void axpy (const complex< double > alpha, const NRSMat< complex< double > > &x)
template<>
 NRSMat (const NRSMat< double > &rhs, bool imagpart)
template<>
NRSMat< double > & operator*= (const double &a)
template<>
NRSMat< complex< double > > & operator*= (const complex< double > &a)
template<>
NRSMat< double > & operator+= (const NRSMat< double > &rhs)
template<>
NRSMat< complex< double > > & operator+= (const NRSMat< complex< double > > &rhs)
template<>
NRSMat< double > & operator-= (const NRSMat< double > &rhs)
template<>
NRSMat< complex< double > > & operator-= (const NRSMat< complex< double > > &rhs)
template<>
const double amax () const
template<>
const double amin () const
template<>
const complex< double > amax () const
template<>
const complex< double > amin () const

Protected Attributes

int nn
 number of rows/columns of this symmetric matrix
T * v
 internal pointer to the underlying data structure
int * count
 pointer to the reference counter

Friends

class NRVec< T >
class NRMat< T >


Detailed Description

template<class T>
class LA::NRSMat< T >

This class implements a general symmetric or hermitian matrix the elements of which are stored in packed form. Particularly the lower triangular part of a symmetric or hermitian matrix of order $N$ is interpreted as a vector of length $N(N+1)/2$ in row-major storage scheme.

Constructor & Destructor Documentation

template<typename T >
LA::NRSMat< T >::~NRSMat (  )  [inline]

destructor for general type T

See also:
NRSMat<T>::count, NRSMat<T>::v

template<typename T >
LA::NRSMat< T >::NRSMat ( const int  n,
const GPUID  loc = undefined 
) [inline, explicit]

default constructor

constructor of a symmetric matrix stored in packed form

Parameters:
[in] n number of rows of the matrix being created
[in] loc location for storing the matrix
See also:
count, v, location

template<typename T>
LA::NRSMat< T >::NRSMat ( const T &  a,
const int  n 
) [inline]

constructor initializing the matrix being created by given scalar value

constructor of a symmetric matrix stored in packed form (default location in used)

Parameters:
[in] a set all matrix elements equal to this value
[in] n number of rows of the matrix being created
See also:
count, v, location, NRSMat<T>::NRSMat(const int, const GPUID)

template<typename T>
LA::NRSMat< T >::NRSMat ( const T *  a,
const int  n 
) [inline]

constructor initializing the matrix being created by data located at given memory position

constructor of a symmetric matrix stored in packed form (default location in used)

Parameters:
[in] a pointer to data of type T used for matrix inicialization
[in] n number of rows of the matrix being created
See also:
count, v, location, NRSMat<T>::NRSMat(const int, const GPUID), NRSMat<T>::NRSMat(const T&, const int)

template<typename T>
LA::NRSMat< T >::NRSMat ( const NRSMat< T > &  rhs  )  [inline]

copy constructor

copy constructor implementing shallow copy

Parameters:
[in] rhs reference matrix being copied
See also:
count, v, location

template<typename T>
LA::NRSMat< T >::NRSMat ( const NRMat< T > &  rhs  )  [inline, explicit]

constructor creating symmetric part of a general matrix

constructor symmetrizing given matrix $A$ of general type T yielding $(A+A^\mathrm{T})/2$

Parameters:
[in] rhs matrix $A$

template<typename T>
LA::NRSMat< T >::NRSMat ( const NRVec< T > &  rhs,
const int  n 
) [inline, explicit]

construct symmetric matrix by filling the lower triangle with data stored in a vector

constructor interpreting a vector of $n(n+1)/2$ elements as a symmetric matrix stored in packed form having $n$ rows

Parameters:
[in] rhs reference matrix being copied
[in] n count of rows of the matrix being created

template<>
LA::NRSMat< complex< double > >::NRSMat ( const NRSMat< double > &  rhs,
bool  imagpart 
) [inline]

create hermitian matrix $H$ from given real double-precision symmetric matrix $S$

Parameters:
[in] rhs real double-precision symmetric matrix $S$
[in] imagpart flag determining whether $S$ should correspond to the real or imaginary part of $H$


Member Function Documentation

template<>
const complex< double > LA::NRSMat< complex< double > >::amax (  )  const [inline]

for this complex symmetric matrix $A$, determine the first element with largest "absolute value"

Returns:
$A_{l,m}$ which maximizes $\left|\Re{}A_{i,j}\right| + \left|\Im{}A_{i,j}\right|$

template<>
const double LA::NRSMat< double >::amax (  )  const [inline]

for this real symmetric matrix $A$, determine the first element with largest absolute value

Returns:
$A_{l,m}$ which maximizes $\left|A_{i,j}\right|$

template<>
const complex< double > LA::NRSMat< complex< double > >::amin (  )  const [inline]

for this complex symmetric matrix $A$, determine the first element with smallest "absolute value"

Returns:
$A_{l,m}$ which minimizes $\left|\Re{}A_{i,j}\right| + \left|\Im{}A_{i,j}\right|$

template<>
const double LA::NRSMat< double >::amin (  )  const [inline]

for this real symmetric matrix $A$, determine the first element with smallest absolute value

Returns:
$A_{l,m}$ which minimizes $\left|A_{i,j}\right|$

template<>
void LA::NRSMat< complex< double > >::axpy ( const complex< double >  alpha,
const NRSMat< complex< double > > &  x 
) [inline]

for this complex double-precision hermitian matrix $H$ stored in packed form, complex scalar value $\alpha$ and complex double-precision hermitian matrix $G$, compute

\[H \leftarrow \alpha G + H\]

template<>
void LA::NRSMat< double >::axpy ( const double  alpha,
const NRSMat< double > &  x 
) [inline]

for this real double-precision symmetric matrix $S$ stored in packed form, real scalar value $\alpha$ and real double-precision symmetric matrix $T$, compute

\[S \leftarrow \alpha T + S\]

template<typename T >
void LA::NRSMat< T >::copyonwrite (  )  [inline]

detach this NRSMat<T> object and create own physical copy of the data

See also:
NRSMat<T>::operator|=, NRSMat<T>::copyonwrite()

template<typename T>
const T * LA::NRSMat< T >::diagonalof ( NRVec< T > &  r,
const bool  divide = 0,
bool  cache = false 
) const [inline]

get or divide by the diagonal of real symmetric double-precision matrix

Parameters:
[in,out] r vector for storing the diagonal
[in] divide 
  • false save the diagonal to vector r
  • true divide the vector r by the diagonal elements element-wise
[in] cache reserved
Returns:
  • divide == true NULL
  • divide == false pointer to the first element of r

template<>
const complex< double > LA::NRSMat< complex< double > >::dot ( const NRVec< complex< double > > &  rhs  )  const [inline]

compute inner product of this complex double-precision hermitian matrix $H$ of order $n$ with given complex double-precision vector $\vec{v}$ of length $n(n+1)/2$

Parameters:
[in] rhs complex double-precision vector $\vec{v}$
Returns:
computed inner product

template<>
const double LA::NRSMat< double >::dot ( const NRVec< double > &  rhs  )  const [inline]

compute inner product of this real double-precision symmetric matrix $S$ of order $n$ with given real double-precision vector $\vec{v}$ of length $n(n+1)/2$

Parameters:
[in] rhs real double-precision vector $\vec{v}$
Returns:
computed inner product

template<>
const complex< double > LA::NRSMat< complex< double > >::dot ( const NRSMat< complex< double > > &  rhs  )  const [inline]

compute inner product of this complex symmetric matrix $A$ with given complex symmetric matrix $B$ i.e. determine the value of

\[\sum_{i,j}\overbar{A_{i,j}}B_{i,j}\]

Parameters:
[in] rhs matrix $B$
Returns:
computed inner product

template<>
const double LA::NRSMat< double >::dot ( const NRSMat< double > &  rhs  )  const [inline]

compute inner product of this real symmetric matrix $A$ with given real symmetric matrix $B$ i.e. determine the value of

\[\sum_{i,j}A_{i,j}B_{i,j}\]

Parameters:
[in] rhs matrix $B$
Returns:
computed inner product

template<typename T >
void LA::NRSMat< T >::fprintf ( FILE *  file,
const char *  format,
const int  modulo 
) const [inline]

routine for formatted output via lawritemat

Parameters:
[in] file pointer to FILE structure representing the output file
[in] format format specification in standard printf-like form
[in] modulo 
See also:
lawritemat()

template<typename T >
void LA::NRSMat< T >::fscanf ( FILE *  f,
const char *  format 
) [inline]

routine for formatted input via fscanf

Parameters:
[in] f pointer to FILE structure representing the input file
[in] format format specification in standard printf-like form

template<typename T >
void LA::NRSMat< T >::get ( int  fd,
bool  dim = 1,
bool  transp = 0 
) [inline]

routine for raw input

Parameters:
[in] fd file descriptor for input
[in] dim number of elements intended for input
[in] transp reserved
See also:
NRSMat<T>::put(), NRSMat<T>::copyonwrite()

template<typename T >
int LA::NRSMat< T >::ncols (  )  const [inline]

Returns:
number of columns of this symmetric matrix of generalt type T

template<>
const double LA::NRSMat< complex< double > >::norm ( const complex< double >  scalar  )  const [inline]

compute the Frobenius norm of this complex double-precision hermitian matrix

Parameters:
[in] scalar subtract this scalar value from the diagonal elements before the norm computation

template<>
const double LA::NRSMat< double >::norm ( const double  scalar  )  const [inline]

compute the Frobenius norm of this real double-precision symmetric matrix

Parameters:
[in] scalar subtract this scalar value from the diagonal elements before the norm computation

template<typename T >
int LA::NRSMat< T >::nrows (  )  const [inline]

Returns:
number of rows of this symmetric matrix of generalt type T

template<typename T >
LA::NRSMat< T >::operator const T * (  )  const [inline]

Returns:
constant pointer of general type T to the underlying data structure

template<typename T >
LA::NRSMat< T >::operator T * (  )  [inline]

Returns:
pointer of general type T to the underlying data structure

template<typename T >
T & LA::NRSMat< T >::operator() ( const int  i,
const int  j 
) [inline]

determine matrix element of this symmetric matrix of general type T

Parameters:
[in] i row index running from 0
[in] j column index running from 0
Returns:
reference to the corresponding matrix element
See also:
count, SMat_index, NRSMat<T>::operator[]

template<typename T >
const T & LA::NRSMat< T >::operator() ( const int  i,
const int  j 
) const [inline]

determine matrix element of this symmetric matrix of general type T

Parameters:
[in] i row index running from 0
[in] j column index running from 0
Returns:
constant reference to the corresponding matrix element
See also:
count, SMat_index, NRSMat<T>::operator[]

template<>
const NRMat< complex< double > > LA::NRSMat< complex< double > >::operator* ( const NRSMat< complex< double > > &  rhs  )  const [inline]

multiply this complex double-precision symmetric matrix $G$ stored in packed form with complex double-precision symmetric matrix $H$

Returns:
matrix produt $G\times{}H$ (not necessarily symmetric)

template<>
const NRMat< double > LA::NRSMat< double >::operator* ( const NRSMat< double > &  rhs  )  const [inline]

multiply this real double-precision symmetric matrix $S$ stored in packed form with real double-precision symmetric matrix $T$

Returns:
matrix produt $S\times{}T$ (not necessarily symmetric)

template<>
const NRMat< complex< double > > LA::NRSMat< complex< double > >::operator* ( const NRMat< complex< double > > &  rhs  )  const [inline]

multiply this real double-precision symmetric matrix $S$ stored in packed form with real double-precision dense matrix $A$

Parameters:
[in] rhs real double-precision matrix $A$
Returns:
matrix produt $S\times{}A$

template<>
const NRMat< double > LA::NRSMat< double >::operator* ( const NRMat< double > &  rhs  )  const [inline]

multiply this real double-precision symmetric matrix $S$ stored in packed form with real double-precision dense matrix $A$

Parameters:
[in] rhs real double-precision matrix $A$
Returns:
matrix produt $S\times{}A$

template<>
NRSMat< complex< double > > & LA::NRSMat< complex< double > >::operator*= ( const complex< double > &  a  )  [inline]

multiply this complex symmetric matrix with complex scalar value

Parameters:
[in] a complex multiplicative factor
Returns:
reference to the modified matrix

template<>
NRSMat< double > & LA::NRSMat< double >::operator*= ( const double &  a  )  [inline]

multiply this real symmetric matrix with real scalar value

Parameters:
[in] a real multiplicative factor
Returns:
reference to the modified matrix

template<typename T>
NRSMat< T > & LA::NRSMat< T >::operator*= ( const T &  a  )  [inline]

multiply this symmetric matrix of general type T stored in packed form with scalar value of type T

Parameters:
[in] a multiplicative factor of type T
Returns:
reference to the modified matrix

template<typename T>
const NRMat< T > LA::NRSMat< T >::operator+ ( const NRMat< T > &  rhs  )  const [inline]

add up given dense matrix of general type T with this symmetric matrix of type T

Parameters:
[in] rhs dense matrix of type T to be added
Returns:
reference to the modified matrix

template<>
NRSMat< complex< double > > & LA::NRSMat< complex< double > >::operator+= ( const NRSMat< complex< double > > &  rhs  )  [inline]

add up this complex symmetric matrix with given symmetric matrix

Parameters:
[in] rhs complex symmetric matrix to be added
Returns:
reference to the modified matrix

template<>
NRSMat< double > & LA::NRSMat< double >::operator+= ( const NRSMat< double > &  rhs  )  [inline]

add up this real symmetric matrix with given symmetric matrix

Parameters:
[in] rhs real symmetric matrix to be added
Returns:
reference to the modified matrix

template<typename T>
NRSMat< T > & LA::NRSMat< T >::operator+= ( const NRSMat< T > &  rhs  )  [inline]

add up this symmetric matrix of general type T with given symmetric matrix

Parameters:
[in] rhs complex matrix of general type T to be added
Returns:
reference to the modified matrix

template<typename T>
NRSMat< T > & LA::NRSMat< T >::operator+= ( const T &  a  )  [inline]

add a scalar value $\alpha$ of general type T to the diagonal elements of this symmetric matrix of type T

Parameters:
[in] a scalar value $\alpha$
Returns:
reference to the modified matrix

template<>
const NRSMat< complex< double > > LA::NRSMat< complex< double > >::operator- (  )  const [inline]

implements unary minus operator for this hermitian matrix

Returns:
modified copy of this matrix

template<>
const NRSMat< double > LA::NRSMat< double >::operator- (  )  const [inline]

implements unary minus operator for this real symmetric matrix

Returns:
modified copy of this matrix

template<typename T>
const NRMat< T > LA::NRSMat< T >::operator- ( const NRMat< T > &  rhs  )  const [inline]

subtracts given dense matrix of general type T from this symmetric matrix of type T

Parameters:
[in] rhs dense matrix of type T to be added
Returns:
reference to the modified matrix

template<typename T >
const NRSMat< T > LA::NRSMat< T >::operator- (  )  const [inline]

implements unary minus operator for this symmetric matrix of general type T

Returns:
modified copy of this matrix

template<>
NRSMat< complex< double > > & LA::NRSMat< complex< double > >::operator-= ( const NRSMat< complex< double > > &  rhs  )  [inline]

subtracts given complex symmetric matrix from this complex symmetric matrix

Parameters:
[in] rhs complex symmetric matrix to be subtracted
Returns:
reference to the modified matrix

template<>
NRSMat< double > & LA::NRSMat< double >::operator-= ( const NRSMat< double > &  rhs  )  [inline]

subtracts given real symmetric matrix from this real symmetric matrix

Parameters:
[in] rhs real symmetric matrix to be subtracted
Returns:
reference to the modified matrix

template<typename T>
NRSMat< T > & LA::NRSMat< T >::operator-= ( const NRSMat< T > &  rhs  )  [inline]

subtracts given symmetric matrix of general type T from this symmetric matrix of type T

Parameters:
[in] rhs symmetric matrix of general type T to be subtracted
Returns:
reference to the modified matrix

template<typename T>
NRSMat< T > & LA::NRSMat< T >::operator-= ( const T &  a  )  [inline]

subtract a scalar value $\alpha$ of general type T from the diagonal elements of this symmetric matrix of type T

Parameters:
[in] a scalar value $\alpha$
Returns:
reference to the modified matrix

template<typename T>
NRSMat< T > & LA::NRSMat< T >::operator= ( const T &  a  )  [inline]

assign scalar value to diagonal elements

zero out this symmetric matrix of general type T and then set the diagonal elements to prescribed value

Parameters:
[in] a scalar value to be assigned to the diagonal
Returns:
reference to the modified matrix

template<typename T >
NRSMat< T > & LA::NRSMat< T >::operator= ( const NRSMat< T > &  rhs  )  [inline]

assignment operator performing shallow copy

assignment operator implementing shallow copy of reference NRSMat<T> object

See also:
NRSMat<T>::operator|=, NRSMat<T>::copyonwrite()

template<typename T >
T & LA::NRSMat< T >::operator[] ( const int  ij  )  [inline]

determine matrix element of this symmetric matrix of general type T using cumulative index increasing in a row-major way and corresponding to the lower triangular part of the respective dense matrix

Parameters:
[in] ij index of the requested element
Returns:
reference to the corresponding matrix element

template<typename T >
const T & LA::NRSMat< T >::operator[] ( const int  ij  )  const [inline]

determine matrix element of this symmetric matrix of general type T using cumulative index increasing in a row-major way and corresponding to the lower triangular part of the respective dense matrix, i.e. $A_{i,j}$ for $N>i\geq{}j\geq0$ corresponds to cumulative index $i(i+1)/2+j$

Parameters:
[in] ij index of the requested element
Returns:
constant reference to the corresponding matrix element

template<typename T >
NRSMat< T > & LA::NRSMat< T >::operator|= ( const NRSMat< T > &  rhs  )  [inline]

assignment operator performing deep copy

assigment operator implementing deep copy of the reference NRSMat<T> object

See also:
NRSMat<T>::operator=, NRSMat<T>::copyonwrite()

template<typename T >
void LA::NRSMat< T >::put ( int  fd,
bool  dim = 1,
bool  transp = 0 
) const [inline]

routine for raw output

Parameters:
[in] fd file descriptor for output
[in] dim number of elements intended for output
[in] transp reserved
See also:
NRMat<T>::get(), NRSMat<T>::copyonwrite()

template<>
void LA::NRSMat< complex< double > >::randomize ( const double &  x  )  [inline]

Fill this hermitian matrix with pseudorandom numbers generated from uniform distribution. The real and imaginary parts are generated independently.

template<>
void LA::NRSMat< double >::randomize ( const double &  x  )  [inline]

fill this real symmetric matrix with pseudorandom numbers generated from uniform distribution

template<typename T >
void LA::NRSMat< T >::resize ( const int  n  )  [inline]

resize this symmetric matrix of general type T

Parameters:
[in] n requested number of rows (columns)

template<typename T >
int LA::NRSMat< T >::size (  )  const [inline]

Returns:
number of elements of this symmetric matrix of generalt type T

template<typename T >
const T LA::NRSMat< T >::trace (  )  const [inline]

Returns:
the sum of the diagonal elements


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


LA library home page http://www.pittnerovi.com/la .