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

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

#include <dgematrix.hpp>

List of all members.

Public Member Functions

 dgematrix ()
 dgematrix (const dgematrix &)
 dgematrix (const _dgematrix &)
 dgematrix (const long &, const long &)
 dgematrix (const char *)
 ~dgematrix ()
_zgematrix to_zgematrix () const
double & operator() (const long &, const long &)
double operator() (const long &, const long &) const
dgematrixset (const long &, const long &, const double &)
void write (const char *) const
void read (const char *)
void clear ()
dgematrixzero ()
dgematrixidentity ()
void chsign ()
void copy (const dgematrix &)
void shallow_copy (const _dgematrix &)
dgematrixresize (const long &, const long &)
_drovector row (const long &) const
_dcovector col (const long &) const
long dgesv (dgematrix &)
long dgesv (dcovector &)
long dgels (dgematrix &)
long dgels (dcovector &)
long dgels (dgematrix &, drovector &)
long dgels (dcovector &, double &)
long dgelss (dcovector &, dcovector &, long &, const double)
long dgelss (dgematrix &, dcovector &, long &, const double)
long dgeev (std::vector< double > &, std::vector< double > &)
long dgeev (zcovector &)
long dgeev (std::vector< double > &, std::vector< double > &, std::vector< dcovector > &, std::vector< dcovector > &)
long dgeev (std::vector< double > &, std::vector< double > &, std::vector< drovector > &, std::vector< drovector > &)
long dggev (dgematrix &, std::vector< double > &, std::vector< double > &)
long dggev (dgematrix &, std::vector< double > &, std::vector< double > &, std::vector< dcovector > &, std::vector< dcovector > &)
long dggev (dgematrix &, std::vector< double > &, std::vector< double > &, std::vector< drovector > &, std::vector< drovector > &)
long dgesvd (dgbmatrix &)
long dgesvd (dcovector &, dgematrix &, dgematrix &)
long dgglse (dgematrix &, dcovector &, dcovector &, dcovector &)
dgematrixoperator= (const dgematrix &)
dgematrixoperator= (const _dgematrix &)
dgematrixoperator+= (const dgematrix &)
dgematrixoperator+= (const _dgematrix &)
dgematrixoperator+= (const dsymatrix &)
dgematrixoperator+= (const _dsymatrix &)
dgematrixoperator+= (const dgbmatrix &)
dgematrixoperator+= (const _dgbmatrix &)
dgematrixoperator+= (const dgsmatrix &)
dgematrixoperator+= (const _dgsmatrix &)
dgematrixoperator+= (const dssmatrix &)
dgematrixoperator+= (const _dssmatrix &)
dgematrixoperator-= (const dgematrix &)
dgematrixoperator-= (const _dgematrix &)
dgematrixoperator-= (const dsymatrix &)
dgematrixoperator-= (const _dsymatrix &)
dgematrixoperator-= (const dgbmatrix &)
dgematrixoperator-= (const _dgbmatrix &)
dgematrixoperator-= (const dgsmatrix &)
dgematrixoperator-= (const _dgsmatrix &)
dgematrixoperator-= (const dssmatrix &)
dgematrixoperator-= (const _dssmatrix &)
dgematrixoperator*= (const dgematrix &)
dgematrixoperator*= (const _dgematrix &)
dgematrixoperator*= (const dsymatrix &)
dgematrixoperator*= (const _dsymatrix &)
dgematrixoperator*= (const dgbmatrix &)
dgematrixoperator*= (const _dgbmatrix &)
dgematrixoperator*= (const dgsmatrix &)
dgematrixoperator*= (const _dgsmatrix &)
dgematrixoperator*= (const dssmatrix &)
dgematrixoperator*= (const _dssmatrix &)
dgematrixoperator*= (const double &)
dgematrixoperator/= (const double &)

Public Attributes

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

Friends

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

Detailed Description

Real Double-precision General Dence Matrix Class.

Definition at line 3 of file dgematrix.hpp.


Constructor & Destructor Documentation

dgematrix::dgematrix ( ) [inline]

dgematrix constructor without arguments

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

References array, darray, m, and n.

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

dgematrix copy constructor

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

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

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

dgematrix constructor to cast _dgematrix

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

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

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

dgematrix constructor with size specification

Definition at line 49 of file dgematrix-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 double[m*n];
  darray  =new double*[n];
  for(int i=0; i<n; i++){ darray[i] =&array[i*m]; }
}
dgematrix::dgematrix ( const char *  filename) [inline]

dgematrix constructor with filename

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

References array, darray, and read().

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

dgematrix destructor

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

References array, and darray.

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

Member Function Documentation

_zgematrix dgematrix::to_zgematrix ( ) const [inline]

cast to _zgematrix

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

References _, array, zgematrix::array, i, m, and n.

{VERBOSE_REPORT;
  zgematrix newmat(m,n);
  for(long i=0; i<m*n; i++){
    newmat.array[i] =comple(array[i],0.0);
  }
  
  return _(newmat);
}
double & dgematrix::operator() ( const long &  i,
const long &  j 
) [inline]

operator() for non-const object

Definition at line 3 of file dgematrix-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];
}
double dgematrix::operator() ( const long &  i,
const long &  j 
) const [inline]

operator() for const object

Definition at line 20 of file dgematrix-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];
}
dgematrix & dgematrix::set ( const long &  i,
const long &  j,
const double &  v 
) [inline]

set value for const object

Definition at line 41 of file dgematrix-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 dgematrix::write ( const char *  filename) const [inline]

Definition at line 79 of file dgematrix-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 << "#dgematrix" << " " << 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 dgematrix::read ( const char *  filename) [inline]

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

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

Referenced by dgematrix().

{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 != "dgematrix" && id != "#dgematrix" ){
    ERROR_REPORT;
    std::cerr << "The type name of the file \"" << filename << "\" is not dgematrix." << 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 a lack of data components, or a linefeed code or space code is missing at the end of the last line." << std::endl;
    exit(1);
  }
  
  s >> 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 dgematrix::clear ( ) [inline]

clear all the matrix data and set the sizes 0

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

References array, darray, m, and n.

Referenced by dgels(), and dgelss().

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

change the matrix into a zero matrix

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

References array, i, m, and n.

Referenced by operator*(), operator*=(), _dssmatrix::to_dgematrix(), _dgsmatrix::to_dgematrix(), dssmatrix::to_dgematrix(), and dgsmatrix::to_dgematrix().

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

change the matrix into an identity matrix

Definition at line 23 of file dgematrix-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] =0.0; }
  for(long i=0; i<m; i++){ operator()(i,i) =1.0; }
  return *this;
}
void dgematrix::chsign ( ) [inline]

change sign(+/-) of the matrix

Definition at line 41 of file dgematrix-misc.hpp.

References array, i, m, and n.

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

make a deep copy of the matrix

Definition at line 48 of file dgematrix-misc.hpp.

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

Referenced by operator=().

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

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

Definition at line 64 of file dgematrix-misc.hpp.

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

Referenced by operator=().

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

resize the matrix

Definition at line 78 of file dgematrix-misc.hpp.

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

Referenced by dgesvd(), and read().

{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 double[m*n];
  delete [] darray;
  darray =new double*[n];
  for(int i=0; i<n; i++){ darray[i] =&array[i*m]; }
  
  return *this;
}
_drovector dgematrix::row ( const long &  _m) const [inline]

get row of the matrix

Definition at line 106 of file dgematrix-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
  
  drovector v(n);
  for(long j=0; j<n; j++){ v(j)=(*this)(_m,j); }
  return _(v);
}
_dcovector dgematrix::col ( const long &  _n) const [inline]

get column of the matrix

Definition at line 124 of file dgematrix-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
  
  dcovector v(m);
  for(long i=0; i<m; i++){ v(i)=(*this)(i,_n); }
  return _(v);
}
long dgematrix::dgesv ( dgematrix mat) [inline]

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

Definition at line 6 of file dgematrix-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);
  dgesv_(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 dgematrix::dgesv ( dcovector vec) [inline]

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

Definition at line 33 of file dgematrix-lapack.hpp.

References array, dcovector::array, dcovector::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);
  dgesv_(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 dgematrix::dgels ( dgematrix mat) [inline]

solve overdetermined or underdetermined A*X=Y using dgels

Definition at line 62 of file dgematrix-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
    dgematrix 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);
  double *WORK(new double[LWORK]);
  dgels_(TRANS, m, n, NRHS, array, LDA, mat.array, LDB, WORK, LWORK, INFO);
  delete [] WORK;
  
  if(m>n){ //overdetermined
    dgematrix 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 dgematrix::dgels ( dcovector vec) [inline]

solve overdetermined or underdetermined A*x=y using dgels

Definition at line 108 of file dgematrix-lapack.hpp.

References array, dcovector::array, dcovector::clear(), i, dcovector::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
    dcovector 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);
  double *WORK(new double[LWORK]);
  dgels_(TRANS, m, n, NRHS, array, LDA, vec.array, LDB, WORK, LWORK, INFO);
  delete [] WORK;
  
  if(m>n){ //overdetermined
    dcovector 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 dgematrix::dgels ( dgematrix mat,
drovector residual 
) [inline]

solve overdetermined or underdetermined A*X=Y using dgels 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 154 of file dgematrix-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
    dgematrix 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);
  double *WORK(new double[LWORK]);
  dgels_(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::pow(mat(n+j,i), 2.0);
    }}
    
    dgematrix 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 dgematrix::dgels ( dcovector vec,
double &  residual 
) [inline]

solve overdetermined or underdetermined A*x=y using dgels 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 210 of file dgematrix-lapack.hpp.

References array, dcovector::array, dcovector::clear(), i, dcovector::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
    dcovector 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);
  double *WORK(new double[LWORK]);
  dgels_(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::pow(vec(n+i),2.0); }
    
    dcovector 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 dgematrix::dgelss ( dcovector 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 dgelss

Definition at line 261 of file dgematrix-lapack.hpp.

References array, dcovector::array, dcovector::clear(), i, dcovector::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
    dcovector 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(3*std::min(m,n)+std::max(std::max(2*std::min(m,n),std::max(m,n)), NRHS)), INFO(1);
  double *WORK(new double[LWORK]);
  dgelss_(m, n, NRHS, array, LDA, B.array, LDB, S.array,
          RCOND, RANK, WORK, LWORK, INFO);
  delete [] WORK;

  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long dgematrix::dgelss ( dgematrix 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 dgelss

Definition at line 300 of file dgematrix-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
    dgematrix 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(3*std::min(m,n)+std::max(std::max(2*std::min(m,n),std::max(m,n)), NRHS)), INFO(1);
  double *WORK(new double[LWORK]);
  dgelss_(m, n, NRHS, array, LDA, B.array, LDB, S.array,
          RCOND, RANK, WORK, LWORK, INFO);
  delete [] WORK;

  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long dgematrix::dgeev ( std::vector< double > &  wr,
std::vector< double > &  wi 
) [inline]

calculate eigenvalues
All of the arguments need not to be initialized. wr and wi are overwitten and become real and imaginary part of eigenvalues, respectively. This matrix is also overwritten.

Definition at line 350 of file dgematrix-lapack.hpp.

References array, m, and n.

Referenced by dgeev().

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(m!=n){
    ERROR_REPORT;
    std::cerr << "This matrix is not a square matrix." << std::endl
              << "This matrix is (" << m << "x" << n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  wr.resize(n); wi.resize(n);
  char JOBVL('n'), JOBVR('n');
  long LDA(n), LDVL(1), LDVR(1), LWORK(3*n), INFO(1);
  double *VL(NULL), *VR(NULL), *WORK(new double[LWORK]);
  dgeev_(JOBVL, JOBVR, n, array, LDA, &wr[0], &wi[0], 
         VL, LDVL, VR, LDVR, WORK, LWORK, INFO);
  delete [] WORK; delete [] VL; delete [] VL;
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long dgematrix::dgeev ( zcovector w) [inline]

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

Definition at line 382 of file dgematrix-lapack.hpp.

References dgeev(), i, n, and zcovector::resize().

{VERBOSE_REPORT;
  //// call dgeev ////
  std::vector<double> wr, wi;
  long INFO =dgeev(wr,wi);
  
  //// assign ////
  w.resize(n);
  for(long i=0; i<n; i++){
    w(i) =comple(wr[i],wi[i]);
  }
  
  return INFO;
}
long dgematrix::dgeev ( std::vector< double > &  wr,
std::vector< double > &  wi,
std::vector< dcovector > &  vrr,
std::vector< dcovector > &  vri 
) [inline]

calculate right eigenvalues and right eigenvectors
All of the arguments need not to be initialized. wr, wi, vrr, vri are overwitten and become real and imaginary part of right eigenvalues and right eigenvectors, respectively. This matrix is also overwritten.

Definition at line 406 of file dgematrix-lapack.hpp.

References array, and i().

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(m!=n){
    ERROR_REPORT;
    std::cerr << "This matrix is not a square matrix." << std::endl
              << "This matrix is (" << m << "x" << n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  wr.resize(n); wi.resize(n); vrr.resize(n); vri.resize(n);
  for(long i=0; i<n; i++){ vrr[i].resize(n); vri[i].resize(n); }
  dgematrix VR(n,n);
  char JOBVL('n'), JOBVR('V');
  long LDA(n), LDVL(1), LDVR(n), LWORK(4*n), INFO(1);
  double *VL(NULL), *WORK(new double[LWORK]);
  dgeev_(JOBVL, JOBVR, n, array, LDA, &wr[0], &wi[0], 
         VL, LDVL, VR.array, LDVR, WORK, LWORK, INFO);
  delete [] WORK; delete [] VL;
  
  //// forming ////
  for(long j=0; j<n; j++){
    if(fabs(wi[j])<DBL_MIN){
      for(long i=0; i<n; i++){
        vrr[j](i) = VR(i,j);
        vri[j](i) = 0.0;
      }
    }
    else{
      for(long i=0; i<n; i++){
        vrr[j](i)   = VR(i,j);
        vri[j](i)   = VR(i,j+1);
        vrr[j+1](i) = VR(i,j);
        vri[j+1](i) =-VR(i,j+1);
      }
      j++;
    }
  }
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long dgematrix::dgeev ( std::vector< double > &  wr,
std::vector< double > &  wi,
std::vector< drovector > &  vlr,
std::vector< drovector > &  vli 
) [inline]

calculate left eigenvalues and left eigenvectors
All of the arguments need not to be initialized. wr, wi, vrr, vri are overwitten and become real and imaginary part of left eigenvalues and left eigenvectors, respectively. This matrix is also overwritten.

Definition at line 466 of file dgematrix-lapack.hpp.

References array, i, m, and n.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(m!=n){
    ERROR_REPORT;
    std::cerr << "This matrix is not a square matrix." << std::endl
              << "This matrix is (" << m << "x" << n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  wr.resize(n); wi.resize(n); vlr.resize(n); vli.resize(n);
  for(long i=0; i<n; i++){ vlr[i].resize(n); vli[i].resize(n); }
  dgematrix VL(n,n);
  char JOBVL('V'), JOBVR('n');
  long LDA(n), LDVL(n), LDVR(1), LWORK(4*n), INFO(1);
  double *VR(NULL), *WORK(new double[LWORK]);
  dgeev_(JOBVL, JOBVR, n, array, LDA, &wr[0], &wi[0], 
         VL.array, LDVL, VR, LDVR, WORK, LWORK, INFO);
  delete [] WORK; delete [] VR;

  //// forming ////
  for(long j=0; j<n; j++){
    if(fabs(wi[j])<DBL_MIN){
      for(long i=0; i<n; i++){
        vlr[j](i) = VL(i,j);
        vli[j](i) = 0.0;
      }
    }
    else{
      for(long i=0; i<n; i++){
        vlr[j](i)   = VL(i,j);
        vli[j](i)   =-VL(i,j+1);
        vlr[j+1](i) = VL(i,j);
        vli[j+1](i) = VL(i,j+1);
      }
      j++;
    }
  }
  

  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long dgematrix::dggev ( dgematrix matB,
std::vector< double > &  wr,
std::vector< double > &  wi 
) [inline]

calculate generalized eigenvalues
All of the arguments don't need to be initialized. wr and wi are overwitten and become real and imaginary part of generalized eigenvalues, respectively. This matrix and matB are also overwritten.

Definition at line 529 of file dgematrix-lapack.hpp.

References array, i, m, and n.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(m!=n){
    ERROR_REPORT;
    std::cerr << "This matrix is not a square matrix." << std::endl
              << "This matrix is (" << m << "x" << n << ")." << std::endl;
    exit(1);
  }
  if(matB.m!=n || matB.n!=n){
    ERROR_REPORT;
    std::cerr << "The matrix B is not a square matrix having the same size as \"this\" matrix." << std::endl
              << "The B matrix is (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  wr.resize(n); wi.resize(n);
  char JOBVL('n'), JOBVR('n');
  long LDA(n), LDB(n), LDVL(1), LDVR(1), LWORK(8*n), INFO(1);
  double *BETA(new double[n]), *VL(NULL), *VR(NULL), 
    *WORK(new double[LWORK]);
  dggev_(JOBVL, JOBVR, n, array, LDA, matB.array, LDB, &wr[0], &wi[0], 
         BETA, VL, LDVL, VR, LDVR, WORK, LWORK, INFO);
  delete [] WORK; delete [] VL; delete [] VR;
  
  //// reforming ////
  for(long i=0; i<n; i++){ wr[i]/=BETA[i];  wi[i]/=BETA[i]; }
  delete [] BETA; 
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long dgematrix::dggev ( dgematrix matB,
std::vector< double > &  wr,
std::vector< double > &  wi,
std::vector< dcovector > &  vrr,
std::vector< dcovector > &  vri 
) [inline]

calculate generalized eigenvalues and generalized right eigenvectors
All of the arguments don't need to be initialized. wr, wi, vrr and vri are overwitten and become real and imaginary part of generalized eigenvalue and generalized right eigenvector, respectively. This matrix and matB are also overwritten.

Definition at line 575 of file dgematrix-lapack.hpp.

References array, i, m, and n.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(m!=n){
    ERROR_REPORT;
    std::cerr << "This matrix is not a square matrix." << std::endl
              << "This matrix is (" << m << "x" << n << ")." << std::endl;
    exit(1);
  }
  if(matB.m!=n || matB.n!=n){
    ERROR_REPORT;
    std::cerr << "The matrix B is not a square matrix having the same size as \"this\" matrix." << std::endl
              << "The B matrix is (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  wr.resize(n); wi.resize(n); vrr.resize(n); vri.resize(n);
  for(long i=0; i<n; i++){ vrr[i].resize(n); vri[i].resize(n); }
  dgematrix VR(n,n);
  char JOBVL('n'), JOBVR('V');
  long LDA(n), LDB(n), LDVL(1), LDVR(n), LWORK(8*n), INFO(1);
  double *BETA(new double[n]), *VL(NULL), *WORK(new double[LWORK]);
  dggev_(JOBVL, JOBVR, n, array, LDA, matB.array, LDB, &wr[0], &wi[0], 
         BETA, VL, LDVL, VR.array, LDVR, WORK, LWORK, INFO);
  delete [] WORK; delete [] VL;
  
  //// reforming ////
  for(long i=0; i<n; i++){ wr[i]/=BETA[i];  wi[i]/=BETA[i]; }
  delete [] BETA; 
  
  //// forming ////
  for(long j=0; j<n; j++){
    if(fabs(wi[j])<DBL_MIN){
      for(long i=0; i<n; i++){
        vrr[j](i) = VR(i,j);
        vri[j](i) = 0.0;
      }
    }
    else{
      for(long i=0; i<n; i++){
        vrr[j](i)   = VR(i,j);
        vri[j](i)   = VR(i,j+1);
        vrr[j+1](i) = VR(i,j);
        vri[j+1](i) =-VR(i,j+1);
      }
      j++;
    }
  }
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long dgematrix::dggev ( dgematrix matB,
std::vector< double > &  wr,
std::vector< double > &  wi,
std::vector< drovector > &  vlr,
std::vector< drovector > &  vli 
) [inline]

calculate generalized eigenvalues and generalized left eigenvectors
All of the arguments don't need to be initialized. wr, wi, vlr and vli are overwitten and become real and imaginary part of generalized eigenvalue and generalized left eigenvector, respectively. This matrix and matB are also overwritten.

Definition at line 643 of file dgematrix-lapack.hpp.

References array, i, m, and n.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(m!=n){
    ERROR_REPORT;
    std::cerr << "This matrix is not a square matrix." << std::endl
              << "This matrix is (" << m << "x" << n << ")." << std::endl;
    exit(1);
  }
  if(matB.m!=n || matB.n!=n){
    ERROR_REPORT;
    std::cerr << "The matrix B is not a square matrix having the same size as \"this\" matrix." << std::endl
              << "The B matrix is (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  wr.resize(n); wi.resize(n); vlr.resize(n); vli.resize(n);
  for(long i=0; i<n; i++){ vlr[i].resize(n); vli[i].resize(n); }
  dgematrix VL(n,n);
  char JOBVL('V'), JOBVR('n');
  long LDA(n), LDB(n), LDVL(n), LDVR(1), LWORK(8*n), INFO(1);
  double *BETA(new double[n]), *VR(NULL), *WORK(new double[LWORK]);
  dggev_(JOBVL, JOBVR, n, array, LDA, matB.array, LDB, &wr[0], &wi[0], 
         BETA, VL.array, LDVL, VR, LDVR, WORK, LWORK, INFO);
  delete [] WORK; delete [] VR;
  
  //// reforming ////
  for(long i=0; i<n; i++){ wr[i]/=BETA[i];  wi[i]/=BETA[i]; }
  delete [] BETA; 
  
  //// forming ////
  for(long j=0; j<n; j++){
    if(fabs(wi[j])<DBL_MIN){
      for(long i=0; i<n; i++){
        vlr[j](i) = VL(i,j);
        vli[j](i) = 0.0;
      }
    }
    else{
      for(long i=0; i<n; i++){
        vlr[j](i)   = VL(i,j);
        vli[j](i)   =-VL(i,j+1);
        vlr[j+1](i) = VL(i,j);
        vli[j+1](i) = VL(i,j+1);
      }
      j++;
    }
  }
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long dgematrix::dgesvd ( dgbmatrix S) [inline]

compute the singular value decomposition (SVD)
The argument is dgbmatrix S. S doesn't need to be initialized. S is overwitten and become singular values. This matrix also overwritten.

Definition at line 715 of file dgematrix-lapack.hpp.

References dgbmatrix::array, and dgbmatrix::resize().

{VERBOSE_REPORT;
  char JOBU('n'), JOBVT('n');
  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 *WORK(new double[LWORK]);
  S.resize(m,n,0,0);
  
  dgesvd_(JOBU, JOBVT, m, n, array, LDA, S.array, NULL, LDU, NULL, LDVT, WORK, LWORK, INFO);
  delete [] WORK;
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long dgematrix::dgesvd ( dcovector S,
dgematrix U,
dgematrix VT 
) [inline]

compute the singular value decomposition (SVD)
The arguments are dcocector S, dgematrix 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 743 of file dgematrix-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 *WORK(new double[LWORK]);
  S.resize(std::min(m,n)); U.resize(LDU,m); VT.resize(LDVT,n);
  
  dgesvd_(JOBU, JOBVT, m, n, array, LDA, S.array, U.array,
          LDU, VT.array, LDVT, WORK, LWORK, INFO);
  delete [] WORK;
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long dgematrix::dgglse ( dgematrix B,
dcovector c,
dcovector d,
dcovector x 
) [inline]

solve the linear equality-constrained least squares (LSE) problem
Input matrix and vectors, B, c, and d, are overwitten. This matrix is also overwritten. The solution vector x is to be automatically resized.

Definition at line 773 of file dgematrix-lapack.hpp.

References array, dcovector::array, dcovector::clear(), dcovector::l, m, and dcovector::resize().

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(m!=c.l){
    ERROR_REPORT;
    std::cerr << "A.m and c.l should be the same." << std::endl
              << "Your input was A.m=" << m << " and c.l=" << c.l << std::endl;
    exit(1);
  }
  if(B.m!=d.l){
    ERROR_REPORT;
    std::cerr << "B.m and d.l should be the same." << std::endl
              << "Your input was B.m=" << B.m << " and d.l=" << d.l << std::endl;
    exit(1);
  }
  if( !(B.m<=n) || !(n<=m+B.m) ){
    ERROR_REPORT;
    std::cerr << "B.m<=A.n<=A.m+B.m should be satisfied." << std::endl
              << "Your input was B.m=" << B.m << ", A.n=" << n << ", and A.m+B.m=" << m+B.m << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  long lwork(-1), info(1);
  dcovector work(1);
  x.resize(n);
  
  //////// workspace query ////////
  dgglse_(m, n, B.m, array, std::max(1l,m), B.array, std::max(1l,B.m), c.array, d.array, x.array, work.array, lwork, info);
  lwork =long(work(0));
  work.resize(lwork);
  info =1;
  
  //////// solve ////////
  dgglse_(m, n, B.m, array, std::max(1l,m), B.array, std::max(1l,B.m), c.array, d.array, x.array, work.array, lwork,  info);
  work.clear();
  
  if(info!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. info = " << info << "." << std::endl;
  }
  return info;
}
dgematrix & dgematrix::operator= ( const dgematrix mat) [inline]

dgematrix=dgematrix operator

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

References array, and copy().

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

dgematrix=_dgematrix operator

Definition at line 3 of file dgematrix-_dgematrix.hpp.

References shallow_copy().

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

dgematrix+=dgematrix operator

Definition at line 17 of file dgematrix-dgematrix.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;
}
dgematrix & dgematrix::operator+= ( const _dgematrix mat) [inline]

dgematrix+=_dgematrix operator

Definition at line 15 of file dgematrix-_dgematrix.hpp.

References array, _dgematrix::array, _dgematrix::destroy(), i, _dgematrix::m, m, n, and _dgematrix::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;
}
dgematrix & dgematrix::operator+= ( const dsymatrix mat) [inline]

dgematrix+=dsymatrix operator

Definition at line 3 of file dgematrix-dsymatrix.hpp.

References i, m, dsymatrix::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);
    }
  }
  
  return *this;
}
dgematrix & dgematrix::operator+= ( const _dsymatrix mat) [inline]

dgematrix+=_dsymatrix operator

Definition at line 3 of file dgematrix-_dsymatrix.hpp.

References _dsymatrix::destroy(), i, m, _dsymatrix::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;
}
dgematrix & dgematrix::operator+= ( const dgbmatrix mat) [inline]

dgematrix+=dgbmatrix operator

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

References i, dgbmatrix::kl, dgbmatrix::ku, m, dgbmatrix::m, dgbmatrix::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;
}
dgematrix & dgematrix::operator+= ( const _dgbmatrix mat) [inline]

dgematrix+=_dgbmatrix operator

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

References _dgbmatrix::destroy(), i, _dgbmatrix::kl, _dgbmatrix::ku, m, _dgbmatrix::m, _dgbmatrix::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;
}
dgematrix& dgematrix::operator+= ( const dgsmatrix ) [inline]
dgematrix& dgematrix::operator+= ( const _dgsmatrix ) [inline]
dgematrix& dgematrix::operator+= ( const dssmatrix ) [inline]
dgematrix& dgematrix::operator+= ( const _dssmatrix ) [inline]
dgematrix & dgematrix::operator-= ( const dgematrix mat) [inline]

dgematrix operator-=

Definition at line 34 of file dgematrix-dgematrix.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;
}
dgematrix & dgematrix::operator-= ( const _dgematrix mat) [inline]

dgematrix-=_dgematrix operator

Definition at line 34 of file dgematrix-_dgematrix.hpp.

References array, _dgematrix::array, _dgematrix::destroy(), i, _dgematrix::m, m, n, and _dgematrix::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;
}
dgematrix & dgematrix::operator-= ( const dsymatrix mat) [inline]

dgematrix-=dsymatrix operator

Definition at line 25 of file dgematrix-dsymatrix.hpp.

References i, m, dsymatrix::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);
    }
  }
  
  return *this;
}
dgematrix & dgematrix::operator-= ( const _dsymatrix mat) [inline]

dgematrix-=_dsymatrix operator

Definition at line 26 of file dgematrix-_dsymatrix.hpp.

References _dsymatrix::destroy(), i, m, _dsymatrix::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;
}
dgematrix & dgematrix::operator-= ( const dgbmatrix mat) [inline]

dgematrix-=dgbmatrix operator

Definition at line 25 of file dgematrix-dgbmatrix.hpp.

References i, dgbmatrix::kl, dgbmatrix::ku, m, dgbmatrix::m, dgbmatrix::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;
}
dgematrix & dgematrix::operator-= ( const _dgbmatrix mat) [inline]

dgematrix-=_dgbmatrix operator

Definition at line 26 of file dgematrix-_dgbmatrix.hpp.

References _dgbmatrix::destroy(), i, _dgbmatrix::kl, _dgbmatrix::ku, m, _dgbmatrix::m, _dgbmatrix::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;
}
dgematrix& dgematrix::operator-= ( const dgsmatrix ) [inline]
dgematrix& dgematrix::operator-= ( const _dgsmatrix ) [inline]
dgematrix& dgematrix::operator-= ( const dssmatrix ) [inline]
dgematrix& dgematrix::operator-= ( const _dssmatrix ) [inline]
dgematrix & dgematrix::operator*= ( const dgematrix mat) [inline]

dgematrix operator*=

Definition at line 51 of file dgematrix-dgematrix.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
  
  dgematrix newmat( m, mat.n );
  dgemm_( 'n', 'n', m, mat.n, n, 1.0, array, m,
          mat.array, mat.m, 0.0, newmat.array, m );
  
  swap(*this,newmat);
  return *this;
}
dgematrix & dgematrix::operator*= ( const _dgematrix mat) [inline]

dgematrix*=_dgematrix operator

Definition at line 53 of file dgematrix-_dgematrix.hpp.

References array, _dgematrix::array, _dgematrix::destroy(), _dgematrix::m, m, _dgematrix::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
  
  dgematrix newmat( m, mat.n );
  dgemm_( 'n', 'n', m, mat.n, n, 1.0, array, m,
          mat.array, mat.m, 0.0, newmat.array, m );
  
  swap(*this,newmat);
  mat.destroy();
  return *this;
}
dgematrix & dgematrix::operator*= ( const dsymatrix mat) [inline]

dgematrix*=dsymatrix operator

Definition at line 47 of file dgematrix-dsymatrix.hpp.

References dsymatrix::array, array, m, dsymatrix::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
  
  dgematrix newmat( m, mat.n );
  dsymm_( 'R', 'l', mat.n, n, 1.0, mat.array, mat.n, 
          array, m, 0.0, newmat.array, newmat.m );
  
  swap(*this,newmat);
  return *this;
}
dgematrix & dgematrix::operator*= ( const _dsymatrix mat) [inline]

dgematrix*=_dsymatrix operator

Definition at line 49 of file dgematrix-_dsymatrix.hpp.

References _dsymatrix::array, array, _dsymatrix::destroy(), m, _dsymatrix::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
  
  dgematrix newmat( m, mat.n );
  dsymm_( 'R', 'l', mat.n, n, 1.0, mat.array, mat.n, 
          array, m, 0.0, newmat.array, newmat.m );
  
  swap(*this,newmat);
  mat.destroy();
  return *this;
}
dgematrix & dgematrix::operator*= ( const dgbmatrix mat) [inline]

dgematrix*=dgbmatrix operator

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

References i, dgbmatrix::kl, dgbmatrix::ku, m, dgbmatrix::m, n, dgbmatrix::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
  dgematrix 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;
}
dgematrix & dgematrix::operator*= ( const _dgbmatrix mat) [inline]

dgematrix*=_dgbmatrix operator

Definition at line 48 of file dgematrix-_dgbmatrix.hpp.

References _dgbmatrix::destroy(), i, _dgbmatrix::kl, _dgbmatrix::ku, m, _dgbmatrix::m, n, _dgbmatrix::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
  
  dgematrix 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;
}
dgematrix& dgematrix::operator*= ( const dgsmatrix ) [inline]
dgematrix& dgematrix::operator*= ( const _dgsmatrix ) [inline]
dgematrix& dgematrix::operator*= ( const dssmatrix ) [inline]
dgematrix& dgematrix::operator*= ( const _dssmatrix ) [inline]
dgematrix & dgematrix::operator*= ( const double &  d) [inline]

dgematrix*=double operator

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

References array, m, and n.

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

dgematrix/=double operator

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

References array, m, and n.

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

Friends And Related Function Documentation

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

Definition at line 63 of file dgematrix-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 ( dgematrix A,
dgematrix B 
) [friend]

swap two matrices

Definition at line 146 of file dgematrix-misc.hpp.

Referenced by dgels(), dgelss(), and operator*=().

{VERBOSE_REPORT;
  long A_m =A.m, A_n =A.n;
  double* A_array =A.array;
  double** A_darray=A.darray;
  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;
}
_dgematrix _ ( dgematrix mat) [friend]

convert user object to smart-temporary object

Definition at line 157 of file dgematrix-misc.hpp.

Referenced by col(), row(), and to_zgematrix().

{VERBOSE_REPORT;
  _dgematrix 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;
}
_dgematrix t ( const dgematrix mat) [friend]

return transposed dgematrix

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

{VERBOSE_REPORT;
  dgematrix 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);
}
_dgematrix i ( const dgematrix mat) [friend]

return its inverse matrix

Definition at line 18 of file dgematrix-calc.hpp.

Referenced by chsign(), col(), copy(), dgeev(), dgels(), dgelss(), dgematrix(), dggev(), identity(), operator()(), operator*=(), operator+=(), operator-=(), read(), resize(), set(), to_zgematrix(), 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
  
  dgematrix mat_cp(mat), mat_inv(mat.m,mat.n);
  mat_inv.identity();
  mat_cp.dgesv(mat_inv);
  
  return _(mat_inv);
}
void idamax ( long &  i,
long &  j,
const dgematrix mat 
) [friend]

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

Definition at line 43 of file dgematrix-calc.hpp.

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

return its largest absolute value

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

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

+dgematrix operator

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

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

-dgematrix operator

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

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

dgematrix+dgematrix operator

Definition at line 76 of file dgematrix-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(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);
}
_dgematrix operator+ ( const dgematrix matA,
const _dgematrix matB 
) [friend]

dgematrix+_dgematrix operator

Definition at line 79 of file dgematrix-_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*matA.n; i++){ matB.array[i] +=matA.array[i]; }
  
  return matB;
}
_dgematrix operator+ ( const dgematrix matA,
const dsymatrix matB 
) [friend]

dgematrix+dsymatrix operator

Definition at line 72 of file dgematrix-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(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);
}
_dgematrix operator+ ( const dgematrix matA,
const _dsymatrix matB 
) [friend]

dgematrix+_dsymatrix operator

Definition at line 75 of file dgematrix-_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(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);
}
_dgematrix operator+ ( const dgematrix matA,
const dgbmatrix matB 
) [friend]

dgematrix+dgbmatrix operator

Definition at line 78 of file dgematrix-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
  
  dgematrix 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);
}
_dgematrix operator+ ( const dgematrix matA,
const _dgbmatrix matB 
) [friend]

dgematrix+_dgbmatrix operator

Definition at line 81 of file dgematrix-_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
  
  dgematrix 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);
}
_dgematrix operator+ ( const dgematrix matA,
const dgsmatrix matB 
) [friend]

dgematrix+dgsmatrix operator

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

dgematrix+_dgsmatrix operator

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

dgematrix-dgematrix operator

Definition at line 97 of file dgematrix-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 subtraction." << 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,matA.n);
  for(long i=0; i<newmat.m*newmat.n; i++){
    newmat.array[i] =matA.array[i]-matB.array[i];
  }
  
  return _(newmat);
}
_dgematrix operator- ( const dgematrix matA,
const _dgematrix matB 
) [friend]

dgematrix-_dgematrix operator

Definition at line 97 of file dgematrix-_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 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;
}
_dgematrix operator- ( const dgematrix matA,
const dsymatrix matB 
) [friend]

dgematrix-dsymatrix operator

Definition at line 95 of file dgematrix-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 subtraction." << 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);
  for(long i=0; i<matA.m; i++){
    for(long j=0; j<matA.n; j++){
      newmat(i,j) -= matB(i,j);
    }
  }
  
  return _(newmat);
}
_dgematrix operator- ( const dgematrix matA,
const _dsymatrix matB 
) [friend]

dgematrix-_dsymatrix operator

Definition at line 99 of file dgematrix-_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 subtraction." << 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);
  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);
}
_dgematrix operator- ( const dgematrix matA,
const dgbmatrix matB 
) [friend]

dgematrix-dgbmatrix operator

Definition at line 102 of file dgematrix-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
  
  dgematrix 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);
}
_dgematrix operator- ( const dgematrix matA,
const _dgbmatrix matB 
) [friend]

dgematrix-_dgbmatrix operator

Definition at line 106 of file dgematrix-_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
  
  dgematrix 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);
}
_dgematrix operator- ( const dgematrix matA,
const dgsmatrix matB 
) [friend]

dgematrix-dgsmatrix operator

Definition at line 23 of file dgematrix-dgsmatrix.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.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG

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

dgematrix-_dgsmatrix operator

Definition at line 25 of file dgematrix-_dgsmatrix.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.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG

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

dgematrix*dcovector operator

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

dgematrix*_dcovector operator

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

dgematrix*dgematrix operator

Definition at line 118 of file dgematrix-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 );
  dgemm_( 'n', 'n', matA.m, matB.n, matA.n, 1.0, matA.array, matA.m,
          matB.array, matB.m, 0.0, newmat.array, matA.m );
  
  return _(newmat);
}
_dgematrix operator* ( const dgematrix matA,
const _dgematrix matB 
) [friend]

dgematrix*_dgematrix operator

Definition at line 117 of file dgematrix-_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 );
  dgemm_( 'n', 'n', matA.m, matB.n, matA.n, 1.0, matA.array, matA.m,
          matB.array, matB.m, 0.0, newmat.array, matA.m );
  
  matB.destroy();
  return _(newmat);
}
_dgematrix operator* ( const dgematrix matA,
const dsymatrix matB 
) [friend]

dgematrix*dsymatrix operator

Definition at line 118 of file dgematrix-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 );
  dsymm_( 'R', 'l', newmat.m, newmat.n, 1.0, matB.array, matB.n, 
          matA.array, matA.m, 0.0, newmat.array, newmat.m );
  
  return _(newmat);
}
_dgematrix operator* ( const dgematrix matA,
const _dsymatrix matB 
) [friend]

dgematrix*_dsymatrix operator

Definition at line 123 of file dgematrix-_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 );
  dsymm_( 'R', 'l', newmat.m, newmat.n, 1.0, matB.array, matB.n, 
          matA.array, matA.m, 0.0, newmat.array, newmat.m );
  
  matB.destroy();
  return _(newmat);
}
_dgematrix operator* ( const dgematrix matA,
const dgbmatrix matB 
) [friend]

dgematrix*dgbmatrix operator

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

dgematrix*_dgbmatrix operator

Definition at line 131 of file dgematrix-_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
  
  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),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);
}
_dgematrix operator* ( const dgematrix matA,
const dgsmatrix matB 
) [friend]

dgematrix*dgsmatrix operator

Definition at line 43 of file dgematrix-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=0; i<matA.m; i++){
      newmat(i,it->j) += matA(i,it->i)*it->v;
    }
  }
  
  return _(newmat);
}
_dgematrix operator* ( const dgematrix matA,
const _dgsmatrix matB 
) [friend]

dgematrix*_dgsmatrix operator

Definition at line 47 of file dgematrix-_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=0; i<matA.m; i++){
      newmat(i,it->j) += matA(i,it->i)*it->v;
    }
  }
  
  matB.destroy();
  return _(newmat);
}
_dgematrix operator* ( const dgematrix ,
const dssmatrix  
) [friend]
_dgematrix operator* ( const dgematrix ,
const _dssmatrix  
) [friend]
_dgematrix operator* ( const dgematrix mat,
const double &  d 
) [friend]

dgematrix*double operator

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

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

dgematrix/double operator

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

{VERBOSE_REPORT;
  dgematrix newmat(mat.m, mat.n);
  for(long i=0; i<mat.m*mat.n; i++){ newmat.array[i] =mat.array[i]/d; }
  
  return _(newmat);
}
_drovector operator% ( const dgematrix matA,
const dgematrix matB 
) [friend]

dgematrixdgematrix operator

Definition at line 138 of file dgematrix-dgematrix.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 product." << std::endl
              << "Your input was (" << matA.m << "x" << matA.n << ") % (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  drovector newvec( matA.n );
  newvec.zero();
  for(long j=0; j<matA.n; j++){
    for(long i=0; i<matA.m; i++){
      newvec(j) +=matA(i,j)*matB(i,j);
    }
  }
  
  return _(newvec);
}
_dgematrix operator* ( const double &  d,
const dgematrix mat 
) [friend]

double*dgematrix operator

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

{VERBOSE_REPORT;
  dgematrix 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 dgematrix.hpp.

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


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