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

(DO NOT USE) Smart-temporary Complex Double-precision Row Vector Class More...

#include <_zrovector.hpp>

List of all members.

Public Member Functions

 _zrovector ()
 _zrovector (const _zrovector &)
 ~_zrovector ()
comple & operator() (const long &) const
void write (const char *) const
void nullify () const
void destroy () const

Public Attributes

long l
 vector size
comple * array
 1D array to store vector data

Friends

std::ostream & operator<< (std::ostream &, const _zrovector &)
_zcovector t (const _zrovector &)
_zrovector conj (const _zrovector &)
_zcovector conjt (const _zrovector &)
double nrm2 (const _zrovector &)
long idamax (const _zrovector &)
comple damax (const _zrovector &)
const _zrovectoroperator+ (const _zrovector &)
_zrovector operator- (const _zrovector &)
_zrovector operator+ (const _zrovector &, const zrovector &)
_zrovector operator+ (const _zrovector &, const _zrovector &)
_zrovector operator- (const _zrovector &, const zrovector &)
_zrovector operator- (const _zrovector &, const _zrovector &)
comple operator* (const _zrovector &, const zcovector &)
comple operator* (const _zrovector &, const _zcovector &)
_zrovector operator* (const _zrovector &, const zgematrix &)
_zrovector operator* (const _zrovector &, const _zgematrix &)
_zrovector operator* (const _zrovector &, const zhematrix &)
_zrovector operator* (const _zrovector &, const _zhematrix &)
_zrovector operator* (const _zrovector &, const zgbmatrix &)
_zrovector operator* (const _zrovector &, const _zgbmatrix &)
_zrovector operator* (const _zrovector &, const zgsmatrix &)
_zrovector operator* (const _zrovector &, const _zgsmatrix &)
_zrovector operator* (const _zrovector &, const zhsmatrix &)
_zrovector operator* (const _zrovector &, const _zhsmatrix &)
_zrovector operator* (const _zrovector &, const double &)
_zrovector operator* (const _zrovector &, const comple &)
_zrovector operator/ (const _zrovector &, const double &)
_zrovector operator/ (const _zrovector &, const comple &)
comple operator% (const _zrovector &, const zrovector &)
comple operator% (const _zrovector &, const _zrovector &)
_zrovector operator* (const double &, const _zrovector &)
_zrovector operator* (const comple &, const _zrovector &)

Detailed Description

(DO NOT USE) Smart-temporary Complex Double-precision Row Vector Class

Definition at line 3 of file _zrovector.hpp.


Constructor & Destructor Documentation

_zrovector::_zrovector ( ) [inline]

zrovector constructor

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

References array, and l.

{VERBOSE_REPORT;
  //////// initialize ////////
  l =0;
  array =NULL;
}
_zrovector::_zrovector ( const _zrovector vec) [inline]

_zrovector copy constructor

Definition at line 12 of file _zrovector-constructor.hpp.

References array, l, and nullify().

{VERBOSE_REPORT;
  //////// initialize ////////
  l =vec.l;
  array =vec.array;
  
  vec.nullify();
}

_zrovector destructor

Definition at line 27 of file _zrovector-constructor.hpp.

References array.

{VERBOSE_REPORT;
  delete [] array;
}

Member Function Documentation

comple & _zrovector::operator() ( const long &  i) const [inline]

operator() for const object

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

References array, i(), and l.

Referenced by write().

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if( i<0 || l<=i ){
    ERROR_REPORT;
    std::cerr << "The required component is out of the vector size." << std::endl
              << "Your input was (" << i << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  return array[i];
}
void _zrovector::write ( const char *  filename) const [inline]

Definition at line 36 of file _zrovector-io.hpp.

References destroy(), i(), l, and operator()().

{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 << "#zrovector" << " " << l << std::endl;
  for(long i=0; i<l; i++){
    ofs << operator()(i) << " ";
  }
  ofs << std::endl;
  
  ofs.close();
  destroy();
}
void _zrovector::nullify ( ) const [inline]

nullify all the vector data

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

References array, and l.

Referenced by _zrovector(), zrovector::shallow_copy(), and zrovector::zrovector().

{VERBOSE_REPORT;
  l=0;
  array=NULL;
}
void _zrovector::destroy ( ) const [inline]

destroy all the vector data

Definition at line 11 of file _zrovector-misc.hpp.

References array.

Referenced by conjt(), damax(), idamax(), nrm2(), operator%(), operator*(), operator+(), zrovector::operator+=(), operator-(), zrovector::operator-=(), operator<<(), and write().

{VERBOSE_REPORT;
  delete [] array;
  array=NULL;
}

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  s,
const _zrovector vec 
) [friend]

Definition at line 22 of file _zrovector-io.hpp.

{VERBOSE_REPORT;
  for(long i=0; i<vec.l; i++){ s << " " << vec.array[i]; }
  s << std::endl;
  
  vec.destroy();
  return s;
}
_zcovector t ( const _zrovector rovec) [friend]

return a transposed column vector

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

{VERBOSE_REPORT;
  _zcovector covec;
  covec.l =rovec.l;
  delete [] covec.array;
  covec.array =rovec.array;
  
  return covec;
}
_zrovector conj ( const _zrovector vec) [friend]

return its conjugated vector

Definition at line 15 of file _zrovector-calc.hpp.

{VERBOSE_REPORT;
  for(long i=0; i<vec.l; i++){ vec(i) =std::conj(vec(i)); }
  return vec;
}
_zcovector conjt ( const _zrovector rovec) [friend]

return a conjugate transposed column vector

Definition at line 23 of file _zrovector-calc.hpp.

{VERBOSE_REPORT;
  zcovector covec(rovec.l);
  for(long i=0; i<rovec.l; i++){ covec(i) =std::conj(rovec(i)); }
  
  rovec.destroy();
  return _(covec);
}
double nrm2 ( const _zrovector vec) [friend]

return its Euclidean norm

Definition at line 38 of file _zrovector-calc.hpp.

{VERBOSE_REPORT;
  double val( dznrm2_(vec.l, vec.array, 1) );
  vec.destroy();
  return val;
}
long idamax ( const _zrovector vec) [friend]

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

Definition at line 48 of file _zrovector-calc.hpp.

{VERBOSE_REPORT;
  long i( izamax_(vec.l, vec.array, 1) -1 );
  vec.destroy();
  return i;
}
comple damax ( const _zrovector vec) [friend]

return its largest absolute value

Definition at line 57 of file _zrovector-calc.hpp.

{VERBOSE_REPORT;
  comple val( vec.array[izamax_(vec.l, vec.array, 1)-1] );
  vec.destroy();
  return val;
}
const _zrovector& operator+ ( const _zrovector vec) [friend]

+_zrovector operator

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

{VERBOSE_REPORT;
  return vec;
}
_zrovector operator- ( const _zrovector vec) [friend]

-_zrovector operator

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

{VERBOSE_REPORT;
  for(long i=0; i<vec.l; i++){ vec.array[i]=-vec.array[i]; }
  return vec;
}
_zrovector operator+ ( const _zrovector vecA,
const zrovector vecB 
) [friend]

_zrovector+zrovector operator

Definition at line 3 of file _zrovector-zrovector.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(vecA.l!=vecB.l){
    ERROR_REPORT;
    std::cerr << "These two vectors can not make a sumation." << std::endl
              << "Your input was (" << vecA.l << ") + (" << vecB.l << ")." << std::endl;
    exit(1);
  }
  
#endif//CPPL_DEBUG
  
  for(long i=0; i<vecA.l; i++){ vecA.array[i]+=vecB.array[i]; }
  
  return vecA;
}
_zrovector operator+ ( const _zrovector vecA,
const _zrovector vecB 
) [friend]

_zrovector+_zrovector operator

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

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(vecA.l!=vecB.l){
    ERROR_REPORT;
    std::cerr << "These two vectors can not make a sumation." << std::endl
              << "Your input was (" << vecA.l << ") + (" << vecB.l << ")." << std::endl;
    exit(1);
  }
  
#endif//CPPL_DEBUG
  
  for(long i=0; i<vecA.l; i++){ vecA.array[i]+=vecB.array[i]; }
  
  vecB.destroy();
  return vecA;
}
_zrovector operator- ( const _zrovector vecA,
const zrovector vecB 
) [friend]

zrovector-zrovector operator

Definition at line 22 of file _zrovector-zrovector.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(vecA.l!=vecB.l){
    ERROR_REPORT;
    std::cerr << "These two vectors can not make a subtraction." << std::endl
              << "Your input was (" << vecA.l << ") - (" << vecB.l << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  for(long i=0; i<vecA.l; i++){ vecA.array[i]-=vecB.array[i]; }
  
  return vecA;
}
_zrovector operator- ( const _zrovector vecA,
const _zrovector vecB 
) [friend]

_zrovector-_zrovector operator

Definition at line 23 of file _zrovector-_zrovector.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(vecA.l!=vecB.l){
    ERROR_REPORT;
    std::cerr << "These two vectors can not make a subtraction." << std::endl
              << "Your input was (" << vecA.l << ") - (" << vecB.l << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  for(long i=0; i<vecA.l; i++){ vecA.array[i]-=vecB.array[i]; }
  
  vecB.destroy();
  return vecA;
}
comple operator* ( const _zrovector rovec,
const zcovector covec 
) [friend]

_zrovector*zcovector operator

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

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(rovec.l!=covec.l){
    ERROR_REPORT;
    std::cerr << "These two vectors can not make a product." << std::endl
              << "Your input was (" << rovec.l << ") * (" << covec.l << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  comple val( zdotu_( rovec.l, rovec.array, 1, covec.array, 1 ) );
  
  rovec.destroy();
  return val;
}
comple operator* ( const _zrovector rovec,
const _zcovector covec 
) [friend]

_zrovector*_zcovector operator

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

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(rovec.l!=covec.l){
    ERROR_REPORT;
    std::cerr << "These two vectors can not make a product." << std::endl
              << "Your input was (" << rovec.l << ") * (" << covec.l << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  comple val( zdotu_( rovec.l, rovec.array, 1, covec.array, 1 ) );
  
  rovec.destroy();
  covec.destroy();
  return val;
}
_zrovector operator* ( const _zrovector vec,
const zgematrix mat 
) [friend]

_zrovector*zgematrix operator

Definition at line 3 of file _zrovector-zgematrix.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(vec.l!=mat.m){
    ERROR_REPORT;
    std::cerr << "These vector and matrix can not make a product." << std::endl
              << "Your input was (" << vec.l << ") * (" << mat.m << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zrovector newvec(mat.n);
  zgemv_( 'T', mat.m, mat.n, comple(1.0,0.0), mat.array, mat.m,
          vec.array, 1, comple(0.0,0.0), newvec.array, 1 );
  
  vec.destroy();
  return _(newvec);
}
_zrovector operator* ( const _zrovector vec,
const _zgematrix mat 
) [friend]

_zrovector*_zgematrix operator

Definition at line 3 of file _zrovector-_zgematrix.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(vec.l!=mat.m){
    ERROR_REPORT;
    std::cerr << "These vector and matrix can not make a product." << std::endl
              << "Your input was (" << vec.l << ") * (" << mat.m << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zrovector newvec(mat.n);
  zgemv_( 'T', mat.m, mat.n, comple(1.0,0.0), mat.array, mat.m,
          vec.array, 1, comple(0.0,0.0), newvec.array, 1 );
  
  vec.destroy();
  mat.destroy();
  return _(newvec);
}
_zrovector operator* ( const _zrovector vec,
const zhematrix mat 
) [friend]

_zrovector*zhematrix operator

Definition at line 3 of file _zrovector-zhematrix.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(vec.l!=mat.n){
    ERROR_REPORT;
    std::cerr << "These vector and matrix can not make a product." << std::endl
              << "Your input was (" << vec.l << ") * (" << mat.n << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zrovector newvec(mat.n);
  zhemv_( 'l', mat.n, comple(1.0,0.0), mat.array, mat.n,
          vec.array, 1, comple(0.0,0.0), newvec.array, 1 );

  vec.destroy();
  return _(newvec);
}
_zrovector operator* ( const _zrovector vec,
const _zhematrix mat 
) [friend]

_zrovector*_zhematrix operator

Definition at line 3 of file _zrovector-_zhematrix.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(vec.l!=mat.n){
    ERROR_REPORT;
    std::cerr << "These vector and matrix can not make a product." << std::endl
              << "Your input was (" << vec.l << ") * (" << mat.n << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zrovector newvec(mat.n);
  zhemv_( 'l', mat.n, comple(1.0,0.0), mat.array, mat.n,
          vec.array, 1, comple(0.0,0.0), newvec.array, 1 );
  
  vec.destroy();
  mat.destroy();
  return _(newvec);
}
_zrovector operator* ( const _zrovector vec,
const zgbmatrix mat 
) [friend]

_zrovector*zgbmatrix operator

Definition at line 3 of file _zrovector-zgbmatrix.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(vec.l!=mat.m){
    ERROR_REPORT;
    std::cerr << "These vector and matrix can not make a product." << std::endl
              << "Your input was (" << vec.l << ") * (" << mat.m << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zrovector newvec(mat.n);
  zgbmv_( 'T', mat.m, mat.n, mat.kl, mat.ku, comple(1.0,0.0),
          mat.array, mat.kl+mat.ku+1, vec.array, 1, comple(0.0,0.0), newvec.array, 1 );
  
  vec.destroy();
  return _(newvec);
}
_zrovector operator* ( const _zrovector vec,
const _zgbmatrix mat 
) [friend]

_zrovector*_zgbmatrix operator

Definition at line 3 of file _zrovector-_zgbmatrix.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(vec.l!=mat.m){
    ERROR_REPORT;
    std::cerr << "These vector and matrix can not make a product." << std::endl
              << "Your input was (" << vec.l << ") * (" << mat.m << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zrovector newvec(mat.n);
  zgbmv_( 'T', mat.m, mat.n, mat.kl, mat.ku, comple(1.0,0.0),
          mat.array, mat.kl+mat.ku+1, vec.array, 1, comple(0.0,0.0), newvec.array, 1 );
  
  vec.destroy();
  mat.destroy();
  return _(newvec);
}
_zrovector operator* ( const _zrovector vec,
const zgsmatrix mat 
) [friend]

_zrovector*zgsmatrix operator

Definition at line 3 of file _zrovector-zgsmatrix.hpp.

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

_zrovector*_zgsmatrix operator

Definition at line 3 of file _zrovector-_zgsmatrix.hpp.

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

_zrovector*zhsmatrix operator

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

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

_zrovector*_zhsmatrix operator

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

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

_zrovector*double operator

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

{VERBOSE_REPORT;
  zdscal_(vec.l, d, vec.array, 1);
  return vec;
}
_zrovector operator* ( const _zrovector vec,
const comple &  d 
) [friend]

_zrovector*comple operator

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

{VERBOSE_REPORT;
  zscal_(vec.l, d, vec.array, 1);  
  return vec;
}
_zrovector operator/ ( const _zrovector vec,
const double &  d 
) [friend]

_zrovector/double operator

Definition at line 11 of file _zrovector-double.hpp.

{VERBOSE_REPORT;
  zdscal_(vec.l, 1./d, vec.array, 1);
  return vec;
}
_zrovector operator/ ( const _zrovector vec,
const comple &  d 
) [friend]

_zrovector/comple operator

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

{VERBOSE_REPORT;
  zscal_(vec.l, 1./d, vec.array, 1);
  return vec;
}
comple operator% ( const _zrovector vecA,
const zrovector vecB 
) [friend]

zrovector^T*zrovector operator (inner product)

Definition at line 40 of file _zrovector-zrovector.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(vecA.l!=vecB.l){
    ERROR_REPORT;
    std::cerr << "These two vectors can not make a dot product." << std::endl
              << "Your input was (" << vecA.l << ") % (" << vecB.l << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  comple val( zdotu_( vecA.l, vecA.array, 1, vecB.array, 1 ) );
  
  vecA.destroy();
  return val;
}
comple operator% ( const _zrovector vecA,
const _zrovector vecB 
) [friend]

_zrovector^T*_zrovector operator (inner product)

Definition at line 42 of file _zrovector-_zrovector.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(vecA.l!=vecB.l){
    ERROR_REPORT;
    std::cerr << "These two vectors can not make a dot product." << std::endl
              << "Your input was (" << vecA.l << ") % (" << vecB.l << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  comple val( zdotu_( vecA.l, vecA.array, 1, vecB.array, 1 ) );
  
  vecA.destroy();
  vecB.destroy();
  return val;
}
_zrovector operator* ( const double &  d,
const _zrovector vec 
) [friend]

double*_zrovector operator

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

{VERBOSE_REPORT;
  zdscal_(vec.l, d, vec.array, 1);
  return vec;
}
_zrovector operator* ( const comple &  d,
const _zrovector vec 
) [friend]

comple*_zrovector operator

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

{VERBOSE_REPORT;
  zscal_(vec.l, d, vec.array, 1);  
  return vec;
}

Member Data Documentation

long _zrovector::l [mutable]
comple* _zrovector::array [mutable]

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