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

Complex Double-precision General Dence Matrix Class. More...

#include <zgematrix.hpp>

List of all members.

Public Member Functions

 zgematrix ()
 zgematrix (const zgematrix &)
 zgematrix (const _zgematrix &)
 zgematrix (const long &, const long &)
 zgematrix (const char *)
 ~zgematrix ()
comple & operator() (const long &, const long &)
comple operator() (const long &, const long &) const
zgematrixset (const long &, const long &, const comple &)
void write (const char *) const
void read (const char *)
void clear ()
zgematrixzero ()
zgematrixidentity ()
void chsign ()
void copy (const zgematrix &)
void shallow_copy (const _zgematrix &)
void resize (const long &, const long &)
_zrovector row (const long &) const
_zcovector col (const long &) const
long zgesv (zgematrix &)
long zgesv (zcovector &)
long zgels (zgematrix &)
long zgels (zcovector &)
long zgels (zgematrix &, drovector &)
long zgels (zcovector &, double &)
long zgelss (zcovector &, dcovector &, long &, const double)
long zgelss (zgematrix &, dcovector &, long &, const double)
long zgeev (std::vector< comple > &)
long zgeev (std::vector< comple > &, std::vector< zcovector > &)
long zgeev (std::vector< comple > &, std::vector< zrovector > &)
long zgesvd (dcovector &, zgematrix &, zgematrix &)
zgematrixoperator= (const zgematrix &)
zgematrixoperator= (const _zgematrix &)
zgematrixoperator+= (const zgematrix &)
zgematrixoperator+= (const _zgematrix &)
zgematrixoperator+= (const zhematrix &)
zgematrixoperator+= (const _zhematrix &)
zgematrixoperator+= (const zgbmatrix &)
zgematrixoperator+= (const _zgbmatrix &)
zgematrixoperator+= (const zgsmatrix &)
zgematrixoperator+= (const _zgsmatrix &)
zgematrixoperator+= (const zhsmatrix &)
zgematrixoperator+= (const _zhsmatrix &)
zgematrixoperator-= (const zgematrix &)
zgematrixoperator-= (const _zgematrix &)
zgematrixoperator-= (const zhematrix &)
zgematrixoperator-= (const _zhematrix &)
zgematrixoperator-= (const zgbmatrix &)
zgematrixoperator-= (const _zgbmatrix &)
zgematrixoperator-= (const zgsmatrix &)
zgematrixoperator-= (const _zgsmatrix &)
zgematrixoperator-= (const zhsmatrix &)
zgematrixoperator-= (const _zhsmatrix &)
zgematrixoperator*= (const zgematrix &)
zgematrixoperator*= (const _zgematrix &)
zgematrixoperator*= (const zhematrix &)
zgematrixoperator*= (const _zhematrix &)
zgematrixoperator*= (const zgbmatrix &)
zgematrixoperator*= (const _zgbmatrix &)
zgematrixoperator*= (const zgsmatrix &)
zgematrixoperator*= (const _zgsmatrix &)
zgematrixoperator*= (const zhsmatrix &)
zgematrixoperator*= (const _zhsmatrix &)
zgematrixoperator*= (const double &)
zgematrixoperator*= (const comple &)
zgematrixoperator/= (const double &)
zgematrixoperator/= (const comple &)

Public Attributes

long m
 matrix row size
long n
 matrix column size
comple * array
 1D array to store matrix data
comple ** darray
 array of pointers of column head addresses

Friends

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

Detailed Description

Complex Double-precision General Dence Matrix Class.

Definition at line 3 of file zgematrix.hpp.


Constructor & Destructor Documentation

zgematrix::zgematrix ( ) [inline]

zgematrix constructor without arguments

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

References array, darray, m, and n.

{VERBOSE_REPORT;
  //////// initialize ////////
  m =0;
  n =0;
  array =NULL;
  darray =NULL;
}
zgematrix::zgematrix ( const zgematrix mat) [inline]

zgematrix copy constructor

Definition at line 18 of file zgematrix-constructor.hpp.

References array, darray, i, m, and n.

{VERBOSE_REPORT;
  //////// initialize ////////
  m =mat.m;
  n =mat.n;
  array =new comple[m*n];
  darray =new comple*[n];
  for(int i=0; i<n; i++){ darray[i] =&array[i*m]; }

  //////// copy ////////
  zcopy_(m*n, mat.array, 1, array, 1);
}
zgematrix::zgematrix ( const _zgematrix mat) [inline]

zgematrix constructor to cast _zgematrix

Definition at line 33 of file zgematrix-constructor.hpp.

References array, _zgematrix::array, _zgematrix::darray, darray, m, _zgematrix::m, _zgematrix::n, n, and _zgematrix::nullify().

{VERBOSE_REPORT;
  m =mat.m;
  n =mat.n;
  array =mat.array;
  darray =mat.darray;
  
  mat.nullify();
}
zgematrix::zgematrix ( const long &  _m,
const long &  _n 
) [inline]

zgematrix constructor with size specification

Definition at line 49 of file zgematrix-constructor.hpp.

References array, darray, i, m, and n.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if( _m<0 || _n<0 ){
    ERROR_REPORT;
    std::cerr << "Matrix sizes must be positive integers. " << std::endl
              << "Your input was (" << _m << "," << _n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  //////// initialize ////////
  m =_m;
  n =_n;
  array =new comple[m*n];
  darray =new comple*[n];
  for(int i=0; i<n; i++){ darray[i] =&array[i*m]; }
}
zgematrix::zgematrix ( const char *  filename) [inline]

zgematrix constructor with filename

Definition at line 70 of file zgematrix-constructor.hpp.

References array, darray, and read().

{VERBOSE_REPORT;
  array =NULL;
  darray =NULL;
  
  //// read ////
  read(filename);
}
zgematrix::~zgematrix ( ) [inline]

zgematrix destructor

Definition at line 85 of file zgematrix-constructor.hpp.

References array, and darray.

{VERBOSE_REPORT;
  //////// delete array ////////
  delete [] array;
  delete [] darray;
}

Member Function Documentation

comple & zgematrix::operator() ( const long &  i,
const long &  j 
) [inline]

operator() for non-const object

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

References darray, i, m, and n.

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

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if( i<0 || j<0 || m<=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
  
  //return array[i+m*j];
  return darray[j][i];
}
comple zgematrix::operator() ( const long &  i,
const long &  j 
) const [inline]

operator() for const object

Definition at line 20 of file zgematrix-io.hpp.

References darray, i, m, and n.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if( i<0 || j<0 || m<=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
  
  //return array[i+m*j];
  return darray[j][i];
}
zgematrix & zgematrix::set ( const long &  i,
const long &  j,
const comple &  v 
) [inline]

set value for const object

Definition at line 41 of file zgematrix-io.hpp.

References darray, i, m, and n.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if( i<0 || j<0 || m<=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
  
  //array[i+m*j] =v;
  darray[j][i] =v;
  
  return *this;
}
void zgematrix::write ( const char *  filename) const [inline]

Definition at line 79 of file zgematrix-io.hpp.

References i, m, n, 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 << "#zgematrix" << " " << m << " " << n << std::endl;
  for(long i=0; i<m; i++){
    for(long j=0; j<n; j++ ){
      ofs << operator()(i,j) << " ";
    }
    ofs << std::endl;
  }
  
  ofs.close();
}
void zgematrix::read ( const char *  filename) [inline]

Definition at line 99 of file zgematrix-io.hpp.

References i, m, n, operator()(), and resize().

Referenced by zgematrix().

{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 != "zgematrix" && id != "#zgematrix" ){
    ERROR_REPORT;
    std::cerr << "The type name of the file \"" << filename << "\" is not zgematrix." << std::endl
              << "Its type name was " << id << " ." << std::endl;
    exit(1);
  }
  
  s >> m >> n;
  resize(m, n);
  for(long i=0; i<m; i++){
    for(long j=0; j<n; 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 not enough data components, or a linefeed code or space code is missing at the end of the last line." << std::endl;
    exit(1);
  }
  
  s >> id;
  if(!s.eof()){
    ERROR_REPORT;
    std::cerr << "There is something is wrong with the file \"" << filename << "\"." << std::endl
              << "Most likely, there are extra data components." << std::endl;
    exit(1);
  }
  
  
  s.close();
}
void zgematrix::clear ( ) [inline]

clear all the matrix data and set the sizes 0

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

References array, darray, m, and n.

Referenced by zgels(), and zgelss().

{VERBOSE_REPORT;
  m =0;
  n =0;
  delete [] array;
  array =NULL;
  delete [] darray;
  darray =NULL;
}
zgematrix & zgematrix::zero ( ) [inline]

change the matrix into a zero matrix

Definition at line 15 of file zgematrix-misc.hpp.

References array, i, m, and n.

Referenced by operator*(), operator*=(), and _zgsmatrix::to_zgematrix().

{VERBOSE_REPORT;
  for(long i=0; i<m*n; i++){
    array[i] =comple(0.0,0.0);
  }
  return *this;
}

change the matrix into an identity matrix

Definition at line 25 of file zgematrix-misc.hpp.

References array, i, m, n, and operator()().

Referenced by i().

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(m!=n){
    ERROR_REPORT;
    std::cerr << "Only square matrix can be a identity matrix." << std::endl
              << "The matrix size was " << m << "x" << n << "." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  for(long i=0; i<m*n; i++){ array[i] =comple(0.0,0.0); }
  for(long i=0; i<m; i++){ operator()(i,i) =comple(1.0,0.0); }
  
  return *this;
}
void zgematrix::chsign ( ) [inline]

change sign(+/-) of the matrix

Definition at line 44 of file zgematrix-misc.hpp.

References array, i, m, and n.

{VERBOSE_REPORT;
  for(long i=0; i<m*n; i++){ array[i] =-array[i]; }
}
void zgematrix::copy ( const zgematrix mat) [inline]

make a deep copy of the matrix

Definition at line 51 of file zgematrix-misc.hpp.

References array, darray, i, m, and n.

Referenced by operator=().

{VERBOSE_REPORT;
  m =mat.m;
  n =mat.n;
  delete [] array;
  array =new comple[m*n];
  delete [] darray;
  darray =new comple*[n];
  for(int i=0; i<n; i++){ darray[i] =&array[i*m]; }

  zcopy_(mat.m*mat.n, mat.array, 1, array, 1);
}
void zgematrix::shallow_copy ( const _zgematrix mat) [inline]

make a shallow copy of the matrix
This function is not designed to be used in project codes.

Definition at line 67 of file zgematrix-misc.hpp.

References array, _zgematrix::array, _zgematrix::darray, darray, m, _zgematrix::m, _zgematrix::n, n, and _zgematrix::nullify().

Referenced by operator=().

{VERBOSE_REPORT;
  m =mat.m;
  n =mat.n;
  delete [] array;
  array =mat.array;
  delete [] darray;
  darray =mat.darray;
  
  mat.nullify();
}
void zgematrix::resize ( const long &  _m,
const long &  _n 
) [inline]

resize the matrix

Definition at line 81 of file zgematrix-misc.hpp.

References array, darray, i, m, and n.

Referenced by read(), and zgesvd().

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if( _m<0 || _n<0 ){
    ERROR_REPORT;
    std::cerr << "Matrix sizes must be positive integers." << std::endl
              << "Your input was (" << _m << "," << _n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  m =_m;
  n =_n;
  delete [] array;
  array =new comple[m*n];
  delete [] darray;
  darray =new comple*[n];
  for(int i=0; i<n; i++){ darray[i] =&array[i*m]; }
}
_zrovector zgematrix::row ( const long &  _m) const [inline]

get row of the matrix

Definition at line 107 of file zgematrix-misc.hpp.

References _, m, and n.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if( _m<0 || _m>m ){
    ERROR_REPORT;
    std::cerr << "Input row number must be between 0 and " << m << "." << std::endl
              << "Your input was " << _m << "." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zrovector v(n);
  for(long j=0; j<n; j++){ v(j)=(*this)(_m,j); }
  return _(v);
}
_zcovector zgematrix::col ( const long &  _n) const [inline]

get column of the matrix

Definition at line 125 of file zgematrix-misc.hpp.

References _, i, m, and n.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if( _n<0 || _n>n ){
    ERROR_REPORT;
    std::cerr << "Input row number must be between 0 and " << n << "." << std::endl
              << "Your input was " << _n << "." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zcovector v(m);
  for(long i=0; i<m; i++){ v(i)=(*this)(i,_n); }
  return _(v);
}
long zgematrix::zgesv ( zgematrix mat) [inline]

solve A*X=Y using zgesv
The argument is zgematrix Y. Y is overwritten and become the solution X. A is also overwritten and become P*l*U.

Definition at line 5 of file zgematrix-lapack.hpp.

References array, m, and n.

Referenced by i().

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(m!=n || m!=mat.m){
    ERROR_REPORT;
    std::cerr << "These two matrices cannot be solved." << std::endl
              << "Your input was (" << m << "x" << n << ") and (" << mat.m << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG 
  
  long NRHS(mat.n), LDA(n), *IPIV(new long[n]), LDB(mat.m), INFO(1);
  zgesv_(n, NRHS, array, LDA, IPIV, mat.array, LDB, INFO);
  delete [] IPIV;
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long zgematrix::zgesv ( zcovector vec) [inline]

solve A*x=y using zgesv
The argument is zcovector y. y is overwritten and become the solution x. A is also overwritten and become P*l*U.

Definition at line 31 of file zgematrix-lapack.hpp.

References zcovector::array, array, zcovector::l, m, and n.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(m!=n || m!=vec.l){
    ERROR_REPORT;
    std::cerr << "These matrix and vector cannot be solved." << std::endl
              << "Your input was (" << m << "x" << n << ") and (" << vec.l << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG 
  long NRHS(1), LDA(n), *IPIV(new long[n]), LDB(vec.l), INFO(1);
  zgesv_(n, NRHS, array, LDA, IPIV, vec.array, LDB, INFO);
  delete [] IPIV;
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long zgematrix::zgels ( zgematrix mat) [inline]

solve overdetermined or underdetermined A*X=Y using zgels

Definition at line 58 of file zgematrix-lapack.hpp.

References array, clear(), i, m, n, and swap.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(m!=mat.m){
    ERROR_REPORT;
    std::cerr << "These two matrices cannot be solved." << std::endl
              << "Your input was (" << m << "x" << n << ") and (" << mat.m << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG    
  
  if(m<n){ //underdetermined
    zgematrix tmp(n,mat.n);
    for(long i=0; i<mat.m; i++){ for(long j=0; j<mat.n; j++){
      tmp(i,j) =mat(i,j);
    }}
    mat.clear();
    swap(mat,tmp);
  }
  
  char TRANS('n');
  long NRHS(mat.n), LDA(m), LDB(mat.m),
    LWORK(std::min(m,n)+std::max(std::min(m,n),NRHS)), INFO(1);
  comple *WORK(new comple[LWORK]);
  zgels_(TRANS, m, n, NRHS, array, LDA, mat.array, LDB, WORK, LWORK, INFO);
  delete [] WORK;
  
  if(m>n){ //overdetermined
    zgematrix tmp(n,mat.n);
    for(long i=0; i<tmp.m; i++){ for(long j=0; j<tmp.n; j++){
      tmp(i,j) =mat(i,j);
    }}
    mat.clear();
    swap(mat,tmp);
  }
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long zgematrix::zgels ( zcovector vec) [inline]

solve overdetermined or underdetermined A*x=y using zgels

Definition at line 103 of file zgematrix-lapack.hpp.

References zcovector::array, array, zcovector::clear(), i, zcovector::l, m, n, and swap.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(m!=vec.l){
    ERROR_REPORT;
    std::cerr << "These matrix and vector cannot be solved." << std::endl
              << "Your input was (" << m << "x" << n << ") and (" << vec.l << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG    
  
  if(m<n){ //underdetermined
    zcovector tmp(n);
    for(long i=0; i<vec.l; i++){ tmp(i)=vec(i); }
    vec.clear();
    swap(vec,tmp);
  }
  
  char TRANS('n');
  long NRHS(1), LDA(m), LDB(vec.l),
    LWORK(std::min(m,n)+std::max(std::min(m,n),NRHS)), INFO(1);
  comple *WORK(new comple[LWORK]);
  zgels_(TRANS, m, n, NRHS, array, LDA, vec.array, LDB, WORK, LWORK, INFO);
  delete [] WORK;
  
  if(m>n){ //overdetermined
    zcovector tmp(n);
    for(long i=0; i<tmp.l; i++){ tmp(i)=vec(i); }
    vec.clear();
    swap(vec,tmp);
  }
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long zgematrix::zgels ( zgematrix mat,
drovector residual 
) [inline]

solve overdetermined or underdetermined A*X=Y using zgels with the sum of residual squares output
The residual is set as the columnwise sum of residual squares for overdetermined problems while it is always zero for underdetermined problems.

Definition at line 149 of file zgematrix-lapack.hpp.

References array, clear(), i, drovector::l, m, n, drovector::resize(), swap, and drovector::zero().

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(m!=mat.m){
    ERROR_REPORT;
    std::cerr << "These two matrices cannot be solved." << std::endl
              << "Your input was (" << m << "x" << n << ") and (" << mat.m << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  residual.resize(mat.n); residual.zero();
  
  if(m<n){ //underdetermined
    zgematrix tmp(n,mat.n);
    for(long i=0; i<mat.m; i++){ for(long j=0; j<mat.n; j++){
      tmp(i,j) =mat(i,j);
    }}
    mat.clear();
    swap(mat,tmp);
  }
  
  char TRANS('n');
  long NRHS(mat.n), LDA(m), LDB(mat.m),
    LWORK(std::min(m,n)+std::max(std::min(m,n),NRHS)), INFO(1);
  comple *WORK(new comple[LWORK]);
  zgels_(TRANS, m, n, NRHS, array, LDA, mat.array, LDB, WORK, LWORK, INFO);
  delete [] WORK;
  
  if(m>n){ //overdetermined
    for(long i=0; i<residual.l; i++){ for(long j=0; j<m-n; j++){
      residual(i) += std::norm(mat(n+j,i));
    }}
    
    zgematrix tmp(n,mat.n);
    for(long i=0; i<tmp.m; i++){ for(long j=0; j<tmp.n; j++){
      tmp(i,j) =mat(i,j);
    }}
    mat.clear();
    swap(mat,tmp);
  }
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long zgematrix::zgels ( zcovector vec,
double &  residual 
) [inline]

solve overdetermined or underdetermined A*x=y using zgels with the sum of residual squares output
The residual is set as the sum of residual squares for overdetermined problems while it is always zero for underdetermined problems.

Definition at line 204 of file zgematrix-lapack.hpp.

References zcovector::array, array, zcovector::clear(), i, zcovector::l, m, n, and swap.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(m!=vec.l){
    ERROR_REPORT;
    std::cerr << "These matrix and vector cannot be solved." << std::endl
              << "Your input was (" << m << "x" << n << ") and (" << vec.l << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG    
  
  residual=0.0;
  
  if(m<n){ //underdetermined
    zcovector tmp(n);
    for(long i=0; i<vec.l; i++){ tmp(i)=vec(i); }
    vec.clear();
    swap(vec,tmp);
  }
  
  char TRANS('n');
  long NRHS(1), LDA(m), LDB(vec.l),
    LWORK(std::min(m,n)+std::max(std::min(m,n),NRHS)), INFO(1);
  comple *WORK(new comple[LWORK]);
  zgels_(TRANS, m, n, NRHS, array, LDA, vec.array, LDB, WORK, LWORK, INFO);
  delete [] WORK;
  
  if(m>n){ //overdetermined
    for(long i=0; i<m-n; i++){ residual+=std::norm(vec(n+i)); }
    
    zcovector tmp(n);
    for(long i=0; i<tmp.l; i++){ tmp(i)=vec(i); }
    vec.clear();
    swap(vec,tmp);
  }
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long zgematrix::zgelss ( zcovector B,
dcovector S,
long &  RANK,
const double  RCOND = -1. 
) [inline]

calculate the least-squares-least-norm solution for overdetermined or underdetermined A*x=y using zgelss

Definition at line 254 of file zgematrix-lapack.hpp.

References zcovector::array, array, dcovector::array, zcovector::clear(), i, zcovector::l, m, n, dcovector::resize(), and swap.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(m!=B.l){
    ERROR_REPORT;
    std::cerr << "These matrix and vector cannot be solved." << std::endl
              << "Your input was (" << m << "x" << n << ") and (" << B.l << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG    
  
  if(m<n){ //underdetermined
    zcovector tmp(n);
    for(long i=0; i<B.l; i++){ tmp(i)=B(i); }
    B.clear();
    swap(B,tmp);
  }
  
  S.resize(std::min(m,n));
  
  long NRHS(1), LDA(m), LDB(B.l),
    LWORK(2*std::min(m,n) +std::max(std::max(m,n),NRHS)), INFO(1);
  double *RWORK(new double[5*std::min(m,n)]);
  comple *WORK(new comple[LWORK]);
  zgelss_(m, n, NRHS, array, LDA, B.array, LDB, S.array, RCOND, RANK, 
          WORK, LWORK, RWORK, INFO);
  delete [] RWORK; delete [] WORK;
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long zgematrix::zgelss ( zgematrix B,
dcovector S,
long &  RANK,
const double  RCOND = -1. 
) [inline]

calculate the least-squares-least-norm solution for overdetermined or underdetermined A*x=y using zgelss

Definition at line 293 of file zgematrix-lapack.hpp.

References array, dcovector::array, clear(), i, m, n, dcovector::resize(), and swap.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(m!=B.m){
    ERROR_REPORT;
    std::cerr << "These matrix and vector cannot be solved." << std::endl
              << "Your input was (" << m << "x" << n << ") and (" << B.m << "x" << B.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG    
  
  if(m<n){ //underdetermined
    zgematrix tmp(n,B.n);
    for(long i=0; i<B.m; i++){
      for(long j=0; j<B.n; j++){
        tmp(i,j)=B(i,j);
      }
    }
    B.clear();
    swap(B,tmp);
  }
  
  S.resize(std::min(m,n));
  
  long NRHS(B.n), LDA(m), LDB(B.m),
    LWORK(2*std::min(m,n) +std::max(std::max(m,n),NRHS)), INFO(1);
  double *RWORK(new double[5*std::min(m,n)]);
  comple *WORK(new comple[LWORK]);
  zgelss_(m, n, NRHS, array, LDA, B.array, LDB, S.array, RCOND, RANK, 
          WORK, LWORK, RWORK, INFO);
  delete [] RWORK; delete [] WORK;
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long zgematrix::zgeev ( std::vector< comple > &  w) [inline]

calculate eigenvalues
The argument need not to be initialized. w is overwitten and become eigenvalues. This matrix is also overwritten.

Definition at line 342 of file zgematrix-lapack.hpp.

References array, m, and n.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(m!=n){
    ERROR_REPORT;
    std::cerr << "This matrix cannot have eigenvalues." << std::endl
              << "Your input was (" << m << "x" << n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  w.resize(n);
  char JOBVL('n'), JOBVR('n');
  long LDA(n), LDVL(1), LDVR(1), LWORK(4*n), INFO(1);
  double *RWORK(new double[2*n]);
  comple *VL(NULL), *VR(NULL), 
    *WORK(new comple[LWORK]);
  zgeev_(JOBVL, JOBVR, n, array, LDA, &w[0], 
         VL, LDVL, VR, LDVR, WORK, LWORK, RWORK, INFO);
  delete [] RWORK; delete [] WORK; delete [] VL; delete [] VR;
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long zgematrix::zgeev ( std::vector< comple > &  w,
std::vector< zcovector > &  vr 
) [inline]

calculate eigenvalues and right eigenvectors
All of the arguments need not to be initialized. w, vr are overwitten and become eigenvalues and right eigenvectors, respectively. This matrix is also overwritten.

Definition at line 376 of file zgematrix-lapack.hpp.

References array, i, m, and n.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(m!=n){
    ERROR_REPORT;
    std::cerr << "This matrix cannot have eigenvalues." << std::endl
              << "Your input was (" << m << "x" << n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  w.resize(n);  vr.resize(n);
  for(long i=0; i<n; i++){ vr[i].resize(n); }
  zgematrix VR(n,n);
  char JOBVL('n'), JOBVR('V');
  long LDA(n), LDVL(1), LDVR(n), LWORK(4*n), INFO(1);
  double *RWORK(new double[2*n]);
  comple *VL(NULL), *WORK(new comple[LWORK]);
  zgeev_(JOBVL, JOBVR, n, array, LDA, &w[0], 
         VL, LDVL, VR.array, LDVR, WORK, LWORK, RWORK, INFO);
  delete [] RWORK; delete [] WORK; delete [] VL;
  
  //// forming ////
  for(long j=0; j<n; j++){  for(long i=0; i<n; i++){
    vr[j](i) = VR(i,j);
  }}
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long zgematrix::zgeev ( std::vector< comple > &  w,
std::vector< zrovector > &  vl 
) [inline]

calculate eigenvalues and left eigenvectors
All of the arguments need not to be initialized. w, vr are overwitten and become eigenvalues and left eigenvectors, respectively. This matrix is also overwritten.

Definition at line 417 of file zgematrix-lapack.hpp.

References array, conj(), i, m, and n.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(m!=n){
    ERROR_REPORT;
    std::cerr << "This matrix cannot have eigenvalues." << std::endl
              << "Your input was (" << m << "x" << n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  w.resize(n);  vl.resize(n);
  for(long i=0; i<n; i++){ vl[i].resize(n); }
  zgematrix VL(n,n);
  char JOBVL('V'), JOBVR('n');
  long LDA(n), LDVL(n), LDVR(1), LWORK(4*n), INFO(1);
  double *RWORK(new double[2*n]);
  comple *VR(NULL), *WORK(new comple[LWORK]);
  zgeev_(JOBVL, JOBVR, n, array, LDA, &w[0], 
         VL.array, LDVL, VR, LDVR, WORK, LWORK, RWORK, INFO);
  delete [] RWORK; delete [] WORK; delete [] VR;
  
  //// forming ////
  for(long j=0; j<n; j++){ for(long i=0; i<n; i++){
    vl[j](i) = std::conj(VL(i,j));
  }}
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long zgematrix::zgesvd ( dcovector S,
zgematrix U,
zgematrix VT 
) [inline]

compute the singular value decomposition (SVD)
The arguments are zcocector S, zgematrix U and VT. All of them need not to be initialized. S, U and VT are overwitten and become singular values, left singular vectors, and right singular vectors respectively. This matrix also overwritten.

Definition at line 473 of file zgematrix-lapack.hpp.

References array, dcovector::array, m, n, resize(), and dcovector::resize().

{VERBOSE_REPORT;
  char JOBU('A'), JOBVT('A');
  long LDA(m), LDU(m), LDVT(n),
    LWORK(std::max(3*std::min(m,n)+std::max(m,n),5*std::min(m,n))), INFO(1);
  double *RWORK(new double[5*std::min(m,n)]);
  comple *WORK(new comple[LWORK]);
  S.resize(std::min(m,n)); U.resize(LDU,m); VT.resize(LDVT,n);
  
  zgesvd_(JOBU, JOBVT, m, n, array, LDA, S.array, U.array, 
          LDU, VT.array, LDVT, WORK, LWORK, RWORK, INFO);
  delete [] RWORK; delete [] WORK;
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
zgematrix & zgematrix::operator= ( const zgematrix mat) [inline]

zgematrix=zgematrix operator

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

References array, and copy().

{VERBOSE_REPORT;
  if(array!=mat.array){ // if it is NOT self substitution
    copy(mat);
  }
  return *this;
}
zgematrix & zgematrix::operator= ( const _zgematrix mat) [inline]

zgematrix=_zgematrix operator

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

References shallow_copy().

{VERBOSE_REPORT;
  shallow_copy(mat);
  return *this;
}
zgematrix & zgematrix::operator+= ( const zgematrix mat) [inline]

zgematrix+=zgematrix operator

Definition at line 17 of file zgematrix-zgematrix.hpp.

References array, i, m, and n.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(n!=mat.n || m!=mat.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a summation." << std::endl
              << "Your input was (" << m << "x" << n << ") += (" << mat.m << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  for(long i=0; i<m*n; i++){ array[i]+=mat.array[i]; }
  return *this;
}
zgematrix & zgematrix::operator+= ( const _zgematrix mat) [inline]

zgematrix+=_zgematrix operator

Definition at line 15 of file zgematrix-_zgematrix.hpp.

References array, _zgematrix::array, _zgematrix::destroy(), i, _zgematrix::m, m, n, and _zgematrix::n.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(n!=mat.n || m!=mat.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a summation." << std::endl
              << "Your input was (" << m << "x" << n << ") += (" << mat.m << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  for(long i=0; i<m*n; i++){ array[i]+=mat.array[i]; }
  
  mat.destroy();
  return *this;
}
zgematrix & zgematrix::operator+= ( const zhematrix mat) [inline]

zgematrix+=zhematrix operator

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

References i, m, n, zhematrix::n, and operator()().

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(n!=mat.n || m!=mat.n){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a summation." << std::endl
              << "Your input was (" << m << "x" << n << ") += (" << mat.n << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  for(long i=0; i<m; i++){ for( long j=0; j<n; j++){
    operator()(i,j) += mat(i,j);
  }}
  
  return *this;
}
zgematrix & zgematrix::operator+= ( const _zhematrix mat) [inline]

zgematrix+=_zhematrix operator

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

References _zhematrix::destroy(), i, m, _zhematrix::n, n, and operator()().

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(n!=mat.n || m!=mat.n){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a summation." << std::endl
              << "Your input was (" << m << "x" << n << ") += (" << mat.n << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  for(long i=0; i<m; i++){ for(long j=0; j<n; j++){
    operator()(i,j) +=mat(i,j);
  }}
  
  mat.destroy();
  return *this;
}
zgematrix & zgematrix::operator+= ( const zgbmatrix mat) [inline]

zgematrix+=zgbmatrix operator

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

References i, zgbmatrix::kl, zgbmatrix::ku, m, zgbmatrix::m, zgbmatrix::n, n, and operator()().

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(n!=mat.n || m!=mat.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a summation." << std::endl
              << "Your input was (" << m << "x" << n << ") += (" << mat.m << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  for(long i=0; i<mat.m; i++){
    for(long j=std::max(long(0),i-mat.kl); j<std::min(n,i+mat.ku+1); j++){
      operator()(i,j)+=mat(i,j);
    }
  }
  
  return *this;
}
zgematrix & zgematrix::operator+= ( const _zgbmatrix mat) [inline]

zgematrix+=_zgbmatrix operator

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

References _zgbmatrix::destroy(), i, _zgbmatrix::kl, _zgbmatrix::ku, m, _zgbmatrix::m, _zgbmatrix::n, n, and operator()().

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(n!=mat.n || m!=mat.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a summation." << std::endl
              << "Your input was (" << m << "x" << n << ") += (" << mat.m << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  for(long i=0; i<mat.m; i++){
    for(long j=std::max(long(0),i-mat.kl); j<std::min(n,i+mat.ku+1); j++){
      operator()(i,j)+=mat(i,j);
    }
  }
  
  mat.destroy();
  return *this;
}
zgematrix& zgematrix::operator+= ( const zgsmatrix ) [inline]
zgematrix& zgematrix::operator+= ( const _zgsmatrix ) [inline]
zgematrix& zgematrix::operator+= ( const zhsmatrix ) [inline]
zgematrix& zgematrix::operator+= ( const _zhsmatrix ) [inline]
zgematrix & zgematrix::operator-= ( const zgematrix mat) [inline]

zgematrix operator-=

Definition at line 34 of file zgematrix-zgematrix.hpp.

References array, i, m, and n.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(n!=mat.n || m!=mat.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a sutraction." << std::endl
              << "Your input was (" << m << "x" << n << ") -= (" << mat.m << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  for(long i=0; i<m*n; i++){ array[i]-=mat.array[i]; }
  return *this;
}
zgematrix & zgematrix::operator-= ( const _zgematrix mat) [inline]

zgematrix-=_zgematrix operator

Definition at line 34 of file zgematrix-_zgematrix.hpp.

References array, _zgematrix::array, _zgematrix::destroy(), i, _zgematrix::m, m, n, and _zgematrix::n.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(n!=mat.n || m!=mat.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a sutraction." << std::endl
              << "Your input was (" << m << "x" << n << ") -= (" << mat.m << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  for(long i=0; i<m*n; i++){ array[i]-=mat.array[i]; }

  mat.destroy();
  return *this;
}
zgematrix & zgematrix::operator-= ( const zhematrix mat) [inline]

zgematrix-=zhematrix operator

Definition at line 23 of file zgematrix-zhematrix.hpp.

References i, m, n, zhematrix::n, and operator()().

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(n!=mat.n || m!=mat.n){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a sutraction." << std::endl
              << "Your input was (" << m << "x" << n << ") -= (" << mat.n << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  for(long i=0; i<m; i++){ for(long j=0; j<n; j++){
    operator()(i,j) -= mat(i,j);
  }}
  
  return *this;
}
zgematrix & zgematrix::operator-= ( const _zhematrix mat) [inline]

zgematrix-=_zhematrix operator

Definition at line 24 of file zgematrix-_zhematrix.hpp.

References _zhematrix::destroy(), i, m, _zhematrix::n, n, and operator()().

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(n!=mat.n || m!=mat.n){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a sutraction." << std::endl
              << "Your input was (" << m << "x" << n << ") -= (" << mat.n << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  for(long i=0; i<m; i++){ for(long j=0; j<n; j++){
    operator()(i,j) -=mat(i,j);
  }}
  
  mat.destroy();
  return *this;
}
zgematrix & zgematrix::operator-= ( const zgbmatrix mat) [inline]

zgematrix-=zgbmatrix operator

Definition at line 25 of file zgematrix-zgbmatrix.hpp.

References i, zgbmatrix::kl, zgbmatrix::ku, m, zgbmatrix::m, zgbmatrix::n, n, and operator()().

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(n!=mat.n || m!=mat.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a subtraction." << std::endl
              << "Your input was (" << m << "x" << n << ") -= (" << mat.m << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  for(long i=0; i<mat.m; i++){
    for(long j=std::max(long(0),i-mat.kl); j<std::min(n,i+mat.ku+1); j++){
      operator()(i,j)-=mat(i,j);
    }
  }
  
  return *this;
}
zgematrix & zgematrix::operator-= ( const _zgbmatrix mat) [inline]

zgematrix-=_zgbmatrix operator

Definition at line 26 of file zgematrix-_zgbmatrix.hpp.

References _zgbmatrix::destroy(), i, _zgbmatrix::kl, _zgbmatrix::ku, m, _zgbmatrix::m, _zgbmatrix::n, n, and operator()().

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(n!=mat.n || m!=mat.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a subtraction." << std::endl
              << "Your input was (" << m << "x" << n << ") -= (" << mat.m << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  for(long i=0; i<mat.m; i++){
    for(long j=std::max(long(0),i-mat.kl); j<std::min(n,i+mat.ku+1); j++){
      operator()(i,j)-=mat(i,j);
    }
  }
  
  mat.destroy();
  return *this;
}
zgematrix& zgematrix::operator-= ( const zgsmatrix ) [inline]
zgematrix& zgematrix::operator-= ( const _zgsmatrix ) [inline]
zgematrix& zgematrix::operator-= ( const zhsmatrix ) [inline]
zgematrix& zgematrix::operator-= ( const _zhsmatrix ) [inline]
zgematrix & zgematrix::operator*= ( const zgematrix mat) [inline]

zgematrix operator*=

Definition at line 51 of file zgematrix-zgematrix.hpp.

References array, m, n, and swap.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(n!=mat.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a product." << std::endl
              << "Your input was (" << m << "x" << n << ") *= (" << mat.m << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zgematrix newmat( m, mat.n );
  zgemm_( 'n', 'n', m, mat.n, n, comple(1.0,0.0), array, m,
          mat.array, mat.m, comple(0.0,0.0), newmat.array, m );

  swap(*this,newmat);
  return *this;
}
zgematrix & zgematrix::operator*= ( const _zgematrix mat) [inline]

zgematrix*=_zgematrix operator

Definition at line 53 of file zgematrix-_zgematrix.hpp.

References array, _zgematrix::array, _zgematrix::destroy(), _zgematrix::m, m, _zgematrix::n, n, and swap.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(n!=mat.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a product." << std::endl
              << "Your input was (" << m << "x" << n << ") *= (" << mat.m << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zgematrix newmat( m, mat.n );
  zgemm_( 'n', 'n', m, mat.n, n, comple(1.0,0.0), array, m,
          mat.array, mat.m, comple(0.0,0.0), newmat.array, m );
  
  swap(*this,newmat);
  mat.destroy();
  return *this;
}
zgematrix & zgematrix::operator*= ( const zhematrix mat) [inline]

zgematrix*=zhematrix operator

Definition at line 43 of file zgematrix-zhematrix.hpp.

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

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(n!=mat.n){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a product." << std::endl
              << "Your input was (" << m << "x" << n << ") *= (" << mat.n << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zgematrix newmat( m, mat.n );
  
  zhemm_( 'R', 'l', mat.n, n, comple(1.0,0.0), mat.array, mat.n, 
          array, m, comple(0.0,0.0), newmat.array, newmat.m );
  
  swap(*this,newmat);
  return *this;
}
zgematrix & zgematrix::operator*= ( const _zhematrix mat) [inline]

zgematrix*=_zhematrix operator

Definition at line 45 of file zgematrix-_zhematrix.hpp.

References _zhematrix::array, array, _zhematrix::destroy(), m, _zhematrix::n, n, and swap.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(n!=mat.n){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a product." << std::endl
              << "Your input was (" << m << "x" << n << ") *= (" << mat.n << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zgematrix newmat( m, mat.n );
  
  zhemm_( 'R', 'l', mat.n, n, comple(1.0,0.0), mat.array, mat.n, 
          array, m, comple(0.0,0.0), newmat.array, newmat.m );
  
  swap(*this,newmat);
  mat.destroy();
  return *this;
}
zgematrix & zgematrix::operator*= ( const zgbmatrix mat) [inline]

zgematrix*=zgbmatrix operator

Definition at line 46 of file zgematrix-zgbmatrix.hpp.

References i, zgbmatrix::kl, zgbmatrix::ku, m, zgbmatrix::m, n, zgbmatrix::n, operator()(), swap, and zero().

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(n!=mat.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a product." << std::endl
              << "Your input was (" << m << "x" << n << ") *= (" << mat.m << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  zgematrix newmat(m,mat.n);
  newmat.zero();
  
  for(long i=0; i<newmat.m; i++){
    for(long j=0; j<newmat.n; j++){
      for(long k=std::max(long(0),j-mat.ku); k<std::min(mat.m,j+mat.kl+1); k++){
        newmat(i,j)+=operator()(i,k)*mat(k,j);
      }
    }
  }
  
  swap(*this,newmat);
  return *this;
}
zgematrix & zgematrix::operator*= ( const _zgbmatrix mat) [inline]

zgematrix*=_zgbmatrix operator

Definition at line 48 of file zgematrix-_zgbmatrix.hpp.

References _zgbmatrix::destroy(), i, _zgbmatrix::kl, _zgbmatrix::ku, m, _zgbmatrix::m, n, _zgbmatrix::n, operator()(), swap, and zero().

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(n!=mat.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a product." << std::endl
              << "Your input was (" << m << "x" << n << ") *= (" << mat.m << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zgematrix newmat(m,mat.n);
  newmat.zero();
  
  for(long i=0; i<newmat.m; i++){
    for(long j=0; j<newmat.n; j++){
      for(long k=std::max(long(0),j-mat.ku); k<std::min(mat.m,j+mat.kl+1); k++){
        newmat(i,j)+=operator()(i,k)*mat(k,j);
      }
    }
  }
  
  swap(*this,newmat);
  mat.destroy();
  return *this;
}
zgematrix& zgematrix::operator*= ( const zgsmatrix ) [inline]
zgematrix& zgematrix::operator*= ( const _zgsmatrix ) [inline]
zgematrix& zgematrix::operator*= ( const zhsmatrix ) [inline]
zgematrix& zgematrix::operator*= ( const _zhsmatrix ) [inline]
zgematrix & zgematrix::operator*= ( const double &  d) [inline]

zgematrix*=double operator

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

References array, m, and n.

{VERBOSE_REPORT;
  zdscal_(m*n, d, array, 1);
  return *this;
}
zgematrix & zgematrix::operator*= ( const comple &  d) [inline]

zgematrix*=comple operator

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

References array, m, and n.

{VERBOSE_REPORT;
  zscal_(m*n, d, array, 1);
  return *this;
}
zgematrix & zgematrix::operator/= ( const double &  d) [inline]

zgematrix/=double operator

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

References array, m, and n.

{VERBOSE_REPORT;
  zdscal_(m*n, 1./d, array, 1);
  return *this;
}
zgematrix & zgematrix::operator/= ( const comple &  d) [inline]

zgematrix/=comple operator

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

References array, m, and n.

{VERBOSE_REPORT;
  zscal_(m*n, 1./d, array, 1);
  return *this;
}

Friends And Related Function Documentation

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

Definition at line 63 of file zgematrix-io.hpp.

{VERBOSE_REPORT;
  for(long i=0; i<mat.m; i++){
    for(long j=0; j<mat.n; j++){
      s << " " << mat(i,j);
    }
    s << std::endl;
  }
  return s;
}
void swap ( zgematrix A,
zgematrix B 
) [friend]

swap two matrices

Definition at line 147 of file zgematrix-misc.hpp.

Referenced by operator*=(), zgels(), and zgelss().

{VERBOSE_REPORT;
  long A_m(A.m), A_n(A.n);
  comple* A_array(A.array);
  //comple** A_darray(A.darray);
  comple** A_darray=A.darray; //corruption to support VC++
  A.m=B.m; A.n=B.n; A.array=B.array; A.darray=B.darray;
  B.m=A_m; B.n=A_n; B.array=A_array; B.darray=A_darray;
}
_zgematrix _ ( zgematrix mat) [friend]

convert user object to smart-temporary object

Definition at line 159 of file zgematrix-misc.hpp.

Referenced by col(), and row().

{VERBOSE_REPORT;
  _zgematrix newmat;

  //////// shallow copy ////////
  newmat.m =mat.m;
  newmat.n =mat.n;
  newmat.array =mat.array;
  newmat.darray =mat.darray;
  
  //////// nullify ////////
  mat.m =0;
  mat.n =0;
  mat.array =NULL;
  mat.darray =NULL;

  return newmat;
}
_zgematrix t ( const zgematrix mat) [friend]

return transposed zgematrix

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

{VERBOSE_REPORT;
  zgematrix newmat(mat.n,mat.m);
  
  for(long i=0; i<newmat.m; i++){ for(long j=0; j<newmat.n; j++){
    newmat(i,j) =mat(j,i);
  }}
  
  return _(newmat);
}
_zgematrix i ( const zgematrix mat) [friend]

return its inverse matrix

Definition at line 16 of file zgematrix-calc.hpp.

Referenced by chsign(), col(), copy(), identity(), operator()(), operator*=(), operator+=(), operator-=(), read(), resize(), set(), write(), zero(), zgeev(), zgels(), zgelss(), and zgematrix().

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(mat.m!=mat.n){
    ERROR_REPORT;
    std::cerr << "This matrix is not square and has no inverse matrix." << std::endl
              << "Your input was (" << mat.m << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zgematrix mat_cp(mat), mat_inv(mat.m,mat.n);
  mat_inv.identity();
  mat_cp.zgesv(mat_inv);
  
  return _(mat_inv);
}
_zgematrix conj ( const zgematrix mat) [friend]

return its conjugate matrix

Definition at line 40 of file zgematrix-calc.hpp.

{VERBOSE_REPORT;
  zgematrix newmat(mat.m,mat.n);
  for(long i=0; i<mat.m; i++){ for(long j=0; j<mat.n; j++){
    newmat(i,j) =std::conj(mat(i,j));
  }}
  
  return _(newmat);
}
_zgematrix conjt ( const zgematrix mat) [friend]

return its conjugate transposed matrix

Definition at line 52 of file zgematrix-calc.hpp.

{VERBOSE_REPORT;
  zgematrix newmat(mat.n,mat.m);
  for(long i=0; i<newmat.m; i++){ for(long j=0; j<newmat.n; j++){
    newmat(i,j) =std::conj(mat(j,i));
  }}
  
  return _(newmat);
}
void idamax ( long &  i,
long &  j,
const zgematrix mat 
) [friend]

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

Definition at line 69 of file zgematrix-calc.hpp.

{VERBOSE_REPORT;
  long index( izamax_(mat.m*mat.n, mat.array, 1) -1 );
  i =index%mat.m;
  j =index/mat.m;
}
comple damax ( const zgematrix mat) [friend]

return its largest absolute value

Definition at line 78 of file zgematrix-calc.hpp.

{VERBOSE_REPORT;
  return mat.array[izamax_(mat.m*mat.n, mat.array, 1) -1];
}
const zgematrix& operator+ ( const zgematrix mat) [friend]

+zgematrix operator

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

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

-zgematrix operator

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

{VERBOSE_REPORT;
  zgematrix newmat(mat.m,mat.n);
  for(long i=0; i<newmat.m*newmat.n; i++){ newmat.array[i]=-mat.array[i]; }
  
  return _(newmat);
}
_zgematrix operator+ ( const zgematrix matA,
const zgematrix matB 
) [friend]

zgematrix+zgematrix operator

Definition at line 76 of file zgematrix-zgematrix.hpp.

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

  zgematrix newmat(matA.m,matA.n);
  for(long i=0; i<newmat.m*newmat.n; i++){
    newmat.array[i] =matA.array[i]+matB.array[i];
  }
  
  return _(newmat);
}
_zgematrix operator+ ( const zgematrix matA,
const _zgematrix matB 
) [friend]

zgematrix+_zgematrix operator

Definition at line 79 of file zgematrix-_zgematrix.hpp.

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

  for(long i=0; i<matA.m*matA.n; i++){ matB.array[i] +=matA.array[i]; }
  
  return matB;
}
_zgematrix operator+ ( const zgematrix matA,
const zhematrix matB 
) [friend]

zgematrix+zhematrix operator

Definition at line 69 of file zgematrix-zhematrix.hpp.

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

  zgematrix newmat(matA);
  for(long i=0; i<matA.m; i++){ for(long j=0; j<matA.n; j++){
    newmat(i,j) += matB(i,j);
  }}
  
  return _(newmat);
}
_zgematrix operator+ ( const zgematrix matA,
const _zhematrix matB 
) [friend]

zgematrix+_zhematrix operator

Definition at line 72 of file zgematrix-_zhematrix.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.n!=matB.n || matA.m!=matB.n){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a summation." << std::endl
              << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.n << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zgematrix newmat(matA);
  for(long i=0; i<matA.m; i++){ for(long j=0; j<matA.n; j++){
    newmat(i,j) +=matB(i,j);
  }}
  
  matB.destroy();
  return _(newmat);
}
_zgematrix operator+ ( const zgematrix matA,
const zgbmatrix matB 
) [friend]

zgematrix+zgbmatrix operator

Definition at line 77 of file zgematrix-zgbmatrix.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.n!=matB.n || matA.m!=matB.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a summation." << std::endl
              << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zgematrix newmat(matA);
  
  for(long i=0; i<matB.m; i++){
    for(long j=std::max(long(0),i-matB.kl); j<std::min(matB.n,i+matB.ku+1); j++){
      newmat(i,j)+=matB(i,j);
    }
  }
  
  return _(newmat);
}
_zgematrix operator+ ( const zgematrix matA,
const _zgbmatrix matB 
) [friend]

zgematrix+_zgbmatrix operator

Definition at line 81 of file zgematrix-_zgbmatrix.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.n!=matB.n || matA.m!=matB.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a summation." << std::endl
              << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zgematrix newmat(matA);
  
  for(long i=0; i<matB.m; i++){
    for(long j=std::max(long(0),i-matB.kl); j<std::min(matB.n,i+matB.ku+1); j++){
      newmat(i,j)+=matB(i,j);
    }
  }
  
  matB.destroy();
  return _(newmat);
}
_zgematrix operator+ ( const zgematrix matA,
const zgsmatrix matB 
) [friend]

zgematrix+zgsmatrix operator

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

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.m!=matB.m || matA.n!=matB.n){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a summation." << std::endl
              << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zgematrix newmat(matA);
  for(size_t c=0; c<matB.data.size(); c++){
    const zcomponent& z =matB.data[c];
    newmat(z.i,z.j) += z.v;
  }
  
  return _(newmat);
}
_zgematrix operator+ ( const zgematrix matA,
const _zgsmatrix matB 
) [friend]

zgematrix+_zgsmatrix operator

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

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.m!=matB.m || matA.n!=matB.n){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a summation." << std::endl
              << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zgematrix newmat(matA);
  for(size_t c=0; c<matB.data.size(); c++){
    const zcomponent& z =matB.data[c];
    newmat(z.i,z.j) += z.v;
  }
  
  matB.destroy();
  return _(newmat);
}
_zgematrix operator+ ( const zgematrix ,
const zhsmatrix  
) [friend]
_zgematrix operator+ ( const zgematrix ,
const _zhsmatrix  
) [friend]
_zgematrix operator- ( const zgematrix matA,
const zgematrix matB 
) [friend]

zgematrix-zgematrix operator

Definition at line 97 of file zgematrix-zgematrix.hpp.

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

  zgematrix newmat(matA.m,matA.n);
  for(long i=0; i<newmat.m*newmat.n; i++){
    newmat.array[i] =matA.array[i]-matB.array[i];
  }
  
  return _(newmat);
}
_zgematrix operator- ( const zgematrix matA,
const _zgematrix matB 
) [friend]

zgematrix-_zgematrix operator

Definition at line 97 of file zgematrix-_zgematrix.hpp.

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

  for(long i=0; i<matA.m*matA.n; i++){
    matB.array[i] =matA.array[i]-matB.array[i];
  }
  
  return matB;
}
_zgematrix operator- ( const zgematrix matA,
const zhematrix matB 
) [friend]

zgematrix-zhematrix operator

Definition at line 90 of file zgematrix-zhematrix.hpp.

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

  zgematrix newmat(matA);
  for(long i=0; i<matA.m; i++){ for(long j=0; j<matA.n; j++){
    newmat(i,j) -= matB(i,j);
  }}
  
  return _(newmat);
}
_zgematrix operator- ( const zgematrix matA,
const _zhematrix matB 
) [friend]

zgematrix-_zhematrix operator

Definition at line 94 of file zgematrix-_zhematrix.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.n!=matB.n || matA.m!=matB.n){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a subtraction." << std::endl
              << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zgematrix newmat(matA);
  for(long i=0; i<matA.m; i++){ for(long j=0; j<matA.n; j++){
    newmat(i,j) -=matB(i,j);
  }}
  
  matB.destroy();
  return _(newmat);
}
_zgematrix operator- ( const zgematrix matA,
const zgbmatrix matB 
) [friend]

zgematrix-zgbmatrix operator

Definition at line 101 of file zgematrix-zgbmatrix.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.n!=matB.n || matA.m!=matB.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a summation." << std::endl
              << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zgematrix newmat(matA);
  
  for(long i=0; i<matB.m; i++){
    for(long j=std::max(long(0),i-matB.kl); j<std::min(matB.n,i+matB.ku+1); j++){
      newmat(i,j)-=matB(i,j);
    }
  }
  
  return _(newmat);
}
_zgematrix operator- ( const zgematrix matA,
const _zgbmatrix matB 
) [friend]

zgematrix-_zgbmatrix operator

Definition at line 106 of file zgematrix-_zgbmatrix.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.n!=matB.n || matA.m!=matB.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a summation." << std::endl
              << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zgematrix newmat(matA);
  
  for(long i=0; i<matB.m; i++){
    for(long j=std::max(long(0),i-matB.kl); j<std::min(matB.n,i+matB.ku+1); j++){
      newmat(i,j)-=matB(i,j);
    }
  }
  
  matB.destroy();
  return _(newmat);
}
_zgematrix operator- ( const zgematrix matA,
const zgsmatrix matB 
) [friend]

zgematrix-zgsmatrix operator

Definition at line 25 of file zgematrix-zgsmatrix.hpp.

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

  zgematrix newmat(matA);
  for(size_t c=0; c<matB.data.size(); c++){
    const zcomponent& z =matB.data[c];
    newmat(z.i,z.j) -= z.v;
  }
  
  return _(newmat);
}
_zgematrix operator- ( const zgematrix matA,
const _zgsmatrix matB 
) [friend]

zgematrix-_zgsmatrix operator

Definition at line 26 of file zgematrix-_zgsmatrix.hpp.

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

  zgematrix newmat(matA);
  for(size_t c=0; c<matB.data.size(); c++){
    const zcomponent& z =matB.data[c];
    newmat(z.i,z.j) -= z.v;
  }
  
  matB.destroy();
  return _(newmat);
}
_zgematrix operator- ( const zgematrix ,
const zhsmatrix  
) [friend]
_zgematrix operator- ( const zgematrix ,
const _zhsmatrix  
) [friend]
_zcovector operator* ( const zgematrix mat,
const zcovector vec 
) [friend]

zgematrix*zcovector operator

Definition at line 3 of file zgematrix-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.m << "x" << mat.n << ") * (" << vec.l << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zcovector newvec(mat.m);
  zgemv_( 'n', mat.m, mat.n, comple(1.0,0.0), mat.array, mat.m,
          vec.array, 1, comple(0.0,0.0), newvec.array, 1 );
  
  return _(newvec);
}
_zcovector operator* ( const zgematrix mat,
const _zcovector vec 
) [friend]

zgematrix*_zcovector operator

Definition at line 3 of file zgematrix-_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.m << "x" << mat.n << ") * (" << vec.l << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zcovector newvec(mat.m);
  zgemv_( 'n', 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);
}
_zgematrix operator* ( const zgematrix matA,
const zgematrix matB 
) [friend]

zgematrix*zgematrix operator

Definition at line 118 of file zgematrix-zgematrix.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.n!=matB.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a product." << std::endl
              << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zgematrix newmat( matA.m, matB.n );
  zgemm_( 'n', 'n', matA.m, matB.n, matA.n, comple(1.0,0.0), 
          matA.array, matA.m, matB.array, matB.m, 
          comple(0.0,0.0), newmat.array, matA.m );
  
  return _(newmat);
}
_zgematrix operator* ( const zgematrix matA,
const _zgematrix matB 
) [friend]

zgematrix*_zgematrix operator

Definition at line 117 of file zgematrix-_zgematrix.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.n!=matB.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a product." << std::endl
              << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zgematrix newmat( matA.m, matB.n );
  zgemm_( 'n', 'n', matA.m, matB.n, matA.n, comple(1.0,0.0),
          matA.array, matA.m, matB.array, matB.m,
          comple(0.0,0.0), newmat.array, matA.m );
  
  matB.destroy();
  return _(newmat);
}
_zgematrix operator* ( const zgematrix matA,
const zhematrix matB 
) [friend]

zgematrix*zhematrix operator

Definition at line 111 of file zgematrix-zhematrix.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.n!=matB.n){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a product." << std::endl
              << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zgematrix newmat( matA.m, matA.n );
  zhemm_( 'R', 'l', newmat.m, newmat.n, comple(1.0,0.0), 
          matB.array, newmat.n, matA.array, newmat.m, 
          comple(0.0,0.0), newmat.array, newmat.m );
  
  return _(newmat);
}
_zgematrix operator* ( const zgematrix matA,
const _zhematrix matB 
) [friend]

zgematrix*_zhematrix operator

Definition at line 116 of file zgematrix-_zhematrix.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.n!=matB.n){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a product." << std::endl
              << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zgematrix newmat( matA.n, matB.n );
  
  zhemm_( 'R', 'l', matB.n, matA.n, comple(1.0,0.0), 
          matB.array, matB.n, matA.array, matA.m, 
          comple(0.0,0.0), newmat.array, newmat.m );
  
  matB.destroy();
  return _(newmat);
}
_zgematrix operator* ( const zgematrix matA,
const zgbmatrix matB 
) [friend]

zgematrix*zgbmatrix operator

Definition at line 125 of file zgematrix-zgbmatrix.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.n!=matB.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a product." << std::endl
              << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zgematrix newmat( matA.m, matB.n );
  newmat.zero();
  
  for(long i=0; i<newmat.m; i++){
    for(long j=0; j<newmat.n; j++){
      for(long k=std::max(long(0),j-matB.ku); k<std::min(matB.m,j+matB.kl+1); k++){
        newmat(i,j)+=matA(i,k)*matB(k,j);
      }
    }
  }
  
  return _(newmat);
}
_zgematrix operator* ( const zgematrix matA,
const _zgbmatrix matB 
) [friend]

zgematrix*_zgbmatrix operator

Definition at line 131 of file zgematrix-_zgbmatrix.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.n!=matB.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a product." << std::endl
              << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zgematrix newmat( matA.m, matB.n );
  newmat.zero();
  
  for(long i=0; i<newmat.m; i++){
    for(long j=0; j<newmat.n; j++){
      for(long k=std::max(long(0),j-matB.ku); k<std::min(matB.m,j+matB.kl+1); k++){
        newmat(i,j)+=matA(i,k)*matB(k,j);
      }
    }
  }
  
  matB.destroy();
  return _(newmat);
}
_zgematrix operator* ( const zgematrix matA,
const zgsmatrix matB 
) [friend]

zgematrix*zgsmatrix operator

Definition at line 47 of file zgematrix-zgsmatrix.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.n!=matB.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a product." << std::endl
              << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zgematrix newmat(matA.m, matB.n);
  newmat.zero();
  
  for(size_t c=0; c<matB.data.size(); c++){
    const zcomponent& z =matB.data[c];
    for(long i=0; i<matA.m; i++){
      newmat(i,z.j) += matA(i,z.i)*z.v;
    }
  }
  
  return _(newmat);
}
_zgematrix operator* ( const zgematrix matA,
const _zgsmatrix matB 
) [friend]

zgematrix*_zgsmatrix operator

Definition at line 49 of file zgematrix-_zgsmatrix.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.n!=matB.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a product." << std::endl
              << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zgematrix newmat(matA.m, matB.n);
  newmat.zero();
  
  for(size_t c=0; c<matB.data.size(); c++){
    const zcomponent& z =matB.data[c];
    for(long i=0; i<matA.m; i++){
      newmat(i,z.j) += matA(i,z.i)*z.v;
    }
  }
  
  matB.destroy();
  return _(newmat);
}
_zgematrix operator* ( const zgematrix ,
const zhsmatrix  
) [friend]
_zgematrix operator* ( const zgematrix ,
const _zhsmatrix  
) [friend]
_zgematrix operator* ( const zgematrix mat,
const double &  d 
) [friend]

zgematrix*double operator

Definition at line 23 of file zgematrix-double.hpp.

{VERBOSE_REPORT;
  zgematrix newmat(mat.m, mat.n);
  for(long i=0; i<mat.m*mat.n; i++){ newmat.array[i] =mat.array[i]*d; }
  
  return _(newmat);
}
_zgematrix operator* ( const zgematrix mat,
const comple &  d 
) [friend]

zgematrix*comple operator

Definition at line 23 of file zgematrix-complex.hpp.

{VERBOSE_REPORT;
  zgematrix newmat(mat.m, mat.n);
  for(long i=0; i<mat.m*mat.n; i++){ newmat.array[i] =mat.array[i]*d; }
  
  return _(newmat);
}
_zgematrix operator/ ( const zgematrix mat,
const double &  d 
) [friend]

zgematrix/double operator

Definition at line 33 of file zgematrix-double.hpp.

{VERBOSE_REPORT;
  zgematrix newmat(mat.m, mat.n);
  for(long i=0; i<mat.m*mat.n; i++){ newmat.array[i] =mat.array[i]/d; }
  
  return _(newmat);
}
_zgematrix operator/ ( const zgematrix mat,
const comple &  d 
) [friend]

zgematrix/comple operator

Definition at line 33 of file zgematrix-complex.hpp.

{VERBOSE_REPORT;
  zgematrix newmat(mat.m, mat.n);
  for(long i=0; i<mat.m*mat.n; i++){ newmat.array[i] =mat.array[i]/d; }
  
  return _(newmat);
}
_zgematrix operator* ( const double &  d,
const zgematrix mat 
) [friend]

double*zgematrix operator

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

{VERBOSE_REPORT;
  zgematrix newmat(mat.m, mat.n);
  for(long i=0; i<mat.m*mat.n; i++){ newmat.array[i] =d*mat.array[i]; }  
  return _(newmat);
}
_zgematrix operator* ( const comple &  d,
const zgematrix mat 
) [friend]

comple*zgematrix operator

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

{VERBOSE_REPORT;
  zgematrix newmat(mat.m, mat.n);
  for(long i=0; i<mat.m*mat.n; i++){ newmat.array[i] =d*mat.array[i]; }
  
  return _(newmat);
}

Member Data Documentation

array of pointers of column head addresses

Definition at line 12 of file zgematrix.hpp.

Referenced by _(), clear(), copy(), operator()(), resize(), set(), shallow_copy(), swap(), zgematrix(), and ~zgematrix().


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