LA::NRVec< T > Class Template Reference

NRVec<T> class template implementing the vector interface. More...

#include <vec.h>

List of all members.

Public Types

typedef T ROWTYPE

Public Member Functions

 ~NRVec ()
 standard destructor
 NRVec ()
 NRVec (const int n, const GPUID loc=undefined)
 NRVec (const T &a, const int n)
 inlined constructor creating vector of given size filled with prescribed value
 NRVec (const T *a, const int n)
 inlined constructor creating vector of given size filled with data located at given memory location
 NRVec (T *a, const int n, bool skeleton)
 inlined constructor creating vector of given size filled with data located at given memory location
 NRVec (const NRVec &rhs)
 inlined copy constructor
 NRVec (const typename LA_traits_complex< T >::NRVec_Noncomplex_type &rhs, bool imagpart=false)
 complexifying constructor
 NRVec (const NRSMat< T > &S)
 explicit inlined constructor converting symmetric matrix into a vector
 NRVec (const NRMat< T > &rhs)
GPUID getlocation () const
void moveto (const GPUID dest)
void copyonwrite ()
 create separate copy of the data corresponding to this vector
void clear ()
 purge this vector
NRVecoperator= (const NRVec &rhs)
 assignment operator assigns given vector
NRVecoperator= (const T &a)
 assigment operator assigns given scalar to each element of this vector
void randomize (const typename LA_traits< T >::normtype &x)
 fills in this vector with pseudo-random numbers generated using uniform distribution
NRVecoperator|= (const NRVec &rhs)
 perform deep-copy of given vector
const bool operator!= (const NRVec &rhs) const
 relational operators
const bool operator== (const NRVec &rhs) const
const bool operator> (const NRVec &rhs) const
const bool operator< (const NRVec &rhs) const
const bool operator>= (const NRVec &rhs) const
const bool operator<= (const NRVec &rhs) const
const NRVec operator- () const
 unary minus
NRVecoperator+= (const NRVec &rhs)
 bunch of vector-vector arithmetic operators defined element-wise
NRVecoperator-= (const NRVec &rhs)
NRVecoperator*= (const NRVec &rhs)
NRVecoperator/= (const NRVec &rhs)
const NRVec operator+ (const NRVec &rhs) const
const NRVec operator- (const NRVec &rhs) const
NRVecoperator+= (const T &a)
 bunch of scalar-vector arithmetic operators defined element-wise
NRVecoperator-= (const T &a)
NRVecoperator*= (const T &a)
const NRVec operator+ (const T &a) const
const NRVec operator- (const T &a) const
const NRVec operator* (const T &a) const
int getcount () const
 determine the actual value of the reference counter
const T operator* (const NRVec &rhs) const
 compute the Euclidean inner product (with conjugation in complex case)
const T dot (const NRVec &rhs) const
const T dot (const T *a, const int stride=1) const
 compute the Euclidean inner product (with conjugation in complex case) with a stride-vector
void gemv (const T beta, const NRMat< T > &a, const char trans, const T alpha, const NRVec &x)
void gemv (const T beta, const NRSMat< T > &a, const char trans, const T alpha, const NRVec &x)
void gemv (const T beta, const SparseMat< T > &a, const char trans, const T alpha, const NRVec &x, const bool treat_as_symmetric=false)
void gemv (const typename LA_traits_complex< T >::Component_type beta, const typename LA_traits_complex< T >::NRMat_Noncomplex_type &a, const char trans, const typename LA_traits_complex< T >::Component_type alpha, const NRVec &x)
void gemv (const typename LA_traits_complex< T >::Component_type beta, const typename LA_traits_complex< T >::NRSMat_Noncomplex_type &a, const char trans, const typename LA_traits_complex< T >::Component_type alpha, const NRVec &x)
const NRVec operator* (const NRMat< T > &mat) const
 multiply given matrix with this vector from left
const NRVec operator* (const NRSMat< T > &mat) const
 multiply given symmetric matrix in packed form with this vector from left
const NRVec operator* (const SparseMat< T > &mat) const
 multiply given sparse matrix with this vector from left
const NRMat< T > otimes (const NRVec< T > &rhs, const bool conjugate=false, const T &scale=1) const
 compute the outer product of two vectors
const NRMat< T > operator| (const NRVec< T > &rhs) const
 opeartor for outer product computation
const T sum () const
 compute the sum of the vector elements
const LA_traits< T >::normtype asum () const
 compute the sum of the absolute values of the elements of this vector
T & operator[] (const int i)
 indexing operator - index running from zero
const T & operator[] (const int i) const
void setcoldim (int i)
 dummy routine
 operator T * ()
 get the pointer to the underlying data structure
 operator const T * () const
 get the constant pointer to the underlying data structure
void axpy (const T alpha, const NRVec &x)
 add up a scalar multiple of a given vector
void axpy (const T alpha, const T *x, const int stride=1)
 add up a scalar multiple of a given vector with given stride
int size () const
 determine the number of elements
void resize (const int n)
 resize the current vector
const LA_traits< T >::normtype norm () const
 determine the norm of this vector
NRVecnormalize (typename LA_traits< T >::normtype *norm=0)
 normalize this vector and optionally save the norm
const NRVec unitvector () const
 get normalized copy of this vector
const T amax () const
 determine the maximal element (in the absolute value) of this vector
const T amin () const
 determine the minimal element (in the absolute value) of this vector
void fprintf (FILE *f, const char *format, const int modulo) const
 routine for formatted output
void put (int fd, bool dimensions=1, bool transp=0) const
 routine for unformatted output
void fscanf (FILE *f, const char *format)
 routine for formatted input
void get (int fd, bool dimensions=1, bool transp=0)
 routine for unformatted input
 NRVec (const SparseMat< T > &rhs)
 constructor creating vector from sparse matrix
void simplify ()
 routine for compatibility with sparse types
bool bigger (int i, int j) const
 determine whether the ith element is bigger than the jth element
bool smaller (int i, int j) const
 determine whether the ith element is bigger than the jth element
void swap (int i, int j)
 swap the ith and jth element
int sort (int direction=0, int from=0, int to=-1, int *perm=NULL)
 sort by default in ascending order and return the parity of corresponding permutation resulting to this order
NRVeccall_on_me (T(*_F)(const T &))
 apply given function to each element
template<>
const NRVec< double > operator- () const
template<>
const NRVec< complex< double > > operator- () const
template<>
void randomize (const double &x)
template<>
void randomize (const double &x)
template<>
 NRVec (const NRVec< double > &rhs, bool imagpart)
template<>
void axpy (const double alpha, const NRVec< double > &x)
template<>
void axpy (const complex< double > alpha, const NRVec< complex< double > > &x)
template<>
void axpy (const double alpha, const double *x, const int stride)
template<>
void axpy (const complex< double > alpha, const complex< double > *x, const int stride)
template<>
NRVec< double > & operator= (const double &a)
template<>
NRVec< complex< double > > & operator= (const complex< double > &a)
template<>
NRVec< double > & normalize (double *norm)
template<>
NRVec< complex< double > > & normalize (double *norm)
template<>
void gemv (const double beta, const NRMat< double > &A, const char trans, const double alpha, const NRVec &x)
template<>
void gemv (const double beta, const NRMat< double > &A, const char trans, const double alpha, const NRVec< complex< double > > &x)
template<>
void gemv (const complex< double > beta, const NRMat< complex< double > > &A, const char trans, const complex< double > alpha, const NRVec< complex< double > > &x)
template<>
void gemv (const double beta, const NRSMat< double > &A, const char trans, const double alpha, const NRVec &x)
template<>
void gemv (const double beta, const NRSMat< double > &A, const char trans, const double alpha, const NRVec< complex< double > > &x)
template<>
void gemv (const complex< double > beta, const NRSMat< complex< double > > &A, const char trans, const complex< double > alpha, const NRVec< complex< double > > &x)
template<>
const NRMat< double > otimes (const NRVec< double > &b, const bool conj, const double &scale) const
template<>
const NRMat< complex< double > > otimes (const NRVec< complex< double > > &b, const bool conj, const complex< double > &scale) const
template<>
NRVec< double > & operator+= (const double &a)
template<>
NRVec< complex< double > > & operator+= (const complex< double > &a)
template<>
NRVec< double > & operator-= (const double &a)
template<>
NRVec< complex< double > > & operator-= (const complex< double > &a)
template<>
NRVec< double > & operator+= (const NRVec< double > &rhs)
template<>
NRVec< complex< double > > & operator+= (const NRVec< complex< double > > &rhs)
template<>
NRVec< double > & operator-= (const NRVec< double > &rhs)
template<>
NRVec< complex< double > > & operator-= (const NRVec< complex< double > > &rhs)
template<>
NRVec< double > & operator*= (const double &a)
template<>
NRVec< complex< double > > & operator*= (const complex< double > &a)
template<>
const double operator* (const NRVec< double > &rhs) const
template<>
const complex< double > operator* (const NRVec< complex< double > > &rhs) const
template<>
const double dot (const double *y, const int stride) const
template<>
const complex< double > dot (const complex< double > *y, const int stride) const
template<>
const double asum () const
template<>
const double asum () const
template<>
const double norm () const
template<>
const double norm () const
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
 size of the vector
T * v
 pointer to the underlying data structure
int * count
 pointer to the reference-counter

Friends

class NRSMat< T >
class NRMat< T >
template<typename U >
NRVec< complex< U > > complexify (const NRVec< U > &)


Detailed Description

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

NRVec<T> class template implementing the vector interface.

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

Constructor & Destructor Documentation

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

standard destructor

generate operators involving vector and scalar generate operators involving vector and vector destructor for general vector decreases the reference count and performs deallocation if neccessary

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

inlined constructor creating zero vector of general type T

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

Explicit inlined constructor creating vector 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)

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

inlined constructor creating vector of given size filled with prescribed value

inline constructor creating vector of given size filled with prescribed value

Parameters:
[in] a value to be assigned to all vector elements
[in] n required vector size

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

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

inline constructor creating vector of given size filled with given data

Parameters:
[in] a pointer to the data
[in] n required vector size

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

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

inline constructor creating vector of given size filled with given data

Parameters:
[in] a pointer to the data
[in] n required vector size
[in] skeleton if equal to true, only the internal data pointer is modified and reference counter is set to two, i.e. no data deallocation occurs in destructor

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

inlined copy constructor

inline copy constructor

Parameters:
[in] rhs reference vector being copied

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

explicit inlined constructor converting symmetric matrix into a vector

inline constructor interpreting symmetric matrix of order $n$ stored in packed form as a linear vector consisting of $n(n+1)/2$ elements

Parameters:
[in] rhs symmetric matrix of type NRSMat<T>
See also:
NRSMat<T>

using macro NN2 defined in smat.h

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

conversion constructor interpreting a given matrix with $N$ rows and $M$ columns of general type T as a vector of $N\times{}M$ elements

Parameters:
[in] rhs matrix being converted
See also:
NRMat<T>::NRMat()

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

constructor creating complex vector from a real one

Parameters:
[in] rhs the real vector being converted into the complex one
[in] imagpart 
  • true vector rhs is interpreted as the imaginary part of the new complex vector
  • false vector rhs is interpreted as the real part of the new complex vector
Returns:
  • false current vector is bigger than vector rhs
  • true current vector is smaller than vector rhs


Member Function Documentation

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

for a given complex vector $\vec{v}$, determine the smallest index of the maximum magnitude element, i.e. maximal element in the 1-norm

Returns:
$\vec{v}_{j}$ which maximizes $\left\{\left|\Re{}\vec{v}_{i}\right|+\left|\Im{}\vec{v}_{i}\right|\right}$

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

for this real vector $\vec{x}$ determine the element with largest absolute value

Returns:
$\vec{x}_i$ where $\left|\vec{x]_i\right|=\mathrm{max}_{j}\left|\vec{x}_{j}\right|$

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

for a given complex vector $\vec{v}$, determine the smallest index of the minimum magnitude element, i.e. minimal element in the 1-norm

Returns:
$\vec{v}_{j}$ which minimizes $\left\{\left|\Re{}\vec{v}_{i}\right|+\left|\Im{}\vec{v}_{i}\right|\right}$

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

for this real vector $\vec{x}$ determine the element with smallest absolute value

Returns:
$\vec{x}_i$ where $\left|\vec{x]_i\right|=\mathrm{min}_{j}\left|\vec{x}_{j}\right|$

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

for this complex vector $\vec{x}$ compute the expression

\[\sum_{i=1}^N\left|\Re{}\vec{x}_i\right| + \left|\Im{}\vec{x}_i\right|\]

Returns:
the value of this sum

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

computes the sum of the absolute values of the elements of this real vector $\vec{x}$

Returns:
$\sum_{i=1}^N\left|\vec{x}_i\right|$

template<>
void LA::NRVec< complex< double > >::axpy ( const complex< double >  alpha,
const complex< double > *  x,
const int  stride 
) [inline]

perform the axpy operation on the current complex vector $\vec{v}$, i.e.

\[ \vec{v} \leftarrow \vec{v} + \alpha\vec{x} \]

Parameters:
[in] alpha double-precision complex parameter $\alpha$
[in] x pointer to double-precision complex data
[in] stride sets the stride

template<>
void LA::NRVec< double >::axpy ( const double  alpha,
const double *  x,
const int  stride 
) [inline]

perform the axpy operation on the current real vector $\vec{v}$, i.e.

\[ \vec{v} \leftarrow \vec{v} + \alpha\vec{x} \]

Parameters:
[in] alpha $\alpha$ parameter
[in] x pointer to double-precision real data
[in] stride sets the stride

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

perform the axpy operation on the current complex vector $\vec{v}$, i.e.

\[ \vec{v} \leftarrow \vec{v} + \alpha\vec{x} \]

Parameters:
[in] alpha $\alpha$ parameter
[in] x complex vector $\vec{x}$

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

perform the axpy operation on the current real vector $\vec{v}$, i.e.

\[ \vec{v} \leftarrow \vec{v} + \alpha\vec{x} \]

Parameters:
[in] alpha double-precision real parameter $\alpha$
[in] x double-precision real vector $\vec{x}$

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

create separate copy of the data corresponding to this vector

make own copy of the underlying data connected with this vector

template<>
const complex< double > LA::NRVec< complex< double > >::dot ( const complex< double > *  y,
const int  stride 
) const [inline]

computes the inner product of this complex vector $\vec{x}$ with given complex data

Parameters:
[in] y pointer to the double-precision complex array (sufficient length assumed)
[in] stride specifies the stride regarding the data pointe to by y
Returns:
$\sum_{i=1}^N\vec{x}_{i}\cdot \overbar{y_{\mathrm{stride}\cdot(i-1) + 1}}$

template<>
const double LA::NRVec< double >::dot ( const double *  y,
const int  stride 
) const [inline]

computes the inner product of this real vector $\vec{x}$ with given real data

Parameters:
[in] y pointer to the double-precision real array (sufficient length assumed)
[in] stride specifies the stride regarding the data pointe to by y
Returns:
$\sum_{i=1}^N\vec{x}_{i}\cdot y_{\mathrm{stride}\cdot(i-1) + 1}$

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

routine for formatted output

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::NRVec< T >::fscanf ( FILE *  f,
const char *  format 
) [inline]

routine for formatted input

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<>
void LA::NRVec< complex< double > >::gemv ( const complex< double >  beta,
const NRSMat< complex< double > > &  A,
const char  trans,
const complex< double >  alpha,
const NRVec< complex< double > > &  x 
) [inline]

perform the gemv operation on this complex vector $\vec{y}$, i.e.

\[\vec{y}\leftarrow \alpha\operatorname{op}(A)\cdot\vec{x}+\beta\vec{y}\]

Parameters:
[in] beta complex parameter $\beta$
[in] A complex Hermitian matrix $A$ stored in packed form
[in] trans not used
[in] alpha complex parameter $\alpha$
[in] x complex vector $\vec{x}$
See also:
gemm, NRSMat<T>

template<>
void LA::NRVec< complex< double > >::gemv ( const double  beta,
const NRSMat< double > &  A,
const char  trans,
const double  alpha,
const NRVec< complex< double > > &  x 
) [inline]

perform the gemv operation on this complex vector $\vec{y}$, i.e.

\[\vec{y}\leftarrow \alpha\operatorname{op}(A)\cdot\vec{x}+\beta\vec{y}\]

Parameters:
[in] beta real parameter $\beta$
[in] A real symmetric matrix $A$ stored in packed form
[in] trans if trans == 'n' use $A$ directly, otherwise $\operatorname{op}(A)\equiv{}A^\mathrm{T}$
[in] alpha real parameter $\alpha$
[in] x complex vector $\vec{x}$
See also:
gemm, NRSMat<T>

template<>
void LA::NRVec< double >::gemv ( const double  beta,
const NRSMat< double > &  A,
const char  trans,
const double  alpha,
const NRVec< T > &  x 
) [inline]

perform the gemv operation on this real vector $\vec{y}$, i.e.

\[\vec{y}\leftarrow \alpha\operatorname{op}(A)\cdot\vec{x}+\beta\vec{y}\]

Parameters:
[in] beta real parameter $\beta$
[in] A real symmetric matrix $A$ stored in packed form
[in] trans if trans == 'n' use $A$ directly, otherwise $\operatorname{op}(A)\equiv{}A^\mathrm{T}$
[in] alpha real parameter $\alpha$
[in] x real vector $\vec{x}$
See also:
gemm, NRSMat<T>

template<>
void LA::NRVec< complex< double > >::gemv ( const complex< double >  beta,
const NRMat< complex< double > > &  A,
const char  trans,
const complex< double >  alpha,
const NRVec< complex< double > > &  x 
) [inline]

perform the gemv operation on this complex vector $\vec{y}$, i.e.

\[\vec{y}\leftarrow \alpha\operatorname{op}(A)\cdot\vec{x}+\beta\vec{y}\]

Parameters:
[in] beta complex parameter $\beta$
[in] A complex matrix $A$
[in] trans if trans == 'n' use $A$ directly, otherwise $\operatorname{op}(A)\equiv{}A^\mathrm{T}$
[in] alpha complex parameter $\alpha$
[in] x real vector $\vec{x}$
See also:
gemm

template<>
void LA::NRVec< complex< double > >::gemv ( const double  beta,
const NRMat< double > &  A,
const char  trans,
const double  alpha,
const NRVec< complex< double > > &  x 
) [inline]

perform the gemv operation on this complex vector $\vec{y}$, i.e.

\[\vec{y}\leftarrow \alpha\operatorname{op}(A)\cdot\vec{x}+\beta\vec{y}\]

Parameters:
[in] beta real parameter $\beta$
[in] A real matrix $A$
[in] trans if trans == 'n' use $A$ directly, otherwise $\operatorname{op}(A)\equiv{}A^\mathrm{T}$
[in] alpha real parameter $\alpha$
[in] x real vector $\vec{x}$
See also:
gemm

template<>
void LA::NRVec< double >::gemv ( const double  beta,
const NRMat< double > &  A,
const char  trans,
const double  alpha,
const NRVec< T > &  x 
) [inline]

perform the gemv operation on this real vector $\vec{y}$, i.e.

\[\vec{y}\leftarrow \alpha\operatorname{op}(A)\cdot\vec{x}+\beta\vec{y}\]

Parameters:
[in] beta real parameter $\beta$
[in] A real matrix $A$
[in] trans if trans == 'n' use $A$ directly, otherwise $\operatorname{op}(A)\equiv{}A^\mathrm{T}$
[in] alpha real parameter $\alpha$
[in] x real vector $\vec{x}$
See also:
NRMat<T>::gemm

template<typename T>
void LA::NRVec< T >::gemv ( const T  beta,
const NRSMat< T > &  a,
const char  trans,
const T  alpha,
const NRVec< T > &  x 
)

Parameters:
trans just for compatibility reasons

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

routine for 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:
NRMat<T>::get(), copyonwrite()

template<typename T>
GPUID LA::NRVec< 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<>
const double LA::NRVec< complex< double > >::norm (  )  const [inline]

for this complex vector $\vec{x}$ (of $N$ elements) determine the Frobenius norm

Returns:
$\sum_{i=1}^N\left|\vec{x}_i\right|^2$

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

for this real vector $\vec{x}$ (of $N$ elements) determine the Frobenius norm

Returns:
$\sum_{i=1}^N\left|\vec{x}_i\right|^2$

template<>
NRVec< complex< double > > & LA::NRVec< complex< double > >::normalize ( double *  norm  )  [inline]

normalize current complex vector (in the Euclidean norm)

Parameters:
[in] norm if not NULL, the norm of this vector is stored into *norm
Returns:
reference to the modified vector

template<>
NRVec< double > & LA::NRVec< double >::normalize ( double *  norm  )  [inline]

normalize current real vector (in the Euclidean norm)

Parameters:
[in] norm if not NULL, the norm of this vector is stored into *norm
Returns:
reference to the modified vector

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

get the constant pointer to the underlying data structure

get the constant pointer to the underlying data of this vector

Returns:
constant pointer to the first vector element

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

get the pointer to the underlying data structure

get the pointer to the underlying data of this vector

Returns:
pointer to the first vector element

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

computes the inner product of this complex vector $\vec{x}$ with given complex vector $\vec{y}$ taking conjugation of vector $\vec{x}$ into account

Parameters:
[in] rhs complex vector $\vec{y}$
Returns:
$\sum_{i=1}^N\overbar{\vec{x}_i}\cdot\vec{y}_i$

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

computes the inner product of this real vector $\vec{x}$ with given real vector $\vec{y]$

Parameters:
[in] rhs real vector $\vec{y}$
Returns:
$\sum_{i=1}^N\vec{x}_i\cdot\vec{y}_i$

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

compute the Euclidean inner product (with conjugation in complex case)

compute scalar product $d$ of this vector $\vec{x}$ of general type T with given vector $\vec{y}$ of type T and order $N$

\[d = \sum_{i=1}^N\vec{x}_i\cdot\vec{y}_i\]

Parameters:
[in] rhs general vector $\vec{y}$
Returns:
reference to the modified vector

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

multiplies this complex vector $\vec{x}$ by a complex scalar value $\alpha$

\[\vec{x}_i\leftarrow\alpha\vec{x}_i\]

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

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

multiplies this real vector $\vec{x}$ by a real scalar value $\alpha$

\[\vec{x}_i\leftarrow\alpha\vec{x}_i\]

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

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

multiply this general vector $\vec{x}$ by scalar value $\lambda$

\[\vec{x}_i \leftarrow \lambda\vec{x}_i\]

Parameters:
[in] a scalar value $\lambda$
Returns:
reference to the modified vector

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

multiplies this vector $\vec{y}$ componentwise by general vector $\vec{x}$

\[\vec{x}_i = \vec{x}_i\times\vec{y}_i\]

Parameters:
[in] rhs general vector $\vec{y}$
Returns:
reference to the modified vector

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

adds a complex vector $\vec{y}$ to this complex vector $\vec{x}$

\[\vec{x}\leftarrow\vec{x}+\vec{y}\]

Parameters:
[in] rhs complex vector $\vec{y}$
Returns:
reference to the modified vector

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

adds a real vector $\vec{y}$ to this real vector $\vec{x}$

\[\vec{x}\leftarrow\vec{x}+\vec{y}\]

Parameters:
[in] rhs real vector $\vec{y}$
Returns:
reference to the modified vector

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

adds a complex scalar value $\alpha$ to all elements of this complex vector $\vec{x}$

\[\vec{x}_i\leftarrow\vec{x}_i+\alpha\]

Parameters:
[in] a complex scalar value $\alpha$ being added
Returns:
reference to the modified vector

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

routine for moving vector data between CPU and GPU memory

Parameters:
[in] dest required location
See also:
NRVec<T>::location, NRVec<T>::getlocation() adds a real scalar value $\alpha$ to all elements of this real vector $\vec{x}$

\[\vec{x}_i\leftarrow\vec{x}_i+\alpha\]

Parameters:
[in] a real scalar value $\alpha$ being added
Returns:
reference to the modified vector

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

bunch of scalar-vector arithmetic operators defined element-wise

adds given scalar value of type T to all vector elements

Parameters:
[in] a scalar value being added
Returns:
reference to the modified vector

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

bunch of vector-vector arithmetic operators defined element-wise

adds a vector $\vec{y}$ of general type T to this vector $\vec{x}$

\[\vec{x}\leftarrow\vec{x}+\vec{y}\]

Parameters:
[in] rhs vector $\vec{y}$ of type T
Returns:
reference to the modified vector

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

unary minus operator in case of complex double-precision vector

Returns:
the modified vector by value

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

unary minus operator in case of real double-precision vector

Returns:
the modified vector by value

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

unary minus

unary minus operator for vector of general type

Returns:
the modified vector

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

subtracts a complex vector $\vec{y}$ from this complex vector $\vec{x}$

\[\vec{x}\leftarrow\vec{x}-\vec{y}\]

Parameters:
[in] rhs double-precision complex vector $\vec{y}$
Returns:
reference to the modified vector

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

subtracts a real vector $\vec{y}$ from this real vector $\vec{x}$

\[\vec{x}\leftarrow\vec{x}-\vec{y}\]

Parameters:
[in] rhs real vector $\vec{y}$
Returns:
reference to the modified vector

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

subtracts a complex scalar value $\alpha$ from all elements of this complex vector $\vec{x}$

\[\vec{x}_i\leftarrow\vec{x}_i-\alpha\]

Parameters:
[in] a complex scalar value $\alpha$ being subtracted
Returns:
reference to the modified vector

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

subtracts a real scalar value $\alpha$ from all elements of this real vector $\vec{x}$

\[\vec{x}_i\leftarrow\vec{x}_i-\alpha\]

Parameters:
[in] a real scalar value $\alpha$ being subtracted
Returns:
reference to the modified vector

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

subtracts given scalar value of type T from all vector elements

Parameters:
[in] a scalar value being subtracted
Returns:
reference to the modified vector

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

subtracts given vector $\vec{y}$ from this vector $\vec{x}$

\[\vec{x}_i = \vec{x}_i-\vec{y}_i\]

Parameters:
[in] rhs vector $\vec{y}$
Returns:
reference to the modified vector

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

divides this vector $\vec{y}$ componentwise by general vector $\vec{x}$

\[\vec{x}_i = \vec{x}_i\slash\vec{y}_i\]

Parameters:
[in] rhs general vector $\vec{y}$
Returns:
reference to the modified vector

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

comparison operator (lexicographical order)

Parameters:
[in] rhs vector intended for comparison
Returns:
  • false current vector is bigger than vector rhs
  • true current vector is smaller than vector rhs

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

assign complex scalar value to every element of the current vector

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

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

assign real scalar value to every element of the current vector

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

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

assigment operator assigns given scalar to each element of this vector

assign scalar value to every element of the current vector of general type T

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

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

assignment operator assigns given vector

assigns general vector $\vec{y}$ to this vector $\vec{x}$

  • checks for self-assignment
  • decreases the reference count and performs deallocation if neccesary
  • links the internal data structures with corresponding properties of vector $\vec{y}$
  • updates the reference count properly

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

comparison operator (lexicographical order)

Parameters:
[in] rhs vector intended for comparison
Returns:
  • true current vector is bigger than vector rhs
  • false current vector is smaller than vector rhs

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

indexing operator giving the element at given position with range checking in the DEBUG mode

Parameters:
[in] i position of the required vector element (starting from 0)
Returns:
constant reference to the requested element

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

indexing operator - index running from zero

indexing operator giving the element at given position with range checking in the DEBUG mode

Parameters:
[in] i position of the required vector element (starting from 0)
Returns:
reference to the requested element

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

perform deep-copy of given vector

perfrom deep copy

Parameters:
[in] rhs vector being copied
See also:
NRVec<T>::copyonwrite()

template<>
const NRMat< complex< double > > LA::NRVec< complex< double > >::otimes ( const NRVec< complex< double > > &  b,
const bool  conj,
const complex< double > &  scale 
) const [inline]

computes the outer product of this complex vector $\vec{a}$ with given complex vector $\vec{b}$ and scales the resulting matrix with factor $\alpha$, i.e. the matrix elements of the final matrix $A$ can be expressed as

\[A_{i,j} = \alpha\cdot\vec{a}_i\vec{b}_j\]

in case conj = true, the result is

\[A_{i,j} = \alpha\cdot\vec{a}_i\vec{b}_j^{*}\]

Parameters:
[in] b complex vector $\vec{b}$
[in] conj determines whther the vector $\vec{b}$ is conjugated
[in] scale complex scaling factor $\alpha$

template<>
const NRMat< double > LA::NRVec< double >::otimes ( const NRVec< double > &  b,
const bool  conj,
const double &  scale 
) const [inline]

computes the outer product of this real vector $\vec{a}$ with given real vector $\vec{b}$ and scales the resulting matrix with factor $\alpha$, i.e. the matrix elements of the final matrix $A$ can be expressed as

\[A_{i,j} = \alpha\cdot\vec{a}_i\vec{b}_j\]

Parameters:
[in] b real vector $\vec{b}$
[in] conj not used
[in] scale real factor $\alpha$

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

routine for 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:
NRMat<T>::put()

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

fill the complex vector with pseudorandom numbers generated using uniform distribution the real and imaginary parts are generated independently

Parameters:
[in] x specification of the interval $[0,x]$ for the random number generator
Returns:
  • false current vector is bigger than vector rhs
  • true current vector is smaller than vector rhs

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

fill the real vector with pseudorandom numbers generated using uniform distribution

Parameters:
[in] x specification of the interval $[0,x]$ for the random number generator

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

resize the current vector

resizes this vector

Parameters:
[in] n requested size

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

determine the number of elements

determine the number of elements of this vector

Returns:
length of this vector

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

get normalized copy of this vector

create normalized copy of this vector

Returns:
copy of this vector after normalization
See also:
NRVec<T>::normalize()


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


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