CPPLapack
Public Member Functions | Public Attributes | Friends
zhematrix_small< n > Class Template Reference

Samll Complex Double-precision Symmetric Matrix Class. More...

#include <zhematrix_small.hpp>

List of all members.

Public Member Functions

 zhematrix_small ()
 zhematrix_small (const zhematrix &)
 zhematrix_small (const comple &)
 ~zhematrix_small ()
zgematrix_small< n, n > to_zgematrix_small () const
zhematrix to_zhematrix () const
comple & operator() (const long &i, const long &j)
comple operator() (const long &i, const long &j) const
zhematrix_small< n > & set (const long &, const long &, const comple &)
void read (const char *filename)
void write (const char *filename) const
zhematrix_small< n > & zero ()
zhematrix_small< n > & identity ()
template<long N>
zhematrix_small< N > & operator= (const zhematrix_small< N > &)

Public Attributes

comple array [(n *(n+1))/2]

Friends

template<long _n>
std::ostream & operator<< (std::ostream &, const zhematrix_small< _n > &)
template<long N>
zhematrix_small< N > & operator+= (zhematrix_small< N > &, const zhematrix_small< N > &)
template<long N>
zhematrix_small< N > & operator-= (zhematrix_small< N > &, const zhematrix_small< N > &)
template<long N>
zhematrix_small< N > & operator*= (zhematrix_small< N > &, const zhematrix_small< N > &)
template<long N>
zhematrix_small< N > & operator*= (zhematrix_small< N > &, const comple &)
template<long N>
zhematrix_small< N > & operator/= (zhematrix_small< N > &, const comple &)
template<long N>
const zhematrix_small< N > & operator+ (const zhematrix_small< N > &)
template<long N>
zhematrix_small< N > operator- (const zhematrix_small< N > &)
template<long N>
zgematrix_small< N, N > operator+ (const zhematrix_small< N > &, const zgematrix_small< N, N > &)
template<long N>
zhematrix_small< N > operator+ (const zhematrix_small< N > &, const zhematrix_small< N > &)
template<long N>
zgematrix_small< N, N > operator- (const zhematrix_small< N > &, const zgematrix_small< N, N > &)
template<long N>
zhematrix_small< N > operator- (const zhematrix_small< N > &, const zhematrix_small< N > &)
template<long N>
zcovector_small< N > operator* (const zhematrix_small< N > &, const zcovector_small< N > &)
template<long N>
zgematrix_small< N, N > operator* (const zhematrix_small< N > &, const zgematrix_small< N, N > &)
template<long N>
zgematrix_small< N, N > operator* (const zhematrix_small< N > &, const zhematrix_small< N > &)
template<long N>
zhematrix_small< N > operator* (const zhematrix_small< N > &, const comple &)
template<long N>
zhematrix_small< N > operator/ (const zhematrix_small< N > &, const comple &)
template<long N>
zhematrix_small< N > operator* (const comple &, const zhematrix_small< N > &)

Detailed Description

template<long n>
class zhematrix_small< n >

Samll Complex Double-precision Symmetric Matrix Class.

Definition at line 3 of file zhematrix_small.hpp.


Constructor & Destructor Documentation

template<long n>
zhematrix_small< n >::zhematrix_small ( ) [inline]

Definition at line 4 of file zhematrix_small-constructors.hpp.

{VERBOSE_REPORT;
  ;
}
template<long n>
zhematrix_small< n >::zhematrix_small ( const zhematrix mat) [inline, explicit]

Definition at line 12 of file zhematrix_small-constructors.hpp.

References zhematrix::array, zhematrix::m, and zhematrix::n.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if( n!=mat.n ){
    ERROR_REPORT;
    std::cerr << "Matrix sizes must be the same." << std::endl
              << "Your input was " << n << "x" << n << " and " << mat.m << "x" << mat.n << "." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  for(long k=0; k<(n*(n+1))/2; k++){
    array[k] =mat.array[k];;
  }
}
template<long n>
zhematrix_small< n >::zhematrix_small ( const comple &  x) [inline]

Definition at line 31 of file zhematrix_small-constructors.hpp.

{VERBOSE_REPORT;
  for(long k=0; k<(n*(n+1))/2; k++){
    array[k] =x;
  }
}
template<long n>
zhematrix_small< n >::~zhematrix_small ( ) [inline]

Definition at line 45 of file zhematrix_small-constructors.hpp.

{VERBOSE_REPORT;
  ;
}

Member Function Documentation

template<long n>
zgematrix_small< n, n > zhematrix_small< n >::to_zgematrix_small ( ) const [inline]

Definition at line 4 of file zhematrix_small-functions.hpp.

References i().

{VERBOSE_REPORT;
  zgematrix_small<n,n> newmat;
  for(long i=0; i<n; i++){
    for(long j=0;   j<=i; j++){ newmat(i,j) =(*this)(i,j); }
    for(long j=i+1; j<n;  j++){ newmat(i,j) =(*this)(j,i); }
  }
  return newmat;
}
template<long n>
zhematrix zhematrix_small< n >::to_zhematrix ( ) const [inline]

Definition at line 17 of file zhematrix_small-functions.hpp.

References i().

{VERBOSE_REPORT;
  zhematrix newmat(n);
  for(long i=0; i<n; i++){
    for(long j=0; j<=i; j++){
      newmat(i,j) =(*this)(i,j);
    }
  }
  return newmat;
}
template<long n>
comple & zhematrix_small< n >::operator() ( const long &  i,
const long &  j 
) [inline]

Definition at line 38 of file zhematrix_small-functions.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(i<j){
    ERROR_REPORT;
    std::cerr << "i<j" << std::endl;
    exit(1);
  }
#endif
  
  //const long I(max(i,j)), J(min(i,j)); return array[(I*(I+1))/2 +J];
  return array[(i*(i+1))/2 +j]; //l storage
}
template<long n>
comple zhematrix_small< n >::operator() ( const long &  i,
const long &  j 
) const [inline]

Definition at line 55 of file zhematrix_small-functions.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(i<j){
    ERROR_REPORT;
    std::cerr << "i<j" << std::endl;
    exit(1);
  }
#endif
  
  //const long I(max(i,j)), J(min(i,j)); return array[(I*(I+1))/2 +J];
  return array[(i*(i+1))/2 +j];
}
template<long n>
zhematrix_small< n > & zhematrix_small< n >::set ( const long &  i,
const long &  j,
const comple &  v 
) [inline]

Definition at line 72 of file zhematrix_small-functions.hpp.

References i().

{VERBOSE_REPORT;
  (*this)(i,j)=v;
  return *this;
}
template<long n>
void zhematrix_small< n >::read ( const char *  filename) [inline]

Definition at line 115 of file zhematrix_small-functions.hpp.

References i().

{VERBOSE_REPORT;
  std::ifstream s(filename);
  if(!s){
    ERROR_REPORT;
    std::cerr << "The file \"" << filename << "\" can not be opened." << std::endl;
    exit(1);
  }
  
  std::string id;
  s >> id;
  if( id != "zhematrix" && id != "#zhematrix" ){
    ERROR_REPORT;
    std::cerr << "The type name of the file \"" << filename << "\" is not zhematrix." << std::endl
              << "Its type name was " << id << " ." << std::endl;
    exit(1);
  }
  
  long _n;
  s >> _n;
  if(n!=_n){
    ERROR_REPORT;
    std::cerr << "Matrix size is invalid." << std::endl;
    exit(1);
  }
  
  for(long i=0; i<n; i++){
    for(long j=0; j<=i; j++ ){
      s >> operator()(i,j);
    }
  }
  if(s.eof()){
    ERROR_REPORT;
    std::cerr << "There is something is wrong with the file \"" << filename << "\"." << std::endl
              << "Most likely, there is a lack of data components, or a linefeed code or space code is missing at the end of the last line." << std::endl;
    exit(1);
  }
  
  s.close();
}
template<long n>
void zhematrix_small< n >::write ( const char *  filename) const [inline]

Definition at line 95 of file zhematrix_small-functions.hpp.

References i().

{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 << "#zhematrix" << " " << n << std::endl;
  for(long i=0; i<n; i++){
    for(long j=0; j<=i; j++){
      ofs << operator()(i,j) << " ";
    }
    ofs << std::endl;
  }
  ofs.close();
}
template<long n>
zhematrix_small< n > & zhematrix_small< n >::zero ( ) [inline]

Definition at line 166 of file zhematrix_small-functions.hpp.

References i().

{VERBOSE_REPORT;
  for(long i=0; i<n; i++){
    for(long j=0; j<=i; j++){
      (*this)(i,j) =0.;
    }
  }
  return *this;
}
template<long n>
zhematrix_small< n > & zhematrix_small< n >::identity ( ) [inline]

Definition at line 179 of file zhematrix_small-functions.hpp.

{VERBOSE_REPORT;
  zero();
  for(long k=0; k<n; k++){
    (*this)(k,k) =1.;
  }
  return *this;
}
template<long n>
template<long N>
zhematrix_small<N>& zhematrix_small< n >::operator= ( const zhematrix_small< N > &  ) [inline]

Friends And Related Function Documentation

template<long n>
template<long _n>
std::ostream& operator<< ( std::ostream &  ,
const zhematrix_small< _n > &   
) [friend]
template<long n>
template<long N>
zhematrix_small<N>& operator+= ( zhematrix_small< N > &  ,
const zhematrix_small< N > &   
) [friend]
template<long n>
template<long N>
zhematrix_small<N>& operator-= ( zhematrix_small< N > &  ,
const zhematrix_small< N > &   
) [friend]
template<long n>
template<long N>
zhematrix_small<N>& operator*= ( zhematrix_small< N > &  ,
const zhematrix_small< N > &   
) [friend]
template<long n>
template<long N>
zhematrix_small<N>& operator*= ( zhematrix_small< N > &  ,
const comple &   
) [friend]
template<long n>
template<long N>
zhematrix_small<N>& operator/= ( zhematrix_small< N > &  ,
const comple &   
) [friend]
template<long n>
template<long N>
const zhematrix_small<N>& operator+ ( const zhematrix_small< N > &  ) [friend]
template<long n>
template<long N>
zhematrix_small< N > operator- ( const zhematrix_small< N > &  ) [friend]
template<long n>
template<long N>
zgematrix_small<N,N> operator+ ( const zhematrix_small< N > &  ,
const zgematrix_small< N, N > &   
) [friend]
template<long n>
template<long N>
zhematrix_small< N > operator+ ( const zhematrix_small< N > &  ,
const zhematrix_small< N > &   
) [friend]
template<long n>
template<long N>
zgematrix_small<N,N> operator- ( const zhematrix_small< N > &  ,
const zgematrix_small< N, N > &   
) [friend]
template<long n>
template<long N>
zhematrix_small< N > operator- ( const zhematrix_small< N > &  ,
const zhematrix_small< N > &   
) [friend]
template<long n>
template<long N>
zcovector_small< N > operator* ( const zhematrix_small< N > &  ,
const zcovector_small< N > &   
) [friend]
template<long n>
template<long N>
zgematrix_small<N,N> operator* ( const zhematrix_small< N > &  ,
const zgematrix_small< N, N > &   
) [friend]
template<long n>
template<long N>
zgematrix_small<N,N> operator* ( const zhematrix_small< N > &  ,
const zhematrix_small< N > &   
) [friend]
template<long n>
template<long N>
zhematrix_small< N > operator* ( const zhematrix_small< N > &  ,
const comple &   
) [friend]
template<long n>
template<long N>
zhematrix_small< N > operator/ ( const zhematrix_small< N > &  ,
const comple &   
) [friend]
template<long n>
template<long N>
zhematrix_small< N > operator* ( const comple &  ,
const zhematrix_small< N > &   
) [friend]

Member Data Documentation

template<long n>
comple zhematrix_small< n >::array[(n *(n+1))/2]

Definition at line 9 of file zhematrix_small.hpp.

Referenced by operator*(), operator+=(), and operator-=().


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