LA::NRMat< T > Class Template Reference

NRMat<T> class template implementing the matrix interface. More...

#include <mat.h>

Inheritance diagram for LA::NRMat< T >:

LA::NRMat_from1< T >

List of all members.

Public Member Functions

 ~NRMat ()
 standard destructor
 NRMat ()
 inlined constructor creating zero matrix of general type T
 NRMat (const int n, const int m, const GPUID loc=undefined)
 Inlined constructor creating matrix of given size and location. Because of performance reasons, no incialization is done.
 NRMat (const T &a, const int n, const int m, const GPUID loc)
 inlined constructor creating matrix of given size filled with prescribed value and stored at given location
 NRMat (const T &a, const int n, const int m)
 inlined constructor creating matrix of given size filled with prescribed value
 NRMat (const T *a, const int n, const int m)
 inlined constructor creating matrix of given size filled with data located at given memory location
 NRMat (const NRMat &rhs)
 inlined copy-constructor
 NRMat (const typename LA_traits_complex< T >::NRMat_Noncomplex_type &rhs, bool imagpart=false)
 complexifying constructor
 NRMat (const NRSMat< T > &rhs)
 explicit constructor converting symmetric matrix stored in packed form into a NRMat<T> object
 NRMat (const NRVec< T > &rhs, const int n, const int m, const int offset=0)
 explicit constructor converting vector into a NRMat<T> object
const bool operator!= (const NRMat &rhs) const
const bool operator== (const NRMat &rhs) const
int getcount () const
 determine the count of references to this object
void copyonwrite ()
 ensure that the data of this matrix are referenced exactly once
GPUID getlocation () const
void moveto (const GPUID dest)
void randomize (const typename LA_traits< T >::normtype &x)
 fill the matrix with pseudorandom numbers (uniform distribution)
NRMatoperator= (const NRMat &rhs)
 assigment operator performing shallow copy
NRMatoperator|= (const NRMat &rhs)
 assigment operator performing deep copy
NRMatoperator= (const T &a)
 assign scalar value to the diagonal elements
NRMatoperator+= (const T &a)
 add scalar value to the diagonal elements
NRMatoperator-= (const T &a)
 subtract scalar value to the diagonal elements
NRMatoperator*= (const T &a)
 multiply by a scalar value
NRMatoperator+= (const NRMat &rhs)
 add given matrix
NRMatoperator-= (const NRMat &rhs)
 subtract given matrix
NRMatoperator^= (const NRMat< T > &rhs)
 Hadamard element-wise product.
NRMatoperator+= (const NRSMat< T > &rhs)
 add symmetric matrix stored in packed form
NRMatoperator-= (const NRSMat< T > &rhs)
 subtract symmetric matrix stored in packed form
const NRMat operator- () const
 unary minus
const NRMat operator+ (const T &a) const
 add scalar value to all matrix elements and return the result by value
const NRMat operator- (const T &a) const
 subtract scalar value from all matrix elements and return the result by value
const NRMat operator* (const T &a) const
 multiply all matrix elements by a scalar value and return the result by value
const NRMat operator+ (const NRMat &rhs) const
 add given matrix and return the result by value
const NRMat operator+ (const NRSMat< T > &rhs) const
 add given symmetric matrix stored in packed form and return the result by value
const NRMat operator- (const NRMat &rhs) const
 subtract given matrix and return the result by value
const NRMat operator- (const NRSMat< T > &rhs) const
 subtract given symmetric matrix stored in packed form and return the result by value
const NRMat operator* (const NRMat &rhs) const
 multiply by given matrix and return the result by value
const NRMat operator* (const NRSMat< T > &rhs) const
 multiply by given symmetric matrix stored in packed form and return the result by value
const NRMat operator& (const NRMat &rhs) const
 direct sum of two matrices
const NRMat operator| (const NRMat< T > &rhs) const
 direct product of two matrices
const NRVec< T > operator* (const NRVec< T > &rhs) const
 multiply by a vector
const NRVec< complex< T > > operator* (const NRVec< complex< T > > &rhs) const
 multiply this matrix of general type T by vector of type complex<T>
const T dot (const NRMat &rhs) const
 inner product of two matrices (taking conjugation into account in the complex case)
const NRMat oplus (const NRMat &rhs) const
 direct sum
const NRMat otimes (const NRMat &rhs, bool reversecolumns=false) const
 direct product
void diagmultl (const NRVec< T > &rhs)
 multiply by diagonal matrix from left
void diagmultr (const NRVec< T > &rhs)
 multiply by diagonal matrix from right
const NRSMat< T > transposedtimes () const
 for this matrix $A$ compute $A^\mathrm{T}\cdot{}A$
const NRSMat< T > timestransposed () const
 for this matrix $A$ compute $A\cdot{}A^\mathrm{T}$
const NRVec< T > rsum () const
 sum the rows
const NRVec< T > csum () const
 sum the columns
void orthonormalize (const bool rowcol, const NRSMat< T > *metric=NULL)
 orthonormalize this matrix
const NRVec< T > row (const int i, int l=-1) const
 get the ith row
const NRVec< T > column (const int j, int l=-1) const
 get the jth column
const T * diagonalof (NRVec< T > &, const bool divide=0, bool cache=false) const
 extract the digonal elements of this matrix and store them into a vector
void diagonalset (const NRVec< T > &)
 set diagonal elements
void gemv (const T beta, NRVec< T > &r, const char trans, const T alpha, const NRVec< T > &x) const
 perform the gemv operation with vector of type T
void gemv (const T beta, NRVec< complex< T > > &r, const char trans, const T alpha, const NRVec< complex< T > > &x) const
 perform the gemv operation with vector of type complex<T>
T * operator[] (const int i)
 determine the pointer to the ith row
const T * operator[] (const int i) const
 determine the const pointer to the ith row
T & operator() (const int i, const int j)
 get the reference to the element with indices (i,j)
const T & operator() (const int i, const int j) const
 get the const reference to the element with indices (i,j)
const T get_ij (const int i, const int j) const
 get the copy of the element with indices (i,j)
int nrows () const
 get the number of rows
int ncols () const
 get the number of columns
int size () const
 get the number of matrix elements
void get (int fd, bool dimensions=1, bool transposed=false)
 unformatted input
void put (int fd, bool dimensions=1, bool transposed=false) const
 unformatted output
void fprintf (FILE *f, const char *format, const int modulo) const
 formatted output
void fscanf (FILE *f, const char *format)
 formatted input
void clear ()
 set all matrix elements equal to zero
void resize (int n, int m)
 resize the matrix
 operator T * ()
 get the pointer to the data
 operator const T * () const
 get the const pointer to the data
NRMattransposeme (const int n=0)
 in case of square matrix, transpose the leading minor of order n
NRMatconjugateme ()
 conjugate a square matrix
const NRMat transpose (bool conj=false) const
 transpose this matrix and return the result by value
const NRMat conjugate () const
 conjugate this matrix and return the result by value
const NRMat submatrix (const int fromrow, const int torow, const int fromcol, const int tocol) const
 extract specified submatrix
void storesubmatrix (const int fromrow, const int fromcol, const NRMat &rhs)
 store given matrix at given position into the current matrix
void gemm (const T &beta, const NRMat &a, const char transa, const NRMat &b, const char transb, const T &alpha)
 perform the gemm operation
const LA_traits< T >::normtype norm (const T scalar=(T) 0) const
 compute the norm of this matrix
void axpy (const T alpha, const NRMat &x)
 add up a scalar multiple of given matrix to the current matrix
const T amax () const
 maximal element in the absolute value
const T amin () const
 minimal element in the absolute value
const T trace () const
 determine the sum of the diagonal elements
NRMatswap_rows ()
 swap the order of the rows of the current matrix
NRMatswap_cols ()
 swap the order of the columns of the current matrix
NRMatswap_rows_cols ()
 swap the order of the rows and columns of the current matrix
SparseSMat< T > operator* (const SparseSMat< T > &rhs) const
 multiply by sparse matrix
 NRMat (const SparseMat< T > &rhs)
 explicit constructor converting sparse matrix into NRMat<T> object
 NRMat (const SparseSMat< T > &rhs)
 explicit constructor converting sparse symmetric matrix into NRMat<T> object
NRMatoperator+= (const SparseMat< T > &rhs)
 add up given sparse matrix
NRMatoperator-= (const SparseMat< T > &rhs)
 subtract given sparse matrix
void gemm (const T &beta, const SparseMat< T > &a, const char transa, const NRMat &b, const char transb, const T &alpha)
 perform the gemm operation
void simplify ()
bool issymmetric () const
void strassen (const T beta, const NRMat &a, const char transa, const NRMat &b, const char transb, const T alpha)
 Strassen's multiplication (better than $\mathacal{O}(n^3)$, analogous syntax to.
void s_cutoff (const int, const int, const int, const int) const
template<>
NRMat< double > & operator= (const double &a)
template<>
NRMat< complex< double > > & operator= (const complex< double > &a)
template<>
NRMat< double > & operator+= (const double &a)
template<>
NRMat< complex< double > > & operator+= (const complex< double > &a)
template<>
NRMat< double > & operator-= (const double &a)
template<>
NRMat< complex< double > > & operator-= (const complex< double > &a)
template<>
const NRMat< double > operator- () const
template<>
const NRMat< complex< double > > operator- () const
template<>
const NRVec< double > csum () const
template<>
const NRVec< complex< double > > csum () const
template<>
const NRVec< double > rsum () const
template<>
const NRVec< complex< double > > rsum () const
template<>
 NRMat (const NRMat< double > &rhs, bool imagpart)
template<>
const NRSMat< double > transposedtimes () const
template<>
const NRSMat< complex< double > > transposedtimes () const
template<>
const NRSMat< double > timestransposed () const
template<>
const NRSMat< complex< double > > timestransposed () const
template<>
void randomize (const double &x)
template<>
void randomize (const double &x)
template<>
NRMat< double > & operator*= (const double &a)
template<>
NRMat< complex< double > > & operator*= (const complex< double > &a)
template<>
NRMat< double > & operator+= (const NRMat< double > &rhs)
template<>
NRMat< complex< double > > & operator+= (const NRMat< complex< double > > &rhs)
template<>
NRMat< double > & operator-= (const NRMat< double > &rhs)
template<>
NRMat< complex< double > > & operator-= (const NRMat< complex< double > > &rhs)
template<>
NRMat< double > & operator+= (const NRSMat< double > &rhs)
template<>
NRMat< complex< double > > & operator+= (const NRSMat< complex< double > > &rhs)
template<>
NRMat< double > & operator-= (const NRSMat< double > &rhs)
template<>
NRMat< complex< double > > & operator-= (const NRSMat< complex< double > > &rhs)
template<>
const double dot (const NRMat< double > &rhs) const
template<>
const complex< double > dot (const NRMat< complex< double > > &rhs) const
template<>
const NRMat< double > operator* (const NRMat< double > &rhs) const
template<>
const NRMat< complex< double > > operator* (const NRMat< complex< double > > &rhs) const
template<>
void diagmultl (const NRVec< double > &rhs)
template<>
void diagmultl (const NRVec< complex< double > > &rhs)
template<>
void diagmultr (const NRVec< double > &rhs)
template<>
void diagmultr (const NRVec< complex< double > > &rhs)
template<>
const NRMat< double > operator* (const NRSMat< double > &rhs) const
template<>
const NRMat< complex< double > > operator* (const NRSMat< complex< double > > &rhs) const
template<>
NRMat< double > & conjugateme ()
template<>
NRMat< complex< double > > & conjugateme ()
template<>
const NRMat< double > transpose (bool conj) const
template<>
const NRMat< complex< double > > transpose (bool conj) const
template<>
void gemm (const double &beta, const NRMat< double > &a, const char transa, const NRMat< double > &b, const char transb, const double &alpha)
template<>
void gemm (const complex< double > &beta, const NRMat< complex< double > > &a, const char transa, const NRMat< complex< double > > &b, const char transb, const complex< double > &alpha)
template<>
const double norm (const double scalar) const
template<>
const double norm (const complex< double > scalar) const
template<>
void axpy (const double alpha, const NRMat< double > &mat)
template<>
void axpy (const complex< double > alpha, const NRMat< complex< double > > &mat)
template<>
const double * diagonalof (NRVec< double > &r, const bool divide, bool cache) const
template<>
void diagonalset (const NRVec< double > &r)
template<>
void diagonalset (const NRVec< complex< double > > &r)
template<>
void orthonormalize (const bool rowcol, const NRSMat< double > *metric)
template<>
NRMat< double > & swap_rows ()
template<>
NRMat< complex< double > > & swap_rows ()
template<>
NRMat< double > & swap_cols ()
template<>
NRMat< complex< double > > & swap_cols ()
template<>
NRMat< double > & swap_rows_cols ()
template<>
NRMat< complex< double > > & swap_rows_cols ()
template<>
const double amax () const
template<>
const double amin () const
template<>
const complex< double > amax () const
template<>
const complex< double > amin () const
template<>
void gemm (const complex< double > &beta, const SparseMat< complex< double > > &a, const char transa, const NRMat< complex< double > > &b, const char transb, const complex< double > &alpha)
template<>
void gemm (const double &beta, const SparseMat< double > &a, const char transa, const NRMat< double > &b, const char transb, const double &alpha)
template<>
void s_cutoff (const int c, const int c1, const int c2, const int c3) const
template<>
void strassen (const double beta, const NRMat< double > &a, const char transa, const NRMat< double > &b, const char transb, const double alpha)

Protected Attributes

int nn
 number of rows
int mm
 number of columns
T * v
 pointer to the data stored continuously in emmory
int * count
 reference counter

Friends

class NRVec< T >
class NRSMat< T >


Detailed Description

template<typename T>
class LA::NRMat< T >

NRMat<T> class template implementing the matrix interface.

See also:
NRVec<T>, NRSMat<T>

Constructor & Destructor Documentation

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

standard destructor

destructor for general type

See also:
NRMat<T>::count

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

Inlined constructor creating matrix of given size and location. Because of performance reasons, no incialization is done.

Parameters:
[in] n vector size (count of elements)
[in] loc location of the underlying data (CPU/GPU)
matrix constructor
Parameters:
[in] n number of rows of the matrix being created
[in] m number of cols of the matrix being created
[in] loc location for storing the matrix
See also:
count, v, location

template<typename T>
LA::NRMat< T >::NRMat ( const T &  a,
const int  n,
const int  m,
const GPUID  loc 
) [inline]

inlined constructor creating matrix of given size filled with prescribed value and stored at given location

matrix constructor

Parameters:
[in] a value of type T intended for matrix inicialization
[in] n number of rows of the matrix being created
[in] m number of cols of the matrix being created
See also:
count, v

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

inlined constructor creating matrix of given size filled with prescribed value

matrix constructor

Parameters:
[in] a value of type T intended for matrix inicialization
[in] n number of rows of the matrix being created
[in] m number of cols of the matrix being created
See also:
count, v

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

inlined constructor creating matrix of given size filled with data located at given memory location

matrix constructor

Parameters:
[in] a pointer to values of type T intended for matrix inicialization
[in] n number of rows of the matrix being created
[in] m number of cols of the matrix being created
See also:
count, v

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

inlined copy-constructor

copy constructor implementing shallow copy

Parameters:
[in] rhs reference object to be copied
See also:
count, v

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

explicit constructor converting symmetric matrix stored in packed form into a NRMat<T> object

create matrix from a NRSMat object

Parameters:
[in] rhs NRSMat input object to be converted
See also:
count, v, vec.h, NRSMat<T>

template<typename T>
LA::NRMat< T >::NRMat ( const NRVec< T > &  rhs,
const int  n,
const int  m,
const int  offset = 0 
) [inline, explicit]

explicit constructor converting vector into a NRMat<T> object

create matrix from a vector (shallow copy)

Parameters:
[in] rhs NRVec vector containing the data
[in] n number of rows of the matrix being created
[in] m number of cols of the matrix being created
See also:
count, v, vec.h

< make just shallow copy

< therefore increase the reference counter

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

icreate complex double-precision matrix from real double-precision matrix $A$

Parameters:
[in] rhs real double-precision matrix $A$
[in] imagpart flag indicating whether the matrix $A$ should be considered as a real or imaginary part of the complex matrix being created


Member Function Documentation

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

for this complex matrix $A$, determine the smallest index of the maximum magnitude element, i.e. maximal element in the 1-norm

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

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

for this real 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::NRMat< complex< double > >::amin (  )  const [inline]

for this complex matrix $A$, determine the smallest index of the minimum magnitude element, i.e. minimal element in the 1-norm

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

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

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

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

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

perform the axpy operation on the current complex matrix $A$, i.e.

\[ A \leftarrow A + \alpha{}B \]

for real matrix $B$

Parameters:
[in] alpha complex parameter $\alpha$
[in] mat complex matrix $B$

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

perform the axpy operation on the current real matrix $A$, i.e.

\[ A \leftarrow A + \alpha{}B \]

for real matrix $B$

Parameters:
[in] alpha $\alpha$ parameter
[in] mat real matrix $B$

template<>
NRMat< complex< double > > & LA::NRMat< complex< double > >::conjugateme (  )  [inline]

conjugate this complex matrix $A$, i.e. do nothing :-)

Returns:
reference to the modified matrix

template<>
NRMat< double > & LA::NRMat< double >::conjugateme (  )  [inline]

conjugate this real matrix $A$, i.e. do nothing :-)

Returns:
reference to the (unmodified) matrix

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

ensure that the data of this matrix are referenced exactly once

create own deep copy

See also:
NRMat<T>::count, NRMat<T>::operator|=()

template<>
const NRVec< complex< double > > LA::NRMat< complex< double > >::csum (  )  const [inline]

sum up the columns of the current double-precision complex matrix

Returns:
summed columns in a form of a vector

template<>
const NRVec< double > LA::NRMat< double >::csum (  )  const [inline]

sum up the columns of the current double-precision real matrix

Returns:
summed columns in a form of a vector

template<typename T >
const NRVec< T > LA::NRMat< T >::csum (  )  const [inline]

sum the columns

sum up the columns of the current matrix of general type T

Returns:
summed columns in a form of a vector

template<>
void LA::NRMat< complex< double > >::diagmultl ( const NRVec< complex< double > > &  rhs  )  [inline]

multiply this complex matrix $A$ by diagonal complex matrix $D$ from left because of cuBlas implementation, $D$ is required to be placed in CPU memory

Parameters:
[in] rhs complex vector represeting the diagonal of matrix $D$

template<>
void LA::NRMat< double >::diagmultl ( const NRVec< double > &  rhs  )  [inline]

multiply this real matrix $A$ by diagonal real matrix $D$ from left because of cuBlas implementation, $D$ is required to be placed in CPU memory

Parameters:
[in] rhs real vector represeting the diagonal of matrix $D$

template<>
void LA::NRMat< complex< double > >::diagmultr ( const NRVec< complex< double > > &  rhs  )  [inline]

multiply this complex matrix $A$ by diagonal complex matrix $D$ from left

Parameters:
[in] rhs complex vector represeting the diagonal of matrix $D$

template<>
void LA::NRMat< double >::diagmultr ( const NRVec< double > &  rhs  )  [inline]

multiply this real matrix $A$ by diagonal real matrix $D$ from right because of cuBlas implementation, $D$ is required to be placed in CPU memory

Parameters:
[in] rhs real vector represeting the diagonal of matrix $D$

template<>
const double * LA::NRMat< double >::diagonalof ( NRVec< double > &  r,
const bool  divide,
bool  cache 
) const [inline]

get or divide by the diagonal of real double-precision matrix in case of nonsquare matrix $A$, use the diagonal of $A^\mathrm{T}A$

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

< temporary variable for storing the scaling factor

template<>
void LA::NRMat< complex< double > >::diagonalset ( const NRVec< complex< double > > &  r  )  [inline]

sets the diagonal of complex matrix to a given complex vector

Parameters:
[in] r complex vector which is supposed to be assigned to the diagonal
Returns:
void

template<>
void LA::NRMat< double >::diagonalset ( const NRVec< double > &  r  )  [inline]

sets the diagonal of real matrix to a given real vector

Parameters:
[in] r real vector which is supposed to be assigned to the diagonal
Returns:
void

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

compute scalar product of this matrix $A$ with given complex matrix $B$ i.e. determine $\sum_{i,j}A^{*}_{i,j}B_{i,j}$

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

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

compute scalar product of this matrix $A$ with given real matrix $B$ i.e. determine $\sum_{i,j}A_{i,j}B_{i,j}$

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

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

formatted output

output of a matrix of general type via lawritemat

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

formatted input

input of a matrix of general type via lawritemat

template<>
void LA::NRMat< double >::gemm ( const double &  beta,
const NRMat< double > &  a,
const char  transa,
const NRMat< double > &  b,
const char  transb,
const double &  alpha 
) [inline]

perform the gemm operation for this real matrix $M$, i.e. compute

\[M\leftarrow\alpha\times\operatorname{op}(A)\times\operatorname{op}(B) + \beta\times{}M\]

Parameters:
[in] beta $\beta$
[in] a real matrix $A$
[in] transa transposition flag of matrix $A$
[in] b real matrix $B$
[in] transb transposition flag of matrix $B$
[in] alpha $\alpha$

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

unformatted input

routine for raw input

Parameters:
[in] fd file descriptor for input
[in] dim number of elements intended for input, for dim=0 perform copyonwrite
[in] transp reserved
See also:
NRVec<T>::get(), copyonwrite()

template<typename T >
const T LA::NRMat< T >::get_ij ( const int  i,
const int  j 
) const [inline]

get the copy of the element with indices (i,j)

for a given matrix $A$, determine the element with indices (i,j)

Parameters:
[in] i row number
[in] j col number
Returns:
const reference to $A_{i,j}$

Reimplemented in LA::NRMat_from1< T >.

template<typename T>
GPUID LA::NRMat< T >::getlocation (  )  const [inline]

routines for CUDA related stuff

  • getlocation() gets the protected data member location
  • moveto(const GPUID) moves underlying data between CPU/GPU memory

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

get the number of columns

Returns:
number of columns

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

compute the Frobenius norm of the current complex matrix $A$, i.e.

\[ \sqrt{\sum_{i=1}^{N}\sum_{j=1}^{M}\left|A_{i,j}\right|^2} \]

where $N$ and $M$ is the number of rows and columns, respectively

Parameters:
[in] scalar complex value subtracted from the diagonal elements
Returns:
computed norm

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

compute the Frobenius norm of the current real matrix $A$, i.e.

\[ \sqrt{\sum_{i=1}^{N}\sum_{j=1}^{M}\left|A_{i,j}\right|^2} \]

where $N$ and $M$ is the number of rows and columns, respectively

Parameters:
[in] scalar real value subtracted from the diagonal elements
Returns:
computed norm

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

get the number of rows

Returns:
number of rows

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

get the const pointer to the data

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

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

get the pointer to the data

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

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

get the const reference to the element with indices (i,j)

for a given matrix $A$, determine the element with indices (i,j)

Parameters:
[in] i row number
[in] j col number
Returns:
const reference to $A_{i,j}$

Reimplemented in LA::NRMat_from1< T >.

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

get the reference to the element with indices (i,j)

for a given matrix $A$, determine the element with indices (i,j)

Parameters:
[in] i row number
[in] j col number
Returns:
reference to $A_{i,j}$
See also:
NRMat<T>::count

Reimplemented in LA::NRMat_from1< T >.

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

multiply this complex matrix $A$ by symmetric complex matrix $S$ $S$ is stored in packed form, therefore zhpmv routine is used

Parameters:
[in] rhs complex symmetric matrix $S$ stored in packed form
Returns:
$A\times\S$ by value

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

multiply this real matrix $A$ by symmetric matrix $S$ $S$ is stored in packed form, therefore dspmv routine is used

Parameters:
[in] rhs real symmetric matrix $S$ stored in packed form
Returns:
$A\times\S$ by value

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

compute product of this matrix $A$ with given complex matrix $B$

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

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

compute product of this matrix $A$ with given real matrix $B$

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

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

scale complex matrix with a complex factor

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

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

scale real matrix with a real factor

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

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

multiply by a scalar value

scale matrix of type T with a factor

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

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

add given symmetric matrix stored in packed form and return the result by value

NRMat + NRSmat via operator +=

Parameters:
[in] rhs NRSMat matrix to be subtracted from current matrix
Returns:
result of the subtraction
See also:
NRMat<T>::operator+=(const NRSMat<T> &)

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

add a given sparse complex matrix $A$ stored in packed form to the current complex matrix

Parameters:
[in] rhs symmetric complex matrix $A$ in packed form
Returns:
reference to the modified matrix
See also:
NRSMat<T>

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

add a given sparse real matrix $A$ stored in packed form to the current real matrix

Parameters:
[in] rhs symmetric real matrix $A$ in packed form
Returns:
reference to the modified matrix
See also:
NRSMat<T>

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

add a given complex matrix $A$ to the current complex matrix

Parameters:
[in] rhs complex matrix $A$
Returns:
reference to the modified matrix

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

add a given real matrix $A$ to the current real matrix

Parameters:
[in] rhs matrix $A$
Returns:
reference to the modified matrix

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

adds a double-precision complex scalar value to the diagonal elements of this double-precision complex matrix

Parameters:
[in] a double-precision complex scalar value
Returns:
reference to the modified matrix

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

adds a double-precision real scalar value to the diagonal elements of this double-precision real matrix

Parameters:
[in] a double-precision real scalar value
Returns:
reference to the modified matrix

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

add symmetric matrix stored in packed form

add a given general sparse matrix $A$ stored in packed form to the current general matrix (of type T)

Parameters:
[in] rhs symmetric general matrix $A$ in packed form
Returns:
reference to the modified matrix
See also:
NRSMat<T>

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

add given matrix

add a given general matrix (type T) $A$ to the current complex matrix

Parameters:
[in] rhs matrix $A$ of type T
Returns:
reference to the modified matrix

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

add scalar value to the diagonal elements

add a scalar value of type T to the diagonal elements of this matrix of general type T

Returns:
reference to the modified matrix

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

implements unary minus operator for this double-precision complex matrix

Returns:
modified copy of this matrix

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

implements unary minus operator for this double-recision real matrix

Returns:
modified copy of this matrix

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

subtract given symmetric matrix stored in packed form and return the result by value

NRMat - NRSmat via operator -=

Parameters:
[in] rhs NRSMat matrix to be subtracted from current matrix
Returns:
result of the subtraction
See also:
NRMat<T>::operator-=(const NRSMat<T> &)

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

unary minus

implements unary minus operator for this matrix of general type T

Returns:
modified copy of this matrix

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

subtract a given sparse complex matrix $A$ stored in packed form from the current complex matrix

Parameters:
[in] rhs symmetric complex matrix $A$ in packed form
Returns:
reference to the modified matrix
See also:
NRSMat<T>

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

subtract a given sparse real matrix $A$ stored in packed form from the current real matrix

Parameters:
[in] rhs symmetric real matrix $A$ in packed form
Returns:
reference to the modified matrix
See also:
NRSMat<T>

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

subtract a given complex matrix $A$ from the current complex matrix

Parameters:
[in] rhs matrix $A$
Returns:
reference to the modified matrix

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

subtract a given real matrix $A$ from the current real matrix

Parameters:
[in] rhs matrix $A$
Returns:
reference to the modified matrix

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

subtracts a double-precision complex scalar value from the diagonal elements of this double-precision complex matrix

Parameters:
[in] a double-precision complex scalar value
Returns:
reference to the modified matrix

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

subtracts a double-precision real scalar value from the diagonal elements of this double-precision real matrix

Parameters:
[in] a double-precision real scalar value
Returns:
reference to the modified matrix

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

subtract symmetric matrix stored in packed form

subtract a given general sparse matrix $A$ stored in packed form from the current general matrix (of type T)

Parameters:
[in] rhs symmetric general matrix $A$ in packed form
Returns:
reference to the modified matrix
See also:
NRSMat<T>

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

subtract given matrix

subtract a given general matrix (type T) $A$ from the current matrix

Parameters:
[in] rhs matrix $A$ of type T
Returns:
reference to the modified matrix

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

subtract scalar value to the diagonal elements

subtracts a scalar value of type T from the diagonal elements of this matrix of general type T

Returns:
reference to the modified matrix

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

assigns a double-precision complex scalar value to the diagonal elements of this double-precision complex matrix

Parameters:
[in] a double-precision complex scalar value
Returns:
reference to the modified matrix

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

assigns a double-precision real scalar value to the diagonal elements of this double-precision real matrix

Parameters:
[in] a double-precision real scalar value
Returns:
reference to the modified matrix

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

assign scalar value to the diagonal elements

assigns a scalar value of general type T to the diagonal elements of this matrix of general type T

Parameters:
[in] a scalar value of type T
Returns:
reference to the modified matrix

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

assigment operator performing shallow copy

assigment operator for general type between NRMat and NRMat

See also:
count
Returns:
reference to the newly assigned matrix

template<typename T >
const T * LA::NRMat< T >::operator[] ( const int  i  )  const [inline]

determine the const pointer to the ith row

Parameters:
[in] i row number
Returns:
const pointer to the first element in the i-th row

template<typename T >
T * LA::NRMat< T >::operator[] ( const int  i  )  [inline]

determine the pointer to the ith row

Parameters:
[in] i row number
Returns:
pointer to the first element in the i-th row

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

Hadamard element-wise product.

compute Hadamard (component-wise) product with a given matrix $A$

Parameters:
[in] rhs matrix $A$
See also:
count, operator*
Returns:
reference to the multiplied matrix

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

assigment operator performing deep copy

perform an explicit deep copy of NRMat object

See also:
count
Returns:
reference to the newly copied matrix

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

direct sum

implements direct sum with a given matrix $B$ via storesubmatrix()

Parameters:
[in] rhs input matrix $B$
Returns:
result of the computation (new instance of NRMat<T>)
See also:
submatrix()

template<>
void LA::NRMat< double >::orthonormalize ( const bool  rowcol,
const NRSMat< double > *  metric 
) [inline]

perform straightforward orthonormalization via modified Gram-Schmidt process

Parameters:
[in] rowcol flag regarding the interpretation of the current matrix
  • true the vectors being orthonormalized are stored as rows
  • false the vectors being orthonormalized are stored as columns
[in] metric pointer to real symmetric matrix stored in packed form which is used in computing the inner products in the process, the standard inner product is taken into account for metric == NULL
Returns:
void

template<typename T >
const NRMat< T > LA::NRMat< T >::otimes ( const NRMat< T > &  rhs,
bool  reversecolumns = false 
) const [inline]

direct product

implements direct product with a given matrix $B$

Parameters:
[in] rhs input matrix $B$
Returns:
result of the computation (new instance of NRMat<T>)

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

unformatted output

routine for raw output

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

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

fill given complex matrix with random numbers real/imaginary components are generated independently

Parameters:
[in] x generate random numbers from the interval [0, x]

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

fill given real matrix with random numbers

Parameters:
[in] x generate random numbers from the interval [0, x]

template<typename T >
void LA::NRMat< T >::resize ( int  n,
int  m 
) [inline]

resize the matrix

resize given matrix

Parameters:
[in] n number of rows
[in] m number of cols
See also:
count, NRMat<T>::copyonwrite(), NRMat<T>::operator|=()
Returns:
reference to the newly copied matrix

template<typename T >
const NRVec< T > LA::NRMat< T >::row ( const int  i,
int  l = -1 
) const [inline]

get the ith row

extract given row of this matrix of general type T

Parameters:
[in] i row index starting from zero
[in] l consider this value as the count of columns
Returns:
extracted elements as a NRVec<T> object

template<>
const NRVec< complex< double > > LA::NRMat< complex< double > >::rsum (  )  const [inline]

sum up the rows of the current double-precision complex matrix

Returns:
summed rows in a form of a vector

template<>
const NRVec< double > LA::NRMat< double >::rsum (  )  const [inline]

sum up the rows of the current double-precision real matrix

Returns:
summed rows in a form of a vector

template<typename T >
const NRVec< T > LA::NRMat< T >::rsum (  )  const [inline]

sum the rows

sum up the rows of the current matrix of general type T

Returns:
summed rows in a form of a vector

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

get the number of matrix elements

Returns:
number of elements

template<typename T >
void LA::NRMat< T >::storesubmatrix ( const int  fromrow,
const int  fromcol,
const NRMat< T > &  rhs 
) [inline]

store given matrix at given position into the current matrix

places given matrix as submatrix at given position

Parameters:
[in] fromrow row-coordinate of top left corner
[in] fromcol col-coordinate of top left corner
[in] rhs input matrix

template<typename T>
void LA::NRMat< T >::strassen ( const T  beta,
const NRMat< T > &  a,
const char  transa,
const NRMat< T > &  b,
const char  transb,
const T  alpha 
)

Strassen's multiplication (better than $\mathacal{O}(n^3)$, analogous syntax to.

See also:
NRMat<T>::gemm() )

template<typename T >
const NRMat< T > LA::NRMat< T >::submatrix ( const int  fromrow,
const int  torow,
const int  fromcol,
const int  tocol 
) const [inline]

extract specified submatrix

extract block submatrix

Parameters:
[in] fromrow starting row
[in] torow final row
[in] fromcol starting column
[in] tocol final column
Returns:
extracted block submatrix

template<>
NRMat< complex< double > > & LA::NRMat< complex< double > >::swap_cols (  )  [inline]

interchange the order of the columns of the current (complex) matrix

Returns:
reference to the modified matrix

template<>
NRMat< double > & LA::NRMat< double >::swap_cols (  )  [inline]

interchange the order of the columns of the current (real) matrix

Returns:
reference to the modified matrix

template<typename T >
NRMat< T > & LA::NRMat< T >::swap_cols (  )  [inline]

swap the order of the columns of the current matrix

interchange the order of the columns of the current general matrix of type T because of the cuBlas implementation, the GPU version requires that sizeof(T)sizeof(float)==0

Returns:
reference to the modified matrix

template<>
NRMat< complex< double > > & LA::NRMat< complex< double > >::swap_rows (  )  [inline]

interchange the order of the rows of the current (complex) matrix

Returns:
reference to the modified matrix

template<>
NRMat< double > & LA::NRMat< double >::swap_rows (  )  [inline]

interchange the order of the rows of the current (real) matrix

Returns:
reference to the modified matrix

template<typename T >
NRMat< T > & LA::NRMat< T >::swap_rows (  )  [inline]

swap the order of the rows of the current matrix

interchange the order of the rows of the current general matrix of type T for GPU computations, the condition sizeof(T)sizeof(float) is required

Returns:
reference to the modified matrix

template<>
NRMat< complex< double > > & LA::NRMat< complex< double > >::swap_rows_cols (  )  [inline]

interchange the order of the rows and columns of the current complex matrix $A$ of type T, i.e. perform the operation

\[A_{i,j}\leftarrow A_{nn-1-i, mm-1-j}\]

where $0\leq{}i\le{}nn$ and $0\leq{}j\le{}mm$

Returns:
reference to the modified matrix

template<>
NRMat< double > & LA::NRMat< double >::swap_rows_cols (  )  [inline]

interchange the order of the rows and columns of the current real matrix $A$ of type T, i.e. perform the operation

\[A_{i,j}\leftarrow A_{nn-1-i, mm-1-j}\]

where $0\leq{}i\le{}nn$ and $0\leq{}j\le{}mm$

Returns:
reference to the modified matrix

template<typename T >
NRMat< T > & LA::NRMat< T >::swap_rows_cols (  )  [inline]

swap the order of the rows and columns of the current matrix

interchange the order of the rows and columns of the current general matrix $A$ of type T, i.e. perform the operation

\[A_{i,j}\leftarrow A_{nn-1-i, mm-1-j}\]

where $0\leq{}i\le{}nn$ and $0\leq{}j\le{}mm$

Returns:
reference to the modified matrix

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

for a given complex matrix $A$ compute $AA^\dagger{}$

Returns:
complex NRSMat object because of the hermiticity of $AA^\dagger{}$

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

for a given real matrix $A$ compute $AA^\mathrm{T}$

Returns:
real NRSMat object because of the symmetry of $AA^\mathrm{T}$

< resulting matrix has nn rows

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

for this matrix $A$ compute $A\cdot{}A^\mathrm{T}$

for a given matrix $A$ (general type) compute $A^\mathrm{T}A$

Returns:
NRSMat<T> object because of the symmetry of the result

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

determine the sum of the diagonal elements

compute the trace of current genenal square matrix $A$, i.e.

\[ \sum_{i=1}^{N} A_{i,i} \]

where $N$ is the order of the matrix

template<>
const NRMat< complex< double > > LA::NRMat< complex< double > >::transpose ( bool  conj  )  const [inline]

compute transpose (optionally conjugated) of this real matrix $A$

Parameters:
[in] conj conjugation flag
Returns:
transposed (conjugated) matrix by value

template<>
const NRMat< double > LA::NRMat< double >::transpose ( bool  conj  )  const [inline]

compute transpose (optionally conjugated) of this real matrix $A$

Parameters:
[in] conj conjugation flag, unused for real matrices
Returns:
transposed (conjugated) matrix by value

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

for a given complex matrix $A$ compute $A^\dagger{}A$

Returns:
complex NRSMat object because of the hermiticity of $A^\dagger{}A$

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

for a given real matrix $A$ compute $A^\mathrm{T}A$

Returns:
real NRSMat object because of the symmetry of $A^\mathrm{T}A$

< resulting matrix has mm rows

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

for this matrix $A$ compute $A^\mathrm{T}\cdot{}A$

for a given matrix $A$ (general type) compute $A^\mathrm{T}A$

Returns:
NRSMat<T> object because of the symmetry of the result

template<typename T >
NRMat< T > & LA::NRMat< T >::transposeme ( const int  _n = 0  )  [inline]

in case of square matrix, transpose the leading minor of order n

compute matrix transposition for a principal leading minor

Parameters:
[in] _n order of the leading minor
Returns:
reference to the modified matrix

< transpose the entire matrix


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


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