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

(DO NOT USE) Smart-temporary Real Double-precision Symmetric Sparse Matrix Class More...

#include <_dssmatrix.hpp>

List of all members.

Public Member Functions

 _dssmatrix ()
 _dssmatrix (const _dssmatrix &)
 ~_dssmatrix ()
_zhsmatrix to_zhsmatrix () const
_dgematrix to_dgematrix () const
_dsymatrix to_dsymatrix () const
_dgsmatrix to_dgsmatrix () const
double 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< dcomponentdata
 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 _dssmatrix &)
_dssmatrix t (const dssmatrix &)
void idamax (long &, long &, const dssmatrix &)
double damax (const dssmatrix &)
const _dssmatrixoperator+ (const _dssmatrix &)
_dssmatrix operator- (const _dssmatrix &)
_dgematrix operator+ (const _dssmatrix &, const dgematrix &)
_dgematrix operator+ (const _dssmatrix &, const _dgematrix &)
_dgematrix operator+ (const _dssmatrix &, const dsymatrix &)
_dgematrix operator+ (const _dssmatrix &, const _dsymatrix &)
_dgematrix operator+ (const _dssmatrix &, const dgbmatrix &)
_dgematrix operator+ (const _dssmatrix &, const _dgbmatrix &)
_dgsmatrix operator+ (const _dssmatrix &, const dgsmatrix &)
_dgsmatrix operator+ (const _dssmatrix &, const _dgsmatrix &)
_dssmatrix operator+ (const _dssmatrix &, const dssmatrix &)
_dssmatrix operator+ (const _dssmatrix &, const _dssmatrix &)
_dgematrix operator- (const _dssmatrix &, const dgematrix &)
_dgematrix operator- (const _dssmatrix &, const _dgematrix &)
_dgematrix operator- (const _dssmatrix &, const dsymatrix &)
_dgematrix operator- (const _dssmatrix &, const _dsymatrix &)
_dgematrix operator- (const _dssmatrix &, const dgbmatrix &)
_dgematrix operator- (const _dssmatrix &, const _dgbmatrix &)
_dgsmatrix operator- (const _dssmatrix &, const dgsmatrix &)
_dgsmatrix operator- (const _dssmatrix &, const _dgsmatrix &)
_dssmatrix operator- (const _dssmatrix &, const dssmatrix &)
_dssmatrix operator- (const _dssmatrix &, const _dssmatrix &)
_dgematrix operator* (const _dssmatrix &, const dgematrix &)
_dgematrix operator* (const _dssmatrix &, const _dgematrix &)
_dgematrix operator* (const _dssmatrix &, const dsymatrix &)
_dgematrix operator* (const _dssmatrix &, const _dsymatrix &)
_dgematrix operator* (const _dssmatrix &, const dgbmatrix &)
_dgematrix operator* (const _dssmatrix &, const _dgbmatrix &)
_dgematrix operator* (const _dssmatrix &, const dgsmatrix &)
_dgematrix operator* (const _dssmatrix &, const _dgsmatrix &)
_dssmatrix operator* (const _dssmatrix &, const dssmatrix &)
_dssmatrix operator* (const _dssmatrix &, const _dssmatrix &)
_dssmatrix operator* (const _dssmatrix &, const double &)
_dssmatrix operator/ (const _dssmatrix &, const double &)
_dssmatrix operator* (const double &, const _dssmatrix &)

Detailed Description

(DO NOT USE) Smart-temporary Real Double-precision Symmetric Sparse Matrix Class

Definition at line 3 of file _dssmatrix.hpp.


Constructor & Destructor Documentation

_dssmatrix::_dssmatrix ( ) [inline]

_dssmatrix constructor without arguments

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

References data, line, and n.

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

_dssmatrix copy constructor

Definition at line 13 of file _dssmatrix-constructor.hpp.

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

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

_dssmatrix destructor

Definition at line 29 of file _dssmatrix-constructor.hpp.

References data, and line.

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

Member Function Documentation

cast to _zhsmatrix

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

References _(), data, destroy(), n, and zhsmatrix::put().

{VERBOSE_REPORT;
  zhsmatrix newmat(n,data.size());
  for(std::vector<dcomponent>::const_iterator it=data.begin(); it!=data.end(); it++){
    newmat.put(it->i, it->j, comple(it->v,0.0));
  }
  
  destroy();
  return _(newmat);
}

convert to _dgematrix

Definition at line 20 of file _dssmatrix-cast.hpp.

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

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

convert to _dsymatrix

Definition at line 36 of file _dssmatrix-cast.hpp.

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

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

convert to _dgsmatrix

Definition at line 51 of file _dssmatrix-cast.hpp.

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

{VERBOSE_REPORT;
  dgsmatrix newmat(m,n,data.size()*2);
  newmat.zero();
  
  for(std::vector<dcomponent>::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, it->v);
    }
  }
  
  destroy();
  return _(newmat);
}
double _dssmatrix::operator() ( const long &  i,
const long &  j 
) const [inline]

operator() for const object

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

References 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>::iterator p=line[ii].begin(); p!=line[ii].end(); p++){
    if(data[*p].i==ii && data[*p].j==jj){ return data[*p].v; }
  }
  
  //// (i,j) component was not found ////
  return 0.0;
}
void _dssmatrix::write ( const char *  filename) const [inline]

Definition at line 62 of file _dssmatrix-io.hpp.

References data, and destroy().

{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 << "#dssmatrix" << std::endl;
  for(std::vector<dcomponent>::const_iterator it=data.begin(); it!=data.end(); it++){
    ofs << it->i << " " << it->j << " " << it->v << std::endl;
  }
  
  ofs.close();
  destroy();
}
void _dssmatrix::nullify ( ) const [inline]

nullify all the matrix data

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

References data, line, and n.

Referenced by _dssmatrix(), dssmatrix::dssmatrix(), and dssmatrix::shallow_copy().

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

destroy all the matrix data

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

References data, and line.

Referenced by damax(), idamax(), operator*(), operator+(), dssmatrix::operator+=(), operator-(), dssmatrix::operator-=(), operator<<(), to_dgematrix(), to_dgsmatrix(), to_dsymatrix(), to_zhsmatrix(), and write().

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

Friends And Related Function Documentation

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

Definition at line 29 of file _dssmatrix-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;
}
_dssmatrix t ( const dssmatrix mat) [friend]

return transposed dssmatrix

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

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  WARNING_REPORT;
  std::cerr << "This function call has no effect since the matrix is symmetric." << std::endl;
#endif//CPPL_DEBUG

  dssmatrix newmat(mat);
  return _(newmat);
}
void idamax ( long &  i,
long &  j,
const dssmatrix mat 
) [friend]

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

Definition at line 21 of file dssmatrix-calc.hpp.

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

return its largest absolute value

Definition at line 37 of file dssmatrix-calc.hpp.

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

+_dssmatrix operator

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

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

-_dssmatrix operator

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

{VERBOSE_REPORT;
  for(std::vector<dcomponent>::iterator it=mat.data.begin(); it!=mat.data.end(); it++){
    it->v =-it->v;
  }
  
  return mat;
}
_dgematrix operator+ ( const _dssmatrix ,
const dgematrix  
) [friend]
_dgematrix operator+ ( const _dssmatrix ,
const _dgematrix  
) [friend]
_dgematrix operator+ ( const _dssmatrix ,
const dsymatrix  
) [friend]
_dgematrix operator+ ( const _dssmatrix ,
const _dsymatrix  
) [friend]
_dgematrix operator+ ( const _dssmatrix ,
const dgbmatrix  
) [friend]
_dgematrix operator+ ( const _dssmatrix ,
const _dgbmatrix  
) [friend]
_dgsmatrix operator+ ( const _dssmatrix ,
const dgsmatrix  
) [friend]
_dgsmatrix operator+ ( const _dssmatrix ,
const _dgsmatrix  
) [friend]
_dssmatrix operator+ ( const _dssmatrix matA,
const dssmatrix matB 
) [friend]

_dssmatrix+dssmatrix operator

Definition at line 3 of file _dssmatrix-dssmatrix.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

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

_dssmatrix+_dssmatrix operator

Definition at line 3 of file _dssmatrix-_dssmatrix.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
  
  dssmatrix newmat(matA);
  
  for(std::vector<dcomponent>::const_iterator it=matB.data.begin(); it!=matB.data.end(); it++){
    newmat(it->i, it->j) +=it->v;
  }
  
  matB.destroy();
  return _(newmat);
}
_dgematrix operator- ( const _dssmatrix ,
const dgematrix  
) [friend]
_dgematrix operator- ( const _dssmatrix ,
const _dgematrix  
) [friend]
_dgematrix operator- ( const _dssmatrix ,
const dsymatrix  
) [friend]
_dgematrix operator- ( const _dssmatrix ,
const _dsymatrix  
) [friend]
_dgematrix operator- ( const _dssmatrix ,
const dgbmatrix  
) [friend]
_dgematrix operator- ( const _dssmatrix ,
const _dgbmatrix  
) [friend]
_dgsmatrix operator- ( const _dssmatrix ,
const dgsmatrix  
) [friend]
_dgsmatrix operator- ( const _dssmatrix ,
const _dgsmatrix  
) [friend]
_dssmatrix operator- ( const _dssmatrix matA,
const dssmatrix matB 
) [friend]

_dssmatrix-dssmatrix operator

Definition at line 25 of file _dssmatrix-dssmatrix.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

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

_dssmatrix-_dssmatrix operator

Definition at line 26 of file _dssmatrix-_dssmatrix.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
  
  dssmatrix newmat(matA);
  
  for(std::vector<dcomponent>::const_iterator it=matB.data.begin(); it!=matB.data.end(); it++){
    newmat(it->i, it->j) -=it->v;
  }
  
  matB.destroy();
  return _(newmat);
}
_dgematrix operator* ( const _dssmatrix ,
const dgematrix  
) [friend]
_dgematrix operator* ( const _dssmatrix ,
const _dgematrix  
) [friend]
_dgematrix operator* ( const _dssmatrix ,
const dsymatrix  
) [friend]
_dgematrix operator* ( const _dssmatrix ,
const _dsymatrix  
) [friend]
_dgematrix operator* ( const _dssmatrix ,
const dgbmatrix  
) [friend]
_dgematrix operator* ( const _dssmatrix ,
const _dgbmatrix  
) [friend]
_dgematrix operator* ( const _dssmatrix ,
const dgsmatrix  
) [friend]
_dgematrix operator* ( const _dssmatrix ,
const _dgsmatrix  
) [friend]
_dssmatrix operator* ( const _dssmatrix ,
const dssmatrix  
) [friend]
_dssmatrix operator* ( const _dssmatrix ,
const _dssmatrix  
) [friend]
_dssmatrix operator* ( const _dssmatrix mat,
const double &  d 
) [friend]

_dssmatrix*double operator

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

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

_dssmatrix/double operator

Definition at line 14 of file _dssmatrix-double.hpp.

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

double*_dssmatrix operator

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

{VERBOSE_REPORT;
  for(std::vector<dcomponent>::iterator it=mat.data.begin(); it!=mat.data.end(); it++){
    it->v *=d;
  }
  return mat;
}

Member Data Documentation

long const& _dssmatrix::m [mutable]

matrix row size

Definition at line 9 of file _dssmatrix.hpp.

Referenced by to_dgematrix(), and to_dgsmatrix().

long _dssmatrix::n [mutable]
std::vector<dcomponent> _dssmatrix::data [mutable]
std::vector< std::vector<uint32_t> > _dssmatrix::line [mutable]

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

Definition at line 12 of file _dssmatrix.hpp.

Referenced by _(), _dssmatrix(), destroy(), dssmatrix::dssmatrix(), nullify(), operator()(), operator<<(), dssmatrix::shallow_copy(), and ~_dssmatrix().


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