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

Real Double-precision General Band Matrix Class. More...

#include <dgbmatrix.hpp>

List of all members.

Public Member Functions

 dgbmatrix ()
 dgbmatrix (const dgbmatrix &)
 dgbmatrix (const _dgbmatrix &)
 dgbmatrix (const long &, const long &, const long &, const long &)
 dgbmatrix (const char *)
 ~dgbmatrix ()
_zgbmatrix to_zgbmatrix () const
_dgematrix to_dgematrix () const
double & operator() (const long &, const long &)
double operator() (const long &, const long &) const
dgbmatrixset (const long &, const long &, const double &)
void write (const char *) const
void read (const char *)
void clear ()
dgbmatrixzero ()
dgbmatrixidentity ()
void chsign ()
void copy (const dgbmatrix &)
void shallow_copy (const _dgbmatrix &)
dgbmatrixresize (const long &, const long &, const long &, const long &)
_drovector row (const long &) const
_dcovector col (const long &) const
long dgbsv (dgematrix &)
long dgbsv (dcovector &)
dgbmatrixoperator= (const dgbmatrix &)
dgbmatrixoperator= (const _dgbmatrix &)
dgbmatrixoperator+= (const dgbmatrix &)
dgbmatrixoperator+= (const _dgbmatrix &)
dgbmatrixoperator-= (const dgbmatrix &)
dgbmatrixoperator-= (const _dgbmatrix &)
dgbmatrixoperator*= (const dgbmatrix &)
dgbmatrixoperator*= (const _dgbmatrix &)
dgbmatrixoperator*= (const double &)
dgbmatrixoperator/= (const double &)

Public Attributes

long m
 matrix row size
long n
 matrix column size
long kl
 lower band width
long ku
 upper band width
double * array
 1D array to store matrix data
double ** darray
 array of pointers of column head addresses

Friends

std::ostream & operator<< (std::ostream &, const dgbmatrix &)
void swap (dgbmatrix &, dgbmatrix &)
_dgbmatrix _ (dgbmatrix &)
_dgbmatrix t (const dgbmatrix &)
_dgematrix i (const dgbmatrix &)
const dgbmatrixoperator+ (const dgbmatrix &)
_dgbmatrix operator- (const dgbmatrix &)
_dgematrix operator+ (const dgbmatrix &, const dgematrix &)
_dgematrix operator+ (const dgbmatrix &, const _dgematrix &)
_dgematrix operator+ (const dgbmatrix &, const dsymatrix &)
_dgematrix operator+ (const dgbmatrix &, const _dsymatrix &)
_dgbmatrix operator+ (const dgbmatrix &, const dgbmatrix &)
_dgbmatrix operator+ (const dgbmatrix &, const _dgbmatrix &)
_dgematrix operator+ (const dgbmatrix &, const dgsmatrix &)
_dgematrix operator+ (const dgbmatrix &, const _dgsmatrix &)
_dgematrix operator+ (const dgbmatrix &, const dssmatrix &)
_dgematrix operator+ (const dgbmatrix &, const _dssmatrix &)
_dgematrix operator- (const dgbmatrix &, const dgematrix &)
_dgematrix operator- (const dgbmatrix &, const _dgematrix &)
_dgematrix operator- (const dgbmatrix &, const dsymatrix &)
_dgematrix operator- (const dgbmatrix &, const _dsymatrix &)
_dgbmatrix operator- (const dgbmatrix &, const dgbmatrix &)
_dgbmatrix operator- (const dgbmatrix &, const _dgbmatrix &)
_dgematrix operator- (const dgbmatrix &, const dgsmatrix &)
_dgematrix operator- (const dgbmatrix &, const _dgsmatrix &)
_dgematrix operator- (const dgbmatrix &, const dssmatrix &)
_dgematrix operator- (const dgbmatrix &, const _dssmatrix &)
_dcovector operator* (const dgbmatrix &, const dcovector &)
_dcovector operator* (const dgbmatrix &, const _dcovector &)
_dgematrix operator* (const dgbmatrix &, const dgematrix &)
_dgematrix operator* (const dgbmatrix &, const _dgematrix &)
_dgematrix operator* (const dgbmatrix &, const dsymatrix &)
_dgematrix operator* (const dgbmatrix &, const _dsymatrix &)
_dgbmatrix operator* (const dgbmatrix &, const dgbmatrix &)
_dgbmatrix operator* (const dgbmatrix &, const _dgbmatrix &)
_dgematrix operator* (const dgbmatrix &, const dgsmatrix &)
_dgematrix operator* (const dgbmatrix &, const _dgsmatrix &)
_dgematrix operator* (const dgbmatrix &, const dssmatrix &)
_dgematrix operator* (const dgbmatrix &, const _dssmatrix &)
_dgbmatrix operator* (const dgbmatrix &, const double &)
_dgbmatrix operator/ (const dgbmatrix &, const double &)
_dgbmatrix operator* (const double &, const dgbmatrix &)

Detailed Description

Real Double-precision General Band Matrix Class.

Definition at line 3 of file dgbmatrix.hpp.


Constructor & Destructor Documentation

dgbmatrix::dgbmatrix ( ) [inline]

dgbmatrix constructor

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

References array, darray, kl, ku, m, and n.

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

dgbmatrix copy constructor

Definition at line 16 of file dgbmatrix-constructor.hpp.

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

{VERBOSE_REPORT;
  //////// initialize ////////
  m =mat.m;
  n =mat.n;
  kl=mat.kl;
  ku=mat.ku;
  array =new double[(kl+ku+1)*n];
  darray =new double*[n];
  for(int i=0; i<n; i++){ darray[i] =&array[i*(kl+ku+1)]; }
  
  //////// copy ////////
  dcopy_((kl+ku+1)*n, mat.array, 1, array, 1);
}
dgbmatrix::dgbmatrix ( const _dgbmatrix mat) [inline]

dgbmatrix constructor to cast _dgbmatrix

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

References array, _dgbmatrix::array, darray, _dgbmatrix::darray, kl, _dgbmatrix::kl, _dgbmatrix::ku, ku, m, _dgbmatrix::m, _dgbmatrix::n, n, and _dgbmatrix::nullify().

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

dgbmatrix constructor with size specification

Definition at line 47 of file dgbmatrix-constructor.hpp.

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

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if( _m<0 || _n<0 || _kl<0 || _ku<0 || _m<_kl || _n<_ku ){
    ERROR_REPORT;
    std::cerr << "It is impossible to make a matrix you ordered. " << std::endl
              << "Your input was (" << _m << "," << _n << ","<< _ku << "," << _kl << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  //////// initialize ////////
  m =_m;
  n =_n;
  kl =_kl;
  ku =_ku;
  array =new double[(kl+ku+1)*n];
  darray =new double*[n];
  for(int i=0; i<n; i++){ darray[i] =&array[i*(kl+ku+1)]; }
}
dgbmatrix::dgbmatrix ( const char *  filename) [inline]

dgbmatrix constructor with filename

Definition at line 71 of file dgbmatrix-constructor.hpp.

References array, darray, and read().

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

dgbmatrix destructor

Definition at line 86 of file dgbmatrix-constructor.hpp.

References array, and darray.

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

Member Function Documentation

_zgbmatrix dgbmatrix::to_zgbmatrix ( ) const [inline]

cast to _zgbmatrix

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

References _, zgbmatrix::array, array, i, kl, ku, m, and n.

{VERBOSE_REPORT;
  zgbmatrix newmat(m,n,kl,ku);
  for(long i=0; i<(kl+ku+1)*n; i++){
    newmat.array[i] =comple(array[i],0.0);
  }
  
  return _(newmat);
}
_dgematrix dgbmatrix::to_dgematrix ( ) const [inline]

convert to _dgematrix

Definition at line 19 of file dgbmatrix-cast.hpp.

References _, i, kl, ku, m, n, and zero().

{VERBOSE_REPORT;
  dgematrix newmat( dgematrix(m,n).zero() );
  for(long i=0; i<m; i++){
    for(long j=std::max(long(0),i-kl); j<std::min(n,i+ku+1); j++){
      newmat(i,j) =(*this)(i,j);
    }
  }
  
  return _(newmat);
}
double & dgbmatrix::operator() ( const long &  i,
const long &  j 
) [inline]

operator() for non-const object

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

References darray, i, kl, ku, and m.

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

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

operator() for const object

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

References darray, i, kl, ku, and m.

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

set value for const object

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

References darray, i, kl, ku, and m.

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

Definition at line 80 of file dgbmatrix-io.hpp.

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

Definition at line 100 of file dgbmatrix-io.hpp.

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

Referenced by dgbmatrix().

{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 != "dgbmatrix" && id != "#dgbmatrix" ){
    ERROR_REPORT;
    std::cerr << "The type name of the file \"" << filename << "\" is not dgbmatrix." << std::endl
              << "Its type name was " << id << " ." << std::endl;
    exit(1);
  }
  
  s >> m >> n >> kl >> ku;
  resize(m, n, kl, ku);
  for(long i=0; i<m; i++){
    for(long j=std::max(long(0),i-kl); j<std::min(n,i+ku+1); 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 dgbmatrix::clear ( ) [inline]

clear all the matrix data and set the sizes 0

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

References array, darray, kl, ku, m, and n.

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

change the matrix into a zero matrix

Definition at line 18 of file dgbmatrix-misc.hpp.

References array, i, kl, ku, and n.

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

{VERBOSE_REPORT;
  for(long i=0; i<(kl+ku+1)*n; i++){ array[i] =0.0; }
  return *this;
}

change the matrix into an identity matrix

Definition at line 26 of file dgbmatrix-misc.hpp.

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

{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<(kl+ku+1)*n; i++){ array[i] =0.0; }
  for(long i=0; i<m; i++){ operator()(i,i) =1.0; }
  return *this;
}
void dgbmatrix::chsign ( ) [inline]

change sign(+/-) of the matrix

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

References array, i, kl, ku, and n.

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

make a deep copy of the matrix

Definition at line 50 of file dgbmatrix-misc.hpp.

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

Referenced by operator=().

{VERBOSE_REPORT;
  m =mat.m;
  n =mat.n;
  kl =mat.kl;
  ku =mat.ku;
  delete [] array;
  array =new double[(mat.kl+mat.ku+1)*mat.n];
  delete [] darray;
  darray =new double*[n];
  for(int i=0; i<n; i++){ darray[i] =&array[i*(kl+ku+1)]; }
  
  dcopy_((mat.kl+mat.ku+1)*mat.n, mat.array, 1, array, 1);
}
void dgbmatrix::shallow_copy ( const _dgbmatrix mat) [inline]

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

Definition at line 68 of file dgbmatrix-misc.hpp.

References array, _dgbmatrix::array, darray, _dgbmatrix::darray, kl, _dgbmatrix::kl, _dgbmatrix::ku, ku, m, _dgbmatrix::m, _dgbmatrix::n, n, and _dgbmatrix::nullify().

Referenced by operator=().

{VERBOSE_REPORT;
  m =mat.m;
  n =mat.n;
  kl =mat.kl;
  ku =mat.ku;
  delete [] array;
  array =mat.array;
  delete [] darray;
  darray =mat.darray;
  
  mat.nullify();
}
dgbmatrix & dgbmatrix::resize ( const long &  _m,
const long &  _n,
const long &  _kl,
const long &  _ku 
) [inline]

resize the matrix

Definition at line 84 of file dgbmatrix-misc.hpp.

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

Referenced by dgematrix::dgesvd(), and read().

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if( _m<0 || _n<0 || _kl<0 || _ku<0 || _m<_kl || _n<_ku ){
    ERROR_REPORT;
    std::cerr << "It is impossible to make a matrix you ordered. " << std::endl
              << "Your input was (" << _m << "," << _n << ","<< _ku << "," << _kl << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  m =_m;
  n =_n;
  kl =_kl;
  ku =_ku;
  delete [] array;
  array =new double[(kl+ku+1)*n];
  delete [] darray;
  darray =new double*[n];
  for(int i=0; i<n; i++){ darray[i] =&array[i*(kl+ku+1)]; }
  
  return *this;
}
_drovector dgbmatrix::row ( const long &  _m) const [inline]

get row of the matrix

Definition at line 115 of file dgbmatrix-misc.hpp.

References _, kl, ku, m, n, and zero().

{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
  
  drovector v( drovector(n).zero() );
  for(long j=std::max(long(0),_m-kl); j<std::min(n,_m+ku+1); j++){ v(j)=(*this)(_m,j); }
  return _(v);
}
_dcovector dgbmatrix::col ( const long &  _n) const [inline]

get column of the matrix

Definition at line 133 of file dgbmatrix-misc.hpp.

References _, i, kl, ku, m, n, and zero().

{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
  
  dcovector v( dcovector(m).zero() );
  for(long i=std::max(long(0),_n-ku); i<std::min(m,_n+kl+1); i++){ v(i)=(*this)(i,_n); }
  return _(v);
}
long dgbmatrix::dgbsv ( dgematrix mat) [inline]

solve A*X=Y using dgbsv
The argument is dgematrix Y. Y is overwritten and become the solution X. A is also overwritten.

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

References dgematrix::array, array, i, kl, ku, m, dgematrix::m, n, dgematrix::n, operator()(), and swap.

Referenced by i().

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(m!=n || n!=mat.m){
    ERROR_REPORT;
    std::cerr << "These matrix and vector cannot be solved." << std::endl
              << "Your input was (" << m << "x" << n << ") and (" << mat.m << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG 
  
  dgbmatrix newmat(m,n,kl,ku+kl);
  for(long i=0; i<m; i++){ for(long j=std::max(long(0),i-kl); j<std::min(n,i+ku+1); j++){
    newmat(i,j) =operator()(i,j);
  }}
  
  long NRHS(mat.n), LDAB(2*kl+ku+1),
    *IPIV(new long[n]), LDB(mat.m), INFO(1);
  dgbsv_(n, kl, ku, NRHS, newmat.array, LDAB, IPIV, mat.array, LDB, INFO);
  delete [] IPIV;
  
  swap(*this,newmat);
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long dgbmatrix::dgbsv ( dcovector vec) [inline]

solve A*x=y using dgbsv
The argument is dcovector y. y is overwritten and become the solution x. A is also overwritten.

Definition at line 39 of file dgbmatrix-lapack.hpp.

References dcovector::array, array, i, kl, ku, dcovector::l, m, n, operator()(), and swap.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(m!=n || n!=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 
  
  dgbmatrix newmat(m,n,kl,ku+kl);
  for(long i=0; i<m; i++){ for(long j=std::max(long(0),i-kl); j<std::min(n,i+ku+1); j++){
    newmat(i,j) =operator()(i,j);
  }}
  
  long NRHS(1), LDAB(2*kl+ku+1),
    *IPIV(new long[n]), LDB(vec.l), INFO(1);
  dgbsv_(n, kl, ku, NRHS, newmat.array, LDAB, IPIV, vec.array, LDB, INFO);
  delete [] IPIV;

  swap(*this,newmat);
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
dgbmatrix & dgbmatrix::operator= ( const dgbmatrix mat) [inline]

dgbmatrix=dgbmatrix operator
The left side matrix is overwritten thoroughly including band width.

Definition at line 4 of file dgbmatrix-dgbmatrix.hpp.

References array, and copy().

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

dgbmatrix=_dgbmatrix operator

Definition at line 3 of file dgbmatrix-_dgbmatrix.hpp.

References shallow_copy().

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

dgbmatrix+=dgbmatrix operator
If the band width of the left side matrix is narrower than the right side matrix, the band width of the left side matrix become thicker as same as the right side matrix.

Definition at line 19 of file dgbmatrix-dgbmatrix.hpp.

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

{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 <<","<< kl <<":"<< ku << ") "<< "+=" << "("<< mat.m <<"x"<< mat.n <<","<< mat.kl <<":"<< mat.ku <<") " << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  if(kl>=mat.kl && ku>=mat.ku){
    for(long i=0; i<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;
  }
  
  else{
    dgbmatrix newmat(m,n,std::max(kl,mat.kl),std::max(ku,mat.ku));
    newmat.zero();
    for(long i=0; i<m; i++){
      for(long j=std::max(long(0),i-kl); j<std::min(n,i+ku+1); j++){
        newmat(i,j)+=operator()(i,j);
      }
      for(long j=std::max(long(0),i-mat.kl); j<std::min(mat.n,i+mat.ku+1); j++){
        newmat(i,j)+=mat(i,j);
      }
    }
    
    swap(*this,newmat);
    return *this;
  }
}
dgbmatrix & dgbmatrix::operator+= ( const _dgbmatrix mat) [inline]

dgbmatrix+=_dgbmatrix operator
If the band width of the left side matrix is narrower than the right side matrix, the band width of the left side matrix become thicker as same as the right side matrix.

Definition at line 16 of file dgbmatrix-_dgbmatrix.hpp.

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

{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 <<","<< kl <<":"<< ku << ") "<< "+=" << "("<< mat.m <<"x"<< mat.n <<","<< mat.kl <<":"<< mat.ku <<") " << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  if(kl>=mat.kl && ku>=mat.ku){
    for(long i=0; i<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;
  }
  else{
    dgbmatrix newmat(m,n,std::max(kl,mat.kl),std::max(ku,mat.ku));
    newmat.zero();
    for(long i=0; i<m; i++){
      for(long j=std::max(long(0),i-kl); j<std::min(n,i+ku+1); j++){
        newmat(i,j)+=operator()(i,j);
      }
      for(long j=std::max(long(0),i-mat.kl); j<std::min(mat.n,i+mat.ku+1); j++){
        newmat(i,j)+=mat(i,j);
      }
    }
    
    swap(*this,newmat);
    mat.destroy();
    return *this;
  }
}
dgbmatrix & dgbmatrix::operator-= ( const dgbmatrix mat) [inline]

dgbmatrix-=dgbmatrix operator
If the band width of the left side matrix is narrower than the right side matrix, the band width of the left side matrix become thicker as same as the right side matrix.

Definition at line 60 of file dgbmatrix-dgbmatrix.hpp.

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

{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 <<","<< kl <<":"<< ku << ") "<< "-=" << "("<< mat.m <<"x"<< mat.n <<","<< mat.kl <<":"<< mat.ku <<") " << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  if(kl>=mat.kl && ku>=mat.ku){
    for(long i=0; i<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;
  }
  
  else{
    dgbmatrix newmat(m,n,std::max(kl,mat.kl),std::max(ku,mat.ku));
    newmat.zero();
    for(long i=0; i<m; i++){
      for(long j=std::max(long(0),i-kl); j<std::min(n,i+ku+1); j++){
        newmat(i,j)+=operator()(i,j);
      }
      for(long j=std::max(long(0),i-mat.kl); j<std::min(mat.n,i+mat.ku+1); j++){
        newmat(i,j)-=mat(i,j);
      }
    }
    
    swap(*this,newmat);
    return *this;
  }
}
dgbmatrix & dgbmatrix::operator-= ( const _dgbmatrix mat) [inline]

dgbmatrix-=_dgbmatrix operator
If the band width of the left side matrix is narrower than the right side matrix, the band width of the left side matrix become thicker as same as the right side matrix.

Definition at line 58 of file dgbmatrix-_dgbmatrix.hpp.

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

{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 <<","<< kl <<":"<< ku << ") "<< "-=" << "("<< mat.m <<"x"<< mat.n <<","<< mat.kl <<":"<< mat.ku <<") " << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  if(kl>=mat.kl && ku>=mat.ku){
    for(long i=0; i<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;
  }
  else{
    dgbmatrix newmat(m,n,std::max(kl,mat.kl),std::max(ku,mat.ku));
    newmat.zero();
    for(long i=0; i<m; i++){
      for(long j=std::max(long(0),i-kl); j<std::min(n,i+ku+1); j++){
        newmat(i,j)+=operator()(i,j);
      }
      for(long j=std::max(long(0),i-mat.kl); j<std::min(mat.n,i+mat.ku+1); j++){
        newmat(i,j)-=mat(i,j);
      }
    }
    
    swap(*this,newmat);
    mat.destroy();
    return *this;
  }
}
dgbmatrix & dgbmatrix::operator*= ( const dgbmatrix mat) [inline]

dgbmatrix*=dgbmatrix operator

Definition at line 100 of file dgbmatrix-dgbmatrix.hpp.

References i, kl, ku, m, 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
  
  dgbmatrix newmat( m, mat.n, std::min(kl+mat.kl, m-1), std::min(ku+mat.ku, mat.n-1) );
  newmat.zero();
  
  for(long i=0; i<newmat.m; i++){
    for(long j=std::max(long(0),i-newmat.kl); j<std::min(newmat.n,i+newmat.ku+1); j++){
      for(long k=std::max( std::max(long(0),i-kl), std::max(long(0),j-mat.ku) );
          k< std::min( std::min(n,i+ku+1), std::min(mat.m,j+mat.kl+1) ); k++){
        newmat(i,j)+= operator()(i,k)*mat(k,j);
      }
    }
  }
  
  swap(*this,newmat);
  return *this;
}
dgbmatrix & dgbmatrix::operator*= ( const _dgbmatrix mat) [inline]

dgbmatrix*=_dgbmatrix operator

Definition at line 99 of file dgbmatrix-_dgbmatrix.hpp.

References _dgbmatrix::destroy(), i, kl, _dgbmatrix::kl, _dgbmatrix::ku, ku, _dgbmatrix::m, m, _dgbmatrix::n, 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
  
  dgbmatrix newmat( m, mat.n, std::min(kl+mat.kl, m-1), std::min(ku+mat.ku, mat.n-1) );
  newmat.zero();
  
  for(long i=0; i<newmat.m; i++){
    for(long j=std::max(long(0),i-newmat.kl); j<std::min(newmat.n,i+newmat.ku+1); j++){
      for(long k=std::max( std::max(long(0),i-kl), std::max(long(0),j-mat.ku) );
          k< std::min( std::min(n,i+ku+1), 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;
}
dgbmatrix & dgbmatrix::operator*= ( const double &  d) [inline]

dgbmatrix*=double operator

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

References array, kl, ku, and n.

{VERBOSE_REPORT;
  dscal_((kl+ku+1)*n, d, array, 1);
  return *this;
}
dgbmatrix & dgbmatrix::operator/= ( const double &  d) [inline]

dgbmatrix/=double operator

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

References array, kl, ku, and n.

{VERBOSE_REPORT;
  dscal_((kl+ku+1)*n, 1./d, array, 1);
  return *this;
}

Friends And Related Function Documentation

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

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

{VERBOSE_REPORT;
  for(long i=0; i<mat.m; i++){
    for(long j=0; j<mat.n; j++){
      if( i-j>mat.kl || j-i>mat.ku ){ s << " x"; }
      else{ s << " " << mat(i,j); }
    }
    s << std::endl;
  }
  
  return s;
}
void swap ( dgbmatrix A,
dgbmatrix B 
) [friend]

swap two matrices

Definition at line 155 of file dgbmatrix-misc.hpp.

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

{VERBOSE_REPORT;
  long A_m =A.m, A_n =A.n, A_kl =A.kl, A_ku =A.ku;
  double* A_array =A.array;
  double** A_darray=A.darray;
  A.m=B.m; A.n=B.n; A.kl=B.kl; A.ku=B.ku; A.array=B.array; A.darray=B.darray;
  B.m=A_m; B.n=A_n; B.kl=A_kl; B.ku=A_ku; B.array=A_array; B.darray=A_darray;
}
_dgbmatrix _ ( dgbmatrix mat) [friend]

convert user object to smart-temporary object

Definition at line 166 of file dgbmatrix-misc.hpp.

Referenced by col(), row(), to_dgematrix(), and to_zgbmatrix().

{VERBOSE_REPORT;
  _dgbmatrix newmat;
  
  //////// shallow copy ////////
  newmat.m =mat.m;
  newmat.n =mat.n;
  newmat.kl =mat.kl;
  newmat.ku =mat.ku;
  newmat.array =mat.array;
  newmat.darray =mat.darray;
  
  //////// nullify ////////
  mat.m =0;
  mat.n =0;
  mat.kl =0;
  mat.ku =0;
  mat.array =NULL;
  mat.darray =NULL;
  
  return newmat;
}
_dgbmatrix t ( const dgbmatrix mat) [friend]

return transposed dgbmatrix

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

{VERBOSE_REPORT;
  dgbmatrix newmat(mat.n, mat.m, mat.ku, mat.kl);
  for(long i=0; i<newmat.m; i++){
    for(long j=std::max(long(0),i-newmat.kl); j<std::min(newmat.n,i+newmat.ku+1); j++){
      newmat(i,j) =mat(j,i);
    }
  }
  
  return _(newmat);
}
_dgematrix i ( const dgbmatrix mat) [friend]

return its inverse matrix

Definition at line 17 of file dgbmatrix-calc.hpp.

Referenced by chsign(), col(), copy(), dgbmatrix(), dgbsv(), identity(), operator()(), operator*=(), operator+=(), operator-=(), read(), resize(), set(), to_dgematrix(), to_zgbmatrix(), write(), and zero().

{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
  
  dgbmatrix mat_cp(mat);
  dgematrix mat_inv(mat.m,mat.n);
  mat_inv.identity();
  mat_cp.dgbsv(mat_inv);
  
  return _(mat_inv);
}
const dgbmatrix& operator+ ( const dgbmatrix mat) [friend]

+dgbmatrix operator

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

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

-dgbmatrix operator

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

{VERBOSE_REPORT;
  dgbmatrix newmat(mat.m,mat.n,mat.kl,mat.ku);
  for(long i=0; i<(newmat.kl+newmat.ku+1)*newmat.n; i++){
    newmat.array[i]=-mat.array[i];
  }
  
  return _(newmat);
}
_dgematrix operator+ ( const dgbmatrix matA,
const dgematrix matB 
) [friend]

dgbmatrix+dgematrix operator

Definition at line 3 of file dgbmatrix-dgematrix.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

  dgematrix newmat(matB);
  for(long i=0; i<matA.m; i++){
    for(long j=std::max(long(0),i-matA.kl); j<std::min(matA.n,i+matA.ku+1); j++){
      newmat(i,j)+=matA(i,j);
    }
  }
  
  return _(newmat);
}
_dgematrix operator+ ( const dgbmatrix matA,
const _dgematrix matB 
) [friend]

dgbmatrix+_dgematrix operator

Definition at line 3 of file dgbmatrix-_dgematrix.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; i++){
    for(long j=std::max(long(0),i-matA.kl); j<std::min(matA.n,i+matA.ku+1); j++){
      matB(i,j)+=matA(i,j);
    }
  }
  
  return matB;
}
_dgematrix operator+ ( const dgbmatrix matA,
const dsymatrix matB 
) [friend]

dgbmatrix+dsymatrix operator

Definition at line 3 of file dgbmatrix-dsymatrix.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
  
  dgematrix newmat(matB.n,matB.n);
  for(long i=0; i<matA.m; i++){
    for(long j=0; j<matB.n; j++){
      newmat(i,j) = matB(i,j);
    }
    for(long j=std::max(long(0),i-matA.kl); j<std::min(matA.n,i+matA.ku+1); j++){
      newmat(i,j)+=matA(i,j);
    }
  }
  
  return _(newmat);
}
_dgematrix operator+ ( const dgbmatrix matA,
const _dsymatrix matB 
) [friend]

dgbmatrix+_dsymatrix operator

Definition at line 3 of file dgbmatrix-_dsymatrix.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
  
  dgematrix newmat(matB.n,matB.n);
  for(long i=0; i<matA.m; i++){
    for(long j=0; j<matB.n; j++){
      newmat(i,j) = matB(i,j);
    }
    for(long j=std::max(long(0),i-matA.kl); j<std::min(matA.n,i+matA.ku+1); j++){
      newmat(i,j)+=matA(i,j);
    }
  }
  
  matB.destroy();
  return _(newmat);
}
_dgbmatrix operator+ ( const dgbmatrix matA,
const dgbmatrix matB 
) [friend]

dgbmatrix+dgbmatrix operator

Definition at line 133 of file dgbmatrix-dgbmatrix.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
  
  dgbmatrix newmat(matA.m,matA.n,std::max(matA.kl,matB.kl),std::max(matA.ku,matB.ku));
  newmat.zero();
  
  for(long i=0; i<matA.m; i++){
    for(long j=std::max(long(0),i-matA.kl); j<std::min(matA.n,i+matA.ku+1); j++){
      newmat(i,j)+=matA(i,j);
    }
    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);
}
_dgbmatrix operator+ ( const dgbmatrix matA,
const _dgbmatrix matB 
) [friend]

dgbmatrix+_dgbmatrix operator

Definition at line 133 of file dgbmatrix-_dgbmatrix.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
  
  if(matB.kl>matA.kl && matB.ku>matA.ku){
    for(long i=0; i<matA.m; i++){
      for(long j=std::max(long(0),i-matA.kl); j<std::min(matA.n,i+matA.ku+1); j++){
        matB(i,j)+=matA(i,j);
      }
    }
    
    return matB;
  }
  else{
    dgbmatrix newmat(matA.m,matA.n,std::max(matA.kl,matB.kl),std::max(matA.ku,matB.ku));
    newmat.zero();
    
    for(long i=0; i<matA.m; i++){
      for(long j=std::max(long(0),i-matA.kl); j<std::min(matA.n,i+matA.ku+1); j++){
        newmat(i,j)+=matA(i,j);
      }
      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);
  }
}
_dgematrix operator+ ( const dgbmatrix matA,
const dgsmatrix matB 
) [friend]

dgbmatrix+dgsmatrix operator

Definition at line 3 of file dgbmatrix-dgsmatrix.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
  
  dgematrix newmat( matB.to_dgematrix() );
  
  for(long i=0; i<matA.m; i++){
    for(long j=std::max(long(0),i-matA.kl); j<std::min(matA.n,i+matA.ku+1); j++){
      newmat(i,j)+=matA(i,j);
    }
  }
  
  return _(newmat);
}
_dgematrix operator+ ( const dgbmatrix matA,
const _dgsmatrix matB 
) [friend]

dgbmatrix+_dgsmatrix operator

Definition at line 3 of file dgbmatrix-_dgsmatrix.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
  
  dgematrix newmat( matB.to_dgematrix() );
  for(long i=0; i<matA.m; i++){
    for(long j=std::max(long(0),i-matA.kl); j<std::min(matA.n,i+matA.ku+1); j++){
      newmat(i,j)+=matA(i,j);
    }
  }
  
  matB.destroy();
  return _(newmat);
}
_dgematrix operator+ ( const dgbmatrix ,
const dssmatrix  
) [friend]
_dgematrix operator+ ( const dgbmatrix ,
const _dssmatrix  
) [friend]
_dgematrix operator- ( const dgbmatrix matA,
const dgematrix matB 
) [friend]

dgbmatrix-dgematrix operator

Definition at line 26 of file dgbmatrix-dgematrix.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
  
  dgematrix newmat(-matB);
  for(long i=0; i<matA.m; i++){
    for(long j=std::max(long(0),i-matA.kl); j<std::min(matA.n,i+matA.ku+1); j++){
      newmat(i,j)+=matA(i,j);
    }
  }
  
  return _(newmat);
}
_dgematrix operator- ( const dgbmatrix matA,
const _dgematrix matB 
) [friend]

dgbmatrix-_dgematrix operator

Definition at line 25 of file dgbmatrix-_dgematrix.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
  
  //// change sign ////
  for(long i=0; i<matB.m*matB.n; i++){
    matB.array[i]=-matB.array[i];
  }
  
  //// add ////
  for(long i=0; i<matA.m; i++){
    for(long j=std::max(long(0),i-matA.kl); j<std::min(matA.n,i+matA.ku+1); j++){
      matB(i,j) +=matA(i,j);
    }
  }
  
  return matB;
}
_dgematrix operator- ( const dgbmatrix matA,
const dsymatrix matB 
) [friend]

dgbmatrix-dsymatrix operator

Definition at line 29 of file dgbmatrix-dsymatrix.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
  
  dgematrix newmat(matB.n,matB.n);
  for(long i=0; i<matA.m; i++){
    for(long j=0; j<matB.n; j++){
      newmat(i,j) = -matB(i,j);
    }
    for(long j=std::max(long(0),i-matA.kl); j<std::min(matA.n,i+matA.ku+1); j++){
      newmat(i,j) += matA(i,j);
    }
  }
  
  return _(newmat);
}
_dgematrix operator- ( const dgbmatrix matA,
const _dsymatrix matB 
) [friend]

dgbmatrix-_dsymatrix operator

Definition at line 30 of file dgbmatrix-_dsymatrix.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
  
  dgematrix newmat(matB.n,matB.n);
  for(long i=0; i<matA.m; i++){
    for(long j=0; j<matB.n; j++){
      newmat(i,j) = -matB(i,j);
    }
    for(long j=std::max(long(0),i-matA.kl); j<std::min(matA.n,i+matA.ku+1); j++){
      newmat(i,j) += matA(i,j);
    }
  }
  
  matB.destroy();
  return _(newmat);
}
_dgbmatrix operator- ( const dgbmatrix matA,
const dgbmatrix matB 
) [friend]

dgbmatrix-dgbmatrix operator

Definition at line 161 of file dgbmatrix-dgbmatrix.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
  
  dgbmatrix newmat(matA.m,matA.n,std::max(matA.kl,matB.kl),std::max(matA.ku,matB.ku));
  newmat.zero();
  
  for(long i=0; i<matA.m; i++){
    for(long j=std::max(long(0),i-matA.kl); j<std::min(matA.n,i+matA.ku+1); j++){
      newmat(i,j)+=matA(i,j);
    }
    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);
}
_dgbmatrix operator- ( const dgbmatrix matA,
const _dgbmatrix matB 
) [friend]

dgbmatrix-_dgbmatrix operator

Definition at line 173 of file dgbmatrix-_dgbmatrix.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
  
  dgbmatrix newmat(matA.m,matA.n,std::max(matA.kl,matB.kl),std::max(matA.ku,matB.ku));
  newmat.zero();
  
  for(long i=0; i<matA.m; i++){
    for(long j=std::max(long(0),i-matA.kl); j<std::min(matA.n,i+matA.ku+1); j++){
      newmat(i,j)+=matA(i,j);
    }
    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);
}
_dgematrix operator- ( const dgbmatrix matA,
const dgsmatrix matB 
) [friend]

dgbmatrix-dgsmatrix operator

Definition at line 27 of file dgbmatrix-dgsmatrix.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
  
  dgematrix newmat( -matB.to_dgematrix() );
  
  for(long i=0; i<matA.m; i++){
    for(long j=std::max(long(0),i-matA.kl); j<std::min(matA.n,i+matA.ku+1); j++){
      newmat(i,j)-=matA(i,j);
    }
  }
  
  return _(newmat);
}
_dgematrix operator- ( const dgbmatrix matA,
const _dgsmatrix matB 
) [friend]

dgbmatrix-_dgsmatrix operator

Definition at line 27 of file dgbmatrix-_dgsmatrix.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
  
  dgematrix newmat( (-matB).to_dgematrix() );
  for(long i=0; i<matA.m; i++){
    for(long j=std::max(long(0),i-matA.kl); j<std::min(matA.n,i+matA.ku+1); j++){
      newmat(i,j)-=matA(i,j);
    }
  }
  
  matB.destroy();
  return _(newmat);
}
_dgematrix operator- ( const dgbmatrix ,
const dssmatrix  
) [friend]
_dgematrix operator- ( const dgbmatrix ,
const _dssmatrix  
) [friend]
_dcovector operator* ( const dgbmatrix mat,
const dcovector vec 
) [friend]

dgbmatrix*dcovector operator

Definition at line 3 of file dgbmatrix-dcovector.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
  
  dcovector newvec(mat.m);
  dgbmv_( 'n', mat.m, mat.n, mat.kl, mat.ku, 1.0, mat.array,
          mat.kl+mat.ku+1, vec.array, 1, 0.0, newvec.array, 1 );
  
  return _(newvec);
}
_dcovector operator* ( const dgbmatrix mat,
const _dcovector vec 
) [friend]

dgbmatrix*_dcovector operator

Definition at line 3 of file dgbmatrix-_dcovector.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
  
  dcovector newvec(mat.m);
  dgbmv_( 'n', mat.m, mat.n, mat.kl, mat.ku, 1.0, mat.array,
          mat.kl+mat.ku+1, vec.array, 1, 0.0, newvec.array, 1 );
  
  vec.destroy();
  return _(newvec);
}
_dgematrix operator* ( const dgbmatrix matA,
const dgematrix matB 
) [friend]

dgbmatrix*dgematrix operator

Definition at line 49 of file dgbmatrix-dgematrix.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
  
  dgematrix 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),i-matA.kl); k<std::min(matA.n,i+matA.ku+1); k++){
        newmat(i,j)+=matA(i,k)*matB(k,j);
      }
    }
  }
  
  return _(newmat);
}
_dgematrix operator* ( const dgbmatrix matA,
const _dgematrix matB 
) [friend]

dgbmatrix*_dgematrix operator

Definition at line 53 of file dgbmatrix-_dgematrix.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
  
  dgematrix 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),i-matA.kl); k<std::min(matA.n,i+matA.ku+1); k++){
        newmat(i,j)+=matA(i,k)*matB(k,j);
      }
    }
  }
  
  matB.destroy();
  return _(newmat);
}
_dgematrix operator* ( const dgbmatrix matA,
const dsymatrix matB 
) [friend]

dgbmatrix*dsymatrix operator

Definition at line 55 of file dgbmatrix-dsymatrix.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
  
  dgematrix 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),i-matA.kl); k<std::min(matA.n,i+matA.ku+1); k++){
        newmat(i,j)+=matA(i,k)*matB(k,j);
      }
    }
  }
  
  return _(newmat);
}
_dgematrix operator* ( const dgbmatrix matA,
const _dsymatrix matB 
) [friend]

dgbmatrix*_dsymatrix operator

Definition at line 57 of file dgbmatrix-_dsymatrix.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
  
  dgematrix 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),i-matA.kl); k<std::min(matA.n,i+matA.ku+1); k++){
        newmat(i,j)+=matA(i,k)*matB(k,j);
      }
    }
  }
  
  matB.destroy();
  return _(newmat);
}
_dgbmatrix operator* ( const dgbmatrix matA,
const dgbmatrix matB 
) [friend]

dgbmatrix*dgbmatrix operator

Definition at line 189 of file dgbmatrix-dgbmatrix.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
  
  dgbmatrix newmat( matA.m, matB.n, std::min(matA.kl+matB.kl,matA.m-1), std::min(matA.ku+matB.ku,matB.n-1) );
  newmat.zero();
  
  for(long i=0; i<newmat.m; i++){
    for(long j=std::max(long(0),i-newmat.kl); j<std::min(newmat.n,i+newmat.ku+1); j++){
      for(long k=std::max( std::max(long(0),i-matA.kl), std::max(long(0),j-matB.ku) );
          k< std::min( std::min(matA.n,i+matA.ku+1), std::min(matB.m,j+matB.kl+1) ); k++){
        newmat(i,j)+= matA(i,k)*matB(k,j);
      }
    }
  }
  
  return _(newmat);
}
_dgbmatrix operator* ( const dgbmatrix matA,
const _dgbmatrix matB 
) [friend]

dgbmatrix*_dgbmatrix operator

Definition at line 202 of file dgbmatrix-_dgbmatrix.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
  
  dgbmatrix newmat( matA.m, matB.n, std::min(matA.kl+matB.kl,matA.m-1), std::min(matA.ku+matB.ku,matB.n-1) );
  newmat.zero();
  
  for(long i=0; i<newmat.m; i++){
    for(long j=std::max(long(0),i-newmat.kl); j<std::min(newmat.n,i+newmat.ku+1); j++){
      for(long k=std::max( std::max(long(0),i-matA.kl), std::max(long(0),j-matB.ku) );
          k< std::min( std::min(matA.n,i+matA.ku+1), std::min(matB.m,j+matB.kl+1) ); k++){
        newmat(i,j)+= matA(i,k)*matB(k,j);
      }
    }
  }
  
  matB.destroy();
  return _(newmat);
}
_dgematrix operator* ( const dgbmatrix matA,
const dgsmatrix matB 
) [friend]

dgbmatrix*dgsmatrix operator

Definition at line 51 of file dgbmatrix-dgsmatrix.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
  
  dgematrix newmat( matA.m, matB.n );
  newmat.zero();
  for(std::vector<dcomponent>::const_iterator it=matB.data.begin(); it!=matB.data.end(); it++){
    for(long i=std::max(long(0),long(it->i)-(matA.ku+1)); i<std::min(matA.m,long(it->i)+matA.kl); i++){
      newmat(i,it->j) += matA(i,it->i)*it->v;
    }
  }
  
  return _(newmat);
}
_dgematrix operator* ( const dgbmatrix matA,
const _dgsmatrix matB 
) [friend]

dgbmatrix*_dgsmatrix operator

Definition at line 51 of file dgbmatrix-_dgsmatrix.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
  
  dgematrix newmat( matA.m, matB.n );
  newmat.zero();
  for(std::vector<dcomponent>::const_iterator it=matB.data.begin(); it!=matB.data.end(); it++){
    for(long i=std::max(long(0),long(it->i)-(matA.ku+1)); i<std::min(matA.m,long(it->i)+matA.kl); i++){
      newmat(i,it->j) += matA(i,it->i)*it->v;
    }
  }
  
  matB.destroy();
  return _(newmat);
}
_dgematrix operator* ( const dgbmatrix ,
const dssmatrix  
) [friend]
_dgematrix operator* ( const dgbmatrix ,
const _dssmatrix  
) [friend]
_dgbmatrix operator* ( const dgbmatrix mat,
const double &  d 
) [friend]

dgbmatrix*double operator

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

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

dgbmatrix/double operator

Definition at line 35 of file dgbmatrix-double.hpp.

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

double*dgbmatrix operator

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

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

Member Data Documentation

array of pointers of column head addresses

Definition at line 14 of file dgbmatrix.hpp.

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


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