CPPLapack
Public Member Functions | Public Attributes | Friends
_zhsmatrix Class Reference

(DO NOT USE) Smart-temporary Complex Double-precision Hermitian Sparse Matrix Class More...

#include <_zhsmatrix.hpp>

List of all members.

Public Member Functions

 _zhsmatrix ()
 _zhsmatrix (const _zhsmatrix &)
 ~_zhsmatrix ()
_zgematrix to_zgematrix () const
_zhematrix to_zhematrix () const
_zgsmatrix to_zgsmatrix () const
comple operator() (const long &, const long &) const
void write (const char *) const
void nullify () const
void destroy () const

Public Attributes

long const & m
 matrix row size
long n
 matrix column size
std::vector< zcomponentdata
 matrix data
std::vector< std::vector
< uint32_t > > 
line
 vector of vector to store the entry information of component for each row and column

Friends

std::ostream & operator<< (std::ostream &, const _zhsmatrix &)
_zhsmatrix t (const zhsmatrix &)
void idamax (long &, long &, const zhsmatrix &)
comple damax (const zhsmatrix &)
const _zhsmatrixoperator+ (const _zhsmatrix &)
_zhsmatrix operator- (const _zhsmatrix &)
_zgematrix operator+ (const _zhsmatrix &, const zgematrix &)
_zgematrix operator+ (const _zhsmatrix &, const _zgematrix &)
_zgematrix operator+ (const _zhsmatrix &, const zhematrix &)
_zgematrix operator+ (const _zhsmatrix &, const _zhematrix &)
_zgematrix operator+ (const _zhsmatrix &, const zgbmatrix &)
_zgematrix operator+ (const _zhsmatrix &, const _zgbmatrix &)
_zgsmatrix operator+ (const _zhsmatrix &, const zgsmatrix &)
_zgsmatrix operator+ (const _zhsmatrix &, const _zgsmatrix &)
_zhsmatrix operator+ (const _zhsmatrix &, const zhsmatrix &)
_zhsmatrix operator+ (const _zhsmatrix &, const _zhsmatrix &)
_zgematrix operator- (const _zhsmatrix &, const zgematrix &)
_zgematrix operator- (const _zhsmatrix &, const _zgematrix &)
_zgematrix operator- (const _zhsmatrix &, const zhematrix &)
_zgematrix operator- (const _zhsmatrix &, const _zhematrix &)
_zgematrix operator- (const _zhsmatrix &, const zgbmatrix &)
_zgematrix operator- (const _zhsmatrix &, const _zgbmatrix &)
_zgsmatrix operator- (const _zhsmatrix &, const zgsmatrix &)
_zgsmatrix operator- (const _zhsmatrix &, const _zgsmatrix &)
_zhsmatrix operator- (const _zhsmatrix &, const zhsmatrix &)
_zhsmatrix operator- (const _zhsmatrix &, const _zhsmatrix &)
_zcovector operator* (const _zhsmatrix &, const zcovector &)
_zcovector operator* (const _zhsmatrix &, const _zcovector &)
_zgematrix operator* (const _zhsmatrix &, const zgematrix &)
_zgematrix operator* (const _zhsmatrix &, const _zgematrix &)
_zgematrix operator* (const _zhsmatrix &, const zhematrix &)
_zgematrix operator* (const _zhsmatrix &, const _zhematrix &)
_zgematrix operator* (const _zhsmatrix &, const zgbmatrix &)
_zgematrix operator* (const _zhsmatrix &, const _zgbmatrix &)
_zgsmatrix operator* (const _zhsmatrix &, const zgsmatrix &)
_zgsmatrix operator* (const _zhsmatrix &, const _zgsmatrix &)
_zgsmatrix operator* (const _zhsmatrix &, const zhsmatrix &)
_zgsmatrix operator* (const _zhsmatrix &, const _zhsmatrix &)
_zhsmatrix operator* (const _zhsmatrix &, const double &)
_zgsmatrix operator* (const _zhsmatrix &, const comple &)
_zhsmatrix operator/ (const _zhsmatrix &, const double &)
_zgsmatrix operator/ (const _zhsmatrix &, const comple &)
_zhsmatrix operator* (const double &, const _zhsmatrix &)
_zgsmatrix operator* (const comple &, const _zhsmatrix &)

Detailed Description

(DO NOT USE) Smart-temporary Complex Double-precision Hermitian Sparse Matrix Class

Definition at line 3 of file _zhsmatrix.hpp.


Constructor & Destructor Documentation

_zhsmatrix::_zhsmatrix ( ) [inline]

_zhsmatrix constructor without arguments

Definition at line 3 of file _zhsmatrix-constructor.hpp.

References data, line, and n.

  :m(n)
{VERBOSE_REPORT;
  //////// initialize ////////
  n =0;
  data.clear();
  line.clear();
}
_zhsmatrix::_zhsmatrix ( const _zhsmatrix mat) [inline]

_zhsmatrix copy constructor

Definition at line 14 of file _zhsmatrix-constructor.hpp.

References data, line, n, and nullify().

  :m(n)
{VERBOSE_REPORT;
  //////// initialize ////////
  n =mat.n;
  data.swap(mat.data);
  line.swap(mat.line);
  
  mat.nullify();
}

_zhsmatrix destructor

Definition at line 31 of file _zhsmatrix-constructor.hpp.

References data, and line.

{VERBOSE_REPORT;
  data.clear();
  line.clear();
}

Member Function Documentation

convert to _zgematrix

Definition at line 3 of file _zhsmatrix-cast.hpp.

References _(), conj(), data, destroy(), m, and n.

{VERBOSE_REPORT;
  zgematrix newmat( zgematrix(m,n).zero() );
  
  for(std::vector<zcomponent>::const_iterator it=data.begin(); it!=data.end(); it++){
    newmat(it->i, it->j) =it->v;
    newmat(it->j, it->i) =std::conj(it->v);
  }
  
  destroy();
  return _(newmat);
}

convert to _zhematrix

Definition at line 18 of file _zhsmatrix-cast.hpp.

References _(), data, destroy(), n, and zhematrix::zero().

{VERBOSE_REPORT;
  zhematrix newmat(n);
  newmat.zero();

  for(std::vector<zcomponent>::const_iterator it=data.begin(); it!=data.end(); it++){
    newmat(it->i, it->j) =it->v;
  }

  destroy();
  return _(newmat);
}

convert to _zgsmatrix

Definition at line 33 of file _zhsmatrix-cast.hpp.

References _(), conj(), data, destroy(), m, n, zgsmatrix::put(), and zgsmatrix::zero().

Referenced by operator*(), and operator/().

{VERBOSE_REPORT;
  zgsmatrix newmat(m,n);
  newmat.zero();
  
  for(std::vector<zcomponent>::const_iterator it=data.begin(); it!=data.end(); it++){
    newmat.put(it->i, it->j, it->v);
    if(it->i!=it->j){
      newmat.put(it->j, it->i, std::conj(it->v));
    }
  }
  
  destroy();
  return _(newmat);
}
comple _zhsmatrix::operator() ( const long &  i,
const long &  j 
) const [inline]

operator() for const object

Definition at line 3 of file _zhsmatrix-io.hpp.

References conj(), data, line, and n.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if( i<0 || j<0 || n<=i || n<=j ){
    ERROR_REPORT;
    std::cerr << "The required component is out of the matrix size." << std::endl
              << "Your input was (" << i << "," << j << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  //// search (i,j) component ////
  const uint32_t ii(std::max(i,j)), jj(std::min(i,j));
  for(std::vector<uint32_t>::const_iterator p=line[ii].begin(); p!=line[ii].end(); p++){
    if(data[*p].j==jj){
      if( i>j ){ return data[*p].v; }//ii=i
      else{      return std::conj(data[*p].v); }//ii=j
    }
  }
  
  //// (i,j) component was not found ////
  return comple(0.0,0.0);
}
void _zhsmatrix::write ( const char *  filename) const [inline]

Definition at line 65 of file _zhsmatrix-io.hpp.

References data, destroy(), and n.

{VERBOSE_REPORT;
  std::ofstream ofs(filename, std::ios::trunc);
  ofs.setf(std::cout.flags());
  ofs.precision(std::cout.precision());
  ofs.width(std::cout.width());
  ofs.fill(std::cout.fill());
  
  ofs << "#zhsmatrix" << " " << n << std::endl;
  for(std::vector<zcomponent>::const_iterator it=data.begin(); it!=data.end(); it++){
    ofs << it->i << " " << it->j << " " << it->v << std::endl;
  }
  ofs.close();
  destroy();
}
void _zhsmatrix::nullify ( ) const [inline]

nullify all the matrix data

Definition at line 3 of file _zhsmatrix-misc.hpp.

References data, line, and n.

Referenced by _zhsmatrix(), zhsmatrix::shallow_copy(), and zhsmatrix::zhsmatrix().

{VERBOSE_REPORT;
  n=0;
  data.clear();
  line.clear();
}
void _zhsmatrix::destroy ( ) const [inline]

destroy all the matrix data

Definition at line 12 of file _zhsmatrix-misc.hpp.

References data, and line.

Referenced by damax(), idamax(), operator*(), operator+(), zhsmatrix::operator+=(), operator-(), zhsmatrix::operator-=(), operator<<(), to_zgematrix(), to_zgsmatrix(), to_zhematrix(), and write().

{VERBOSE_REPORT;
  data.clear();
  line.clear();
}

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  s,
const _zhsmatrix mat 
) [friend]

Definition at line 32 of file _zhsmatrix-io.hpp.

{VERBOSE_REPORT;
  for(long i=0; i<mat.n; i++){
    for(long j=0; j<mat.n; j++){
      if( i >= j ){
        std::vector<uint32_t>::iterator q;
        for(q=mat.line[i].begin(); q!=mat.line[i].end(); q++){
          if( long(mat.data[*q].j)==j ){ break; }
        }
        if(q!=mat.line[i].end()){ s << " " << mat.data[*q].v << " "; }
        else{ s << " x "; }
      }
      else{//i<j
        std::vector<uint32_t>::iterator q;
        for(q=mat.line[i].begin(); q!=mat.line[i].end(); q++){
          if( long(mat.data[*q].j)==j ){ break; }
        }
        if(q!=mat.line[i].end()){ s << "{" << mat.data[*q].v << "}"; }
        else{ s << "{x}"; }
      }
    }
    s << std::endl;
  }
  
  mat.destroy();
  return s;
}
_zhsmatrix t ( const zhsmatrix mat) [friend]

return transposed zhsmatrix

Definition at line 3 of file zhsmatrix-calc.hpp.

{VERBOSE_REPORT;
  zhsmatrix newmat(mat);
  
  for(std::vector<zcomponent>::iterator it=newmat.data.begin(); it!=newmat.data.end(); it++){
    it->v =std::conj(it->v);
  }
  
  return _(newmat);
}
void idamax ( long &  i,
long &  j,
const zhsmatrix mat 
) [friend]

search the index of element having the largest absolute value in 0-based numbering system

Definition at line 51 of file zhsmatrix-calc.hpp.

{VERBOSE_REPORT;
  std::vector<zcomponent>::const_iterator itx(mat.data.begin());
  double vmax =0.;
  for(std::vector<zcomponent>::const_iterator it=mat.data.begin(); it!=mat.data.end(); it++){
    if( vmax < norm(it->v) ){
      vmax =norm(it->v);
      itx =it;
    }
  }
  i =itx->i;
  j =itx->j;
}
comple damax ( const zhsmatrix mat) [friend]

return its largest absolute value

Definition at line 67 of file zhsmatrix-calc.hpp.

{VERBOSE_REPORT;
  std::vector<zcomponent>::const_iterator itx(mat.data.begin());
  double vmax =0.;
  for(std::vector<zcomponent>::const_iterator it=mat.data.begin(); it!=mat.data.end(); it++){
    if( vmax < norm(it->v) ){
      vmax =norm(it->v);
      itx =it;
    }
  }
  return itx->v;
}
const _zhsmatrix& operator+ ( const _zhsmatrix mat) [friend]

+_zhsmatrix operator

Definition at line 3 of file _zhsmatrix-unary.hpp.

{VERBOSE_REPORT;
  return mat;
}
_zhsmatrix operator- ( const _zhsmatrix mat) [friend]

-_zhsmatrix operator

Definition at line 10 of file _zhsmatrix-unary.hpp.

{VERBOSE_REPORT;
  for(std::vector<zcomponent>::iterator it=mat.data.begin(); it!=mat.data.end(); it++){
    it->v =-it->v;
  }
  
  return mat;
}
_zgematrix operator+ ( const _zhsmatrix ,
const zgematrix  
) [friend]
_zgematrix operator+ ( const _zhsmatrix ,
const _zgematrix  
) [friend]
_zgematrix operator+ ( const _zhsmatrix ,
const zhematrix  
) [friend]
_zgematrix operator+ ( const _zhsmatrix ,
const _zhematrix  
) [friend]
_zgematrix operator+ ( const _zhsmatrix ,
const zgbmatrix  
) [friend]
_zgematrix operator+ ( const _zhsmatrix ,
const _zgbmatrix  
) [friend]
_zgsmatrix operator+ ( const _zhsmatrix ,
const zgsmatrix  
) [friend]
_zgsmatrix operator+ ( const _zhsmatrix ,
const _zgsmatrix  
) [friend]
_zhsmatrix operator+ ( const _zhsmatrix matA,
const zhsmatrix matB 
) [friend]

_zhsmatrix+zhsmatrix operator

Definition at line 3 of file _zhsmatrix-zhsmatrix.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.n!=matB.n){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a summation." << std::endl
              << "Your input was (" << matA.n << "x" << matA.n << ") + (" << matB.n << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG

  zhsmatrix newmat(matA);
  
  for(std::vector<zcomponent>::const_iterator it=matB.data.begin(); it!=matB.data.end(); it++){
    newmat(it->i,it->j) +=it->v;
  }
  
  return _(newmat);
}
_zhsmatrix operator+ ( const _zhsmatrix matA,
const _zhsmatrix matB 
) [friend]

_zhsmatrix+_zhsmatrix operator

Definition at line 3 of file _zhsmatrix-_zhsmatrix.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.n!=matB.n){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a summation." << std::endl
              << "Your input was (" << matA.n << "x" << matA.n << ") + (" << matB.n << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zhsmatrix newmat(matA);
  
  for(std::vector<zcomponent>::const_iterator it=matB.data.begin(); it!=matB.data.end(); it++){
    newmat(it->i,it->j) +=it->v;
  }
  
  matB.destroy();
  return _(newmat);
}
_zgematrix operator- ( const _zhsmatrix ,
const zgematrix  
) [friend]
_zgematrix operator- ( const _zhsmatrix ,
const _zgematrix  
) [friend]
_zgematrix operator- ( const _zhsmatrix ,
const zhematrix  
) [friend]
_zgematrix operator- ( const _zhsmatrix ,
const _zhematrix  
) [friend]
_zgematrix operator- ( const _zhsmatrix ,
const zgbmatrix  
) [friend]
_zgematrix operator- ( const _zhsmatrix ,
const _zgbmatrix  
) [friend]
_zgsmatrix operator- ( const _zhsmatrix ,
const zgsmatrix  
) [friend]
_zgsmatrix operator- ( const _zhsmatrix ,
const _zgsmatrix  
) [friend]
_zhsmatrix operator- ( const _zhsmatrix matA,
const zhsmatrix matB 
) [friend]

_zhsmatrix-zhsmatrix operator

Definition at line 25 of file _zhsmatrix-zhsmatrix.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.n!=matB.n){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a subtraction." << std::endl
              << "Your input was (" << matA.n << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG

  zhsmatrix newmat(matA);
  
  for(std::vector<zcomponent>::const_iterator it=matB.data.begin(); it!=matB.data.end(); it++){
    newmat(it->i,it->j) -=it->v;
  }
  
  return _(newmat);
}
_zhsmatrix operator- ( const _zhsmatrix matA,
const _zhsmatrix matB 
) [friend]

_zhsmatrix-_zhsmatrix operator

Definition at line 26 of file _zhsmatrix-_zhsmatrix.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.n!=matB.n){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a subtraction." << std::endl
              << "Your input was (" << matA.n << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zhsmatrix newmat(matA);
  
  for(std::vector<zcomponent>::const_iterator it=matB.data.begin(); it!=matB.data.end(); it++){
    newmat(it->i,it->j) -=it->v;
  }
  
  matB.destroy();
  return _(newmat);
}
_zcovector operator* ( const _zhsmatrix mat,
const zcovector vec 
) [friend]

_zhsmatrix*zcovector operator

Definition at line 3 of file _zhsmatrix-zcovector.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(mat.n!=vec.l){
    ERROR_REPORT;
    std::cerr << "These matrix and vector can not make a product." << std::endl
              << "Your input was (" << mat.n << "x" << mat.n << ") * (" << vec.l << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zcovector newvec(mat.n);
  newvec.zero();
  
  for(std::vector<zcomponent>::const_iterator it=mat.data.begin(); it!=mat.data.end(); it++){
    newvec(it->i) +=it->v*vec(it->j);
    if(it->i!=it->j){
      newvec(it->j) +=std::conj(it->v)*vec(it->i);
    }
  }
  
  mat.destroy();
  return _(newvec);
}
_zcovector operator* ( const _zhsmatrix mat,
const _zcovector vec 
) [friend]

_zhsmatrix*_zcovector operator

Definition at line 3 of file _zhsmatrix-_zcovector.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(mat.n!=vec.l){
    ERROR_REPORT;
    std::cerr << "These matrix and vector can not make a product." << std::endl
              << "Your input was (" << mat.n << "x" << mat.n << ") * (" << vec.l << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zcovector newvec(mat.n);
  newvec.zero();
  
  for(std::vector<zcomponent>::const_iterator it=mat.data.begin(); it!=mat.data.end(); it++){
    newvec(it->i) +=it->v*vec(it->j);
    if(it->i!=it->j){
      newvec(it->j) +=std::conj(it->v)*vec(it->i);
    }
  }
  
  mat.destroy();
  vec.destroy();
  return _(newvec);
}
_zgematrix operator* ( const _zhsmatrix ,
const zgematrix  
) [friend]
_zgematrix operator* ( const _zhsmatrix ,
const _zgematrix  
) [friend]
_zgematrix operator* ( const _zhsmatrix ,
const zhematrix  
) [friend]
_zgematrix operator* ( const _zhsmatrix ,
const _zhematrix  
) [friend]
_zgematrix operator* ( const _zhsmatrix ,
const zgbmatrix  
) [friend]
_zgematrix operator* ( const _zhsmatrix ,
const _zgbmatrix  
) [friend]
_zgsmatrix operator* ( const _zhsmatrix ,
const zgsmatrix  
) [friend]
_zgsmatrix operator* ( const _zhsmatrix ,
const _zgsmatrix  
) [friend]
_zgsmatrix operator* ( const _zhsmatrix ,
const zhsmatrix  
) [friend]
_zgsmatrix operator* ( const _zhsmatrix ,
const _zhsmatrix  
) [friend]
_zhsmatrix operator* ( const _zhsmatrix mat,
const double &  d 
) [friend]

_zhsmatrix*double operator

Definition at line 3 of file _zhsmatrix-double.hpp.

{VERBOSE_REPORT;
  for(std::vector<zcomponent>::iterator it=mat.data.begin(); it!=mat.data.end(); it++){
    it->v *=d;
  }
  return mat;
}
_zgsmatrix operator* ( const _zhsmatrix mat,
const comple &  d 
) [friend]

_zhsmatrix*comple operator

Definition at line 3 of file _zhsmatrix-complex.hpp.

{VERBOSE_REPORT;
  zgsmatrix newmat( mat.to_zgsmatrix() );
  return newmat*d;
}
_zhsmatrix operator/ ( const _zhsmatrix mat,
const double &  d 
) [friend]

_zhsmatrix/double operator

Definition at line 13 of file _zhsmatrix-double.hpp.

{VERBOSE_REPORT;
  for(std::vector<zcomponent>::iterator it=mat.data.begin(); it!=mat.data.end(); it++){
    it->v /=d;
  }
  return mat;
}
_zgsmatrix operator/ ( const _zhsmatrix mat,
const comple &  d 
) [friend]

_zhsmatrix/comple operator

Definition at line 11 of file _zhsmatrix-complex.hpp.

{VERBOSE_REPORT;
  zgsmatrix newmat( mat.to_zgsmatrix() );
  return newmat/d;
}
_zhsmatrix operator* ( const double &  d,
const _zhsmatrix mat 
) [friend]

double*_zhsmatrix operator

Definition at line 3 of file double-_zhsmatrix.hpp.

{VERBOSE_REPORT;
  for(std::vector<zcomponent>::iterator it=mat.data.begin(); it!=mat.data.end(); it++){
    it->v *=d;
  }
  return mat;
}
_zgsmatrix operator* ( const comple &  d,
const _zhsmatrix mat 
) [friend]

complex*_zhsmatrix operator

Definition at line 3 of file complex-_zhsmatrix.hpp.

{VERBOSE_REPORT;
  zgsmatrix newmat( mat.to_zgsmatrix() );
  return d*newmat;
}

Member Data Documentation

long const& _zhsmatrix::m [mutable]

matrix row size

Definition at line 9 of file _zhsmatrix.hpp.

Referenced by operator*(), to_zgematrix(), and to_zgsmatrix().

long _zhsmatrix::n [mutable]
std::vector<zcomponent> _zhsmatrix::data [mutable]
std::vector< std::vector<uint32_t> > _zhsmatrix::line [mutable]

vector of vector to store the entry information of component for each row and column

Definition at line 12 of file _zhsmatrix.hpp.

Referenced by _(), _zhsmatrix(), destroy(), nullify(), operator()(), operator<<(), zhsmatrix::shallow_copy(), zhsmatrix::zhsmatrix(), and ~_zhsmatrix().


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Friends