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

Real Double-precision Symmetric Matrix Class [l-type (UPLO=l) Strage]. More...

#include <dsymatrix.hpp>

List of all members.

Public Member Functions

 dsymatrix ()
 dsymatrix (const dsymatrix &)
 dsymatrix (const _dsymatrix &)
 dsymatrix (const long &)
 dsymatrix (const char *)
 ~dsymatrix ()
_zhematrix to_zhematrix () const
_dgematrix to_dgematrix () const
_dssmatrix to_dssmatrix (const double eps=-1) const
double & operator() (const long &, const long &)
double operator() (const long &, const long &) const
dsymatrixset (const long &, const long &, const double &)
void write (const char *) const
void read (const char *)
void complete () const
void clear ()
dsymatrixzero ()
dsymatrixidentity ()
void chsign ()
void copy (const dsymatrix &)
void shallow_copy (const _dsymatrix &)
dsymatrixresize (const long &)
_drovector row (const long &) const
_dcovector col (const long &) const
long dsysv (dgematrix &)
long dsysv (dcovector &)
long dsyev (std::vector< double > &, const bool &)
long dsyev (std::vector< double > &, std::vector< dcovector > &)
long dsyev (std::vector< double > &, std::vector< drovector > &)
long dsygv (dsymatrix &, std::vector< double > &)
long dsygv (dsymatrix &, std::vector< double > &, std::vector< dcovector > &)
dsymatrixoperator= (const dsymatrix &)
dsymatrixoperator= (const _dsymatrix &)
dsymatrixoperator+= (const dsymatrix &)
dsymatrixoperator+= (const _dsymatrix &)
dsymatrixoperator-= (const dsymatrix &)
dsymatrixoperator-= (const _dsymatrix &)
dsymatrixoperator*= (const dsymatrix &)
dsymatrixoperator*= (const _dsymatrix &)
dsymatrixoperator*= (const double &)
dsymatrixoperator/= (const double &)

Public Attributes

long const & 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 dsymatrix &)
void swap (dsymatrix &, dsymatrix &)
_dsymatrix _ (dsymatrix &)
_dsymatrix t (const dsymatrix &)
_dsymatrix i (const dsymatrix &)
void idamax (long &, long &, const dsymatrix &)
double damax (const dsymatrix &)
const dsymatrixoperator+ (const dsymatrix &)
_dsymatrix operator- (const dsymatrix &)
_dgematrix operator+ (const dsymatrix &, const dgematrix &)
_dgematrix operator+ (const dsymatrix &, const _dgematrix &)
_dsymatrix operator+ (const dsymatrix &, const dsymatrix &)
_dsymatrix operator+ (const dsymatrix &, const _dsymatrix &)
_dgematrix operator+ (const dsymatrix &, const dgbmatrix &)
_dgematrix operator+ (const dsymatrix &, const _dgbmatrix &)
_dgematrix operator+ (const dsymatrix &, const dgsmatrix &)
_dgematrix operator+ (const dsymatrix &, const _dgsmatrix &)
_dsymatrix operator+ (const dsymatrix &, const dssmatrix &)
_dsymatrix operator+ (const dsymatrix &, const _dssmatrix &)
_dgematrix operator- (const dsymatrix &, const dgematrix &)
_dgematrix operator- (const dsymatrix &, const _dgematrix &)
_dsymatrix operator- (const dsymatrix &, const dsymatrix &)
_dsymatrix operator- (const dsymatrix &, const _dsymatrix &)
_dgematrix operator- (const dsymatrix &, const dgbmatrix &)
_dgematrix operator- (const dsymatrix &, const _dgbmatrix &)
_dgematrix operator- (const dsymatrix &, const dgsmatrix &)
_dgematrix operator- (const dsymatrix &, const _dgsmatrix &)
_dsymatrix operator- (const dsymatrix &, const dssmatrix &)
_dsymatrix operator- (const dsymatrix &, const _dssmatrix &)
_dcovector operator* (const dsymatrix &, const dcovector &)
_dcovector operator* (const dsymatrix &, const _dcovector &)
_dgematrix operator* (const dsymatrix &, const dgematrix &)
_dgematrix operator* (const dsymatrix &, const _dgematrix &)
_dgematrix operator* (const dsymatrix &, const dsymatrix &)
_dgematrix operator* (const dsymatrix &, const _dsymatrix &)
_dgematrix operator* (const dsymatrix &, const dgbmatrix &)
_dgematrix operator* (const dsymatrix &, const _dgbmatrix &)
_dgematrix operator* (const dsymatrix &, const dgsmatrix &)
_dgematrix operator* (const dsymatrix &, const _dgsmatrix &)
_dsymatrix operator* (const dsymatrix &, const dssmatrix &)
_dsymatrix operator* (const dsymatrix &, const _dssmatrix &)
_dsymatrix operator* (const dsymatrix &, const double &)
_dsymatrix operator/ (const dsymatrix &, const double &)
_dsymatrix operator* (const double &, const dsymatrix &)

Detailed Description

Real Double-precision Symmetric Matrix Class [l-type (UPLO=l) Strage].

Definition at line 3 of file dsymatrix.hpp.


Constructor & Destructor Documentation

dsymatrix::dsymatrix ( ) [inline]

dsymatrix constructor without arguments

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

References array, darray, and n.

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

dsymatrix copy constructor

Definition at line 14 of file dsymatrix-constructor.hpp.

References array, darray, i, and n.

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

dsymatrix constructor to cast _dsymatrix

Definition at line 29 of file dsymatrix-constructor.hpp.

References array, _dsymatrix::array, darray, _dsymatrix::darray, _dsymatrix::n, n, and _dsymatrix::nullify().

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

dsymatrix copy constructor to cast dssmatrix

dsymatrix constructor to cast _dssmatrix

dsymatrix constructor with size specification

Definition at line 83 of file dsymatrix-constructor.hpp.

References array, darray, i, and n.

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

dsymatrix constructor with filename

Definition at line 104 of file dsymatrix-constructor.hpp.

References array, darray, and read().

  : m(n)
{VERBOSE_REPORT;
  array =NULL;
  darray =NULL;
  
  //// copy ////
  read(filename);
}
dsymatrix::~dsymatrix ( ) [inline]

dsymatrix destructor

Definition at line 120 of file dsymatrix-constructor.hpp.

References array, and darray.

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

Member Function Documentation

_zhematrix dsymatrix::to_zhematrix ( ) const [inline]

cast to _zhematrix

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

References _, i, and n.

{VERBOSE_REPORT;
  zhematrix newmat(n);
  for(long i=0; i<n; i++){
    for(long j=0; j<=i; j++){
      newmat(i,j) =comple((*this)(i,j),0.0);
    }
  }
  
  return _(newmat);
}
_dgematrix dsymatrix::to_dgematrix ( ) const [inline]

convert to _dgematrix

Definition at line 21 of file dsymatrix-cast.hpp.

References _, i, and n.

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

{VERBOSE_REPORT;
  dgematrix newmat(n,n);
  for(long i=0; i<n; i++){
    for(long j=0; j<n; j++){
      newmat(i,j) =(*this)(i,j);
    }
  }
  
  return _(newmat);
}
_dssmatrix dsymatrix::to_dssmatrix ( const double  eps = -1) const [inline]

convert to _dssmatrix

Definition at line 35 of file dsymatrix-cast.hpp.

References _, i, and n.

{VERBOSE_REPORT;
  dssmatrix newmat(n);
  for(long i=0; i<n; i++){
    for(long j=0; j<=i; j++){
      if( fabs((*this)(i,j))>eps ){ newmat(i,j) =(*this)(i,j); }
    }
  }
  
  return _(newmat);
}
double & dsymatrix::operator() ( const long &  i,
const long &  j 
) [inline]

operator() for non-const object

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

References darray, i, and n.

Referenced by identity(), read(), and write().

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

operator() for const object

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

References darray, i, and n.

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

set value for const object

Definition at line 51 of file dsymatrix-io.hpp.

References darray, i, and n.

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

Definition at line 96 of file dsymatrix-io.hpp.

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

Definition at line 116 of file dsymatrix-io.hpp.

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

Referenced by dsymatrix().

{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 != "dsymatrix" && id != "#dsymatrix" ){
    ERROR_REPORT;
    std::cerr << "The type name of the file \"" << filename << "\" is not dsymatrix." << std::endl
              << "Its type name was " << id << " ." << std::endl;
    exit(1);
  }
  
  s >> n;
  resize(n);
  for(long i=0; i<n; i++){
    for(long j=0; j<=i; j++ ){
      s >> operator()(i,j);
    }
  }
  if(s.eof()){
    ERROR_REPORT;
    std::cerr << "There is something is wrong with the file \"" << filename << " ." << std::endl
              << "Most likely, there is 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 dsymatrix::complete ( ) const [inline]

complete the upper-right components

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

References darray, i, and n.

Referenced by operator*().

{VERBOSE_REPORT;
  for(long i=0; i<n; i++){
    for(long j=0; j<i; j++){
      darray[i][j] =darray[j][i];
    }
  }
}
void dsymatrix::clear ( ) [inline]

clear all the matrix data and set the sizes 0

Definition at line 14 of file dsymatrix-misc.hpp.

References array, darray, and n.

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

change the matrix into a zero matrix

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

References array, i, and n.

Referenced by _dssmatrix::to_dsymatrix(), and dssmatrix::to_dsymatrix().

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

change the matrix into an identity matrix

Definition at line 35 of file dsymatrix-misc.hpp.

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

Referenced by i().

{VERBOSE_REPORT;
  for(long i=0; i<n*n; i++){ array[i] =0.0; }
  for(long i=0; i<n; i++){ operator()(i,i) =1.0; }
  return *this;
}
void dsymatrix::chsign ( ) [inline]

change sign(+/-) of the matrix

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

References array, i, and n.

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

make a deep copy of the matrix

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

References array, darray, i, and n.

Referenced by operator=().

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

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

Definition at line 66 of file dsymatrix-misc.hpp.

References array, _dsymatrix::array, darray, _dsymatrix::darray, _dsymatrix::n, n, and _dsymatrix::nullify().

Referenced by operator=().

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

resize the matrix

Definition at line 79 of file dsymatrix-misc.hpp.

References array, darray, i, and n.

Referenced by read().

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

get row of the matrix

Definition at line 106 of file dsymatrix-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 dsymatrix::col ( const long &  _n) const [inline]

get column of the matrix

Definition at line 124 of file dsymatrix-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 dsymatrix::dsysv ( dgematrix mat) [inline]

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

Definition at line 6 of file dsymatrix-lapack.hpp.

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

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(n!=mat.n){
    ERROR_REPORT;
    std::cerr << "These two matrices cannot be solved." << std::endl
              << "Your input was (" << n << "x" << n << ") and (" << mat.n << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  char UPLO('l');
  long NRHS(mat.n), LDA(n), *IPIV(new long[n]), LDB(mat.m), LWORK(-1), INFO(1);
  double *WORK( new double[1] );
  dsysv_(UPLO, n, NRHS, array, LDA, IPIV, mat.array, LDB, WORK, LWORK, INFO);
  
  INFO=1; 
  LWORK = long(WORK[0]);
  delete [] WORK;  WORK = new double[LWORK];
  dsysv_(UPLO, n, NRHS, array, LDA, IPIV, mat.array, LDB, WORK, LWORK, INFO);
  delete [] WORK; delete [] IPIV;
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long dsymatrix::dsysv ( dcovector vec) [inline]

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

Definition at line 40 of file dsymatrix-lapack.hpp.

References array, dcovector::array, dcovector::l, and n.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(n!=vec.l){
    ERROR_REPORT;
    std::cerr << "These matrix and vector cannot be solved." << std::endl
              << "Your input was (" << n << "x" << n << ") and (" << vec.l << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG 
  
  char UPLO('l');
  long NRHS(1), LDA(n), *IPIV(new long[n]), LDB(vec.l), LWORK(-1), INFO(1);
  double *WORK( new double[1] );
  dsysv_(UPLO, n, NRHS, array, LDA, IPIV, vec.array, LDB, WORK, LWORK, INFO);
  
  INFO=1;
  LWORK = long(WORK[0]);
  delete [] WORK;
  WORK = new double[LWORK];
  dsysv_(UPLO, n, NRHS, array, LDA, IPIV, vec.array, LDB, WORK, LWORK, INFO);
  delete [] WORK;
  delete [] IPIV;

  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long dsymatrix::dsyev ( std::vector< double > &  w,
const bool &  jobz = 0 
) [inline]

calculate eigenvalues and eigenvectors.
All of the arguments need not to be initialized. w is overwitten and become eigenvalues. This matrix is also overwritten. if jobz=1, this matrix becomes eigenvectors.

Definition at line 82 of file dsymatrix-lapack.hpp.

References array, and n.

{VERBOSE_REPORT;
  w.resize(n);
  char JOBZ, UPLO('l');
  if(jobz==0){ JOBZ='n'; } else{ JOBZ='V'; }
  long LDA(n), INFO(1), LWORK(-1);
  double *WORK(new double[1]);
  dsyev_(JOBZ, UPLO, n, array, LDA, &w[0], WORK, LWORK, INFO);
  
  INFO=1;
  LWORK = long(WORK[0]);
  delete [] WORK;  WORK = new double[LWORK];
  dsyev_(JOBZ, UPLO, n, array, LDA, &w[0], WORK, LWORK, INFO);
  delete [] WORK;
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long dsymatrix::dsyev ( std::vector< double > &  w,
std::vector< dcovector > &  v 
) [inline]

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

Definition at line 111 of file dsymatrix-lapack.hpp.

References array, i, and n.

{VERBOSE_REPORT;
  w.resize(n);  v.resize(n);
  for(long i=0; i<n; i++){ v[i].resize(n); }
  char JOBZ('V'), UPLO('l');
  long LDA(n), INFO(1), LWORK(-1);
  double *WORK(new double[1]);
  dsyev_(JOBZ, UPLO, n, array, LDA, &w[0], WORK, LWORK, INFO);
  
  INFO=1;
  LWORK = long(WORK[0]);
  delete [] WORK;  WORK = new double[LWORK];
  dsyev_(JOBZ, UPLO, n, array, LDA, &w[0], WORK, LWORK, INFO);
  delete [] WORK;
  
  //// forming ////
  for(long i=0; i<n; i++){ for(long j=0; j<n; j++){
    v[j](i) = array[i+n*j];
  }}
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long dsymatrix::dsyev ( std::vector< double > &  w,
std::vector< drovector > &  v 
) [inline]

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

Definition at line 145 of file dsymatrix-lapack.hpp.

References array, i, and n.

{VERBOSE_REPORT;
  w.resize(n);  v.resize(n);
  for(long i=0; i<n; i++){ v[i].resize(n); }
  char JOBZ('V'), UPLO('l');
  long LDA(n), INFO(1), LWORK(-1);
  double *WORK(new double[1]);
  dsyev_(JOBZ, UPLO, n, array, LDA, &w[0], WORK, LWORK, INFO);
  
  INFO=1;
  LWORK = long(WORK[0]);
  delete [] WORK;  WORK = new double[LWORK];
  dsyev_(JOBZ, UPLO, n, array, LDA, &w[0], WORK, LWORK, INFO);
  delete [] WORK;
  
  //// forming ////
  for(long i=0; i<n; i++){ for(long j=0; j<n; j++){
    v[j](i) = array[i+n*j];
  }}
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long dsymatrix::dsygv ( dsymatrix matB,
std::vector< double > &  w 
) [inline]

calculate generalized eigenvalues
w is overwitten and become generalized eigenvalues. This matrix and matB are also overwritten.

Definition at line 181 of file dsymatrix-lapack.hpp.

References array, and n.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matB.n!=n){
    ERROR_REPORT;
    std::cerr << "The matrix B is not a matrix having the same size as \"this\" matrix." << std::endl
              << "The B matrix is (" << matB.n << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  w.resize(n);
  char JOBZ('n'), UPLO('l');
  long ITYPE(1), LDA(n), LDB(n), LWORK(-1), INFO(1);
  double *WORK(new double[1]);
  dsygv_(ITYPE, JOBZ, UPLO, n, array, LDA, matB.array, LDB, &w[0],
         WORK, LWORK, INFO);
  INFO=1;
  LWORK = long(WORK[0]);
  delete [] WORK;  WORK = new double[LWORK];
  dsygv_(ITYPE, JOBZ, UPLO, n, array, LDA, matB.array, LDB, &w[0],
         WORK, LWORK, INFO);
  delete [] WORK;
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
long dsymatrix::dsygv ( dsymatrix matB,
std::vector< double > &  w,
std::vector< dcovector > &  v 
) [inline]

calculate generalized eigenvalues
w is overwitten and become generalized eigenvalues. This matrix and matB are also overwritten.

Definition at line 217 of file dsymatrix-lapack.hpp.

References array, darray, i, and n.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matB.n!=n){
    ERROR_REPORT;
    std::cerr << "The matrix B is not a matrix having the same size as \"this\" matrix." << std::endl
              << "The B matrix is (" << matB.n << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  w.resize(n);
  v.resize(n);
  char JOBZ('V'), UPLO('l');
  long ITYPE(1), LDA(n), LDB(n), LWORK(-1), INFO(1);
  double *WORK(new double[1]);
  dsygv_(ITYPE, JOBZ, UPLO, n, array, LDA, matB.array, LDB, &w[0],
         WORK, LWORK, INFO);
  INFO=1;
  LWORK = long(WORK[0]);
  std::cout << " LWORK = "  << LWORK  <<std::endl;
  delete [] WORK;  WORK = new double[LWORK];
  dsygv_(ITYPE, JOBZ, UPLO, n, array, LDA, matB.array, LDB, &w[0],
         WORK, LWORK, INFO);
  delete [] WORK;
  
  //// reforming ////
  for(int i=0; i<n; i++){
    v[i].resize(n);
    for(int j=0; j<n; j++){
      v[i](j) =darray[i][j];
    }
  }
  
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  return INFO;
}
dsymatrix & dsymatrix::operator= ( const dsymatrix mat) [inline]

dsymatrix=dsymatrix operator

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

References array, and copy().

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

dsymatrix=_dsymatrix operator

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

References shallow_copy().

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

dsymatrix+=dsymatrix operator

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

References darray, i, and n.

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

dsymatrix+=_dsymatrix operator

Definition at line 15 of file dsymatrix-_dsymatrix.hpp.

References darray, _dsymatrix::darray, _dsymatrix::destroy(), i, n, and _dsymatrix::n.

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

dsymatrix operator-=

Definition at line 39 of file dsymatrix-dsymatrix.hpp.

References darray, i, and n.

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

dsymatrix-=_dsymatrix operator

Definition at line 38 of file dsymatrix-_dsymatrix.hpp.

References darray, _dsymatrix::darray, _dsymatrix::destroy(), i, n, and _dsymatrix::n.

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

dsymatrix*=double operator

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

References darray, i, and n.

{VERBOSE_REPORT;
  for(long i=0; i<n; i++){
    for(long j=0; j<=i; j++){
      darray[j][i] *=d;
    }
  }
  
  return *this;
}
dsymatrix & dsymatrix::operator/= ( const double &  d) [inline]

dsymatrix/=double operator

Definition at line 16 of file dsymatrix-double.hpp.

References darray, i, and n.

{VERBOSE_REPORT;
  for(long i=0; i<n; i++){
    for(long j=0; j<=i; j++){
      darray[j][i] /=d;
    }
  }
  return *this;
}

Friends And Related Function Documentation

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

Definition at line 77 of file dsymatrix-io.hpp.

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

swap two matrices

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

{VERBOSE_REPORT;
  long A_n(A.n);
  double* A_array(A.array);
  //double** A_darray(A.darray);
  double** A_darray=A.darray; //corruption to support VC++
  A.n=B.n; A.array=B.array; A.darray=B.darray;
  B.n=A_n; B.array=A_array; B.darray=A_darray;
}
_dsymatrix _ ( dsymatrix mat) [friend]

convert user object to smart-temporary object

Definition at line 158 of file dsymatrix-misc.hpp.

Referenced by col(), row(), to_dgematrix(), to_dssmatrix(), and to_zhematrix().

{VERBOSE_REPORT;
  _dsymatrix newmat;

  //////// shallow copy ////////
  newmat.n =mat.n;
  newmat.array =mat.array;
  newmat.darray =mat.darray;
  
  //////// nullify ////////
  mat.n =0;
  mat.array =NULL;
  mat.darray =NULL;
  
  return newmat;
}
_dsymatrix t ( const dsymatrix mat) [friend]

return transposed dgematrix

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

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  WARNING_REPORT;
  std::cerr << "This function call has no effect since the matrix is symmetric." << std::endl;
#endif//CPPL_DEBUG
  
  dsymatrix newmat(mat);
  return _(newmat);
}
_dsymatrix i ( const dsymatrix mat) [friend]

return its inverse matrix

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

Referenced by chsign(), col(), complete(), copy(), dsyev(), dsygv(), dsymatrix(), identity(), operator()(), operator*=(), operator+=(), operator-=(), operator/=(), read(), resize(), set(), to_dgematrix(), to_dssmatrix(), to_zhematrix(), write(), and zero().

{VERBOSE_REPORT;
  dsymatrix mat_cp(mat);
  dsymatrix mat_inv(mat.n);
  mat_inv.identity();
  
  char UPLO('l');
  long NRHS(mat.n), LDA(mat.n), *IPIV(new long[mat.n]), LDB(mat.n), LWORK(-1), INFO(1);
  double *WORK( new double[1] );
  dsysv_(UPLO, mat.n, NRHS, mat_cp.array, LDA, IPIV, mat_inv.array, LDB, WORK, LWORK, INFO);
  LWORK = long(WORK[0]);
  delete [] WORK;  WORK = new double[LWORK];
  dsysv_(UPLO, mat.n, NRHS, mat_cp.array, LDA, IPIV, mat_inv.array, LDB, WORK, LWORK, INFO);
  delete [] WORK; delete [] IPIV;
  if(INFO!=0){
    WARNING_REPORT;
    std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
  }
  
  return _(mat_inv);
}
void idamax ( long &  i,
long &  j,
const dsymatrix mat 
) [friend]

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

Definition at line 46 of file dsymatrix-calc.hpp.

{VERBOSE_REPORT;
  i=j=0;
  double val(0.);
  for(long J=0; J<mat.n; J++){
    long I( J +idamax_(mat.m-J, mat.darray[J]+J, 1) -1 );
    if( val<fabs(mat.darray[J][I]) ){
      val =fabs(mat.darray[J][I]);
      i=I;
      j=J;
    }
  }
}
double damax ( const dsymatrix mat) [friend]

return its largest absolute value

Definition at line 62 of file dsymatrix-calc.hpp.

{VERBOSE_REPORT;
  long i,j;
  idamax(i, j, mat);
  return mat(i,j);
}
const dsymatrix& operator+ ( const dsymatrix mat) [friend]

+dsymatrix operator

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

{VERBOSE_REPORT;
  return mat;
}
_dsymatrix operator- ( const dsymatrix mat) [friend]

-dsymatrix operator

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

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

dsymatrix+dgematrix operator

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

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

  dgematrix newmat(matB);
  for(long i=0; i<matA.n; i++) {
    for(long j=0; j<matA.n; j++) {
      newmat(i,j)+=matA(i,j);
    }
  }
  
  return _(newmat);
}
_dgematrix operator+ ( const dsymatrix matA,
const _dgematrix matB 
) [friend]

_dgematrix+dsymatrix operator

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

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

dsymatrix+dsymatrix operator

Definition at line 61 of file dsymatrix-dsymatrix.hpp.

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

  long n = matA.n;
  dsymatrix newmat(n);
  for(long i=0; i<n; i++){
    for(long j=0; j<=i; j++){
      newmat.darray[j][i] =matA.darray[j][i] +matB.darray[j][i];
    }
  }
  
  return _(newmat);
}
_dsymatrix operator+ ( const dsymatrix matA,
const _dsymatrix matB 
) [friend]

dsymatrix+_dsymatrix operator

Definition at line 65 of file dsymatrix-_dsymatrix.hpp.

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

  for(long i=0; i<matA.n; i++){
    for(long j=0; j<=i; j++){
      matB.darray[j][i] +=matA.darray[j][i];
    }
  }
  
  return matB;
}
_dgematrix operator+ ( const dsymatrix matA,
const dgbmatrix matB 
) [friend]

dsymatrix+dgbmatrix operator

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

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.n!=matB.n || matA.n!=matB.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a summation." << std::endl
              << "Your input was (" << matA.n << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  dgematrix newmat(matA.n, matA.n);
  for(long i=0; i<matB.m; i++){
    for(long j=i; j<matA.n; j++){
      newmat(i,j) = newmat(j,i) = 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);
}
_dgematrix operator+ ( const dsymatrix matA,
const _dgbmatrix matB 
) [friend]

dsymatrix+_dgbmatrix operator

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

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.n!=matB.n || matA.n!=matB.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a summation." << std::endl
              << "Your input was (" << matA.n << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  dgematrix newmat(matA.n, matA.n);
  for(long i=0; i<matB.m; i++){
    for(long j=i; j<matA.n; j++){
      newmat(i,j) = newmat(j,i) = 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 dsymatrix matA,
const dgsmatrix matB 
) [friend]

dsymatrix+dgsmatrix operator

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

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.n!=matB.m || matA.n!=matB.n){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a summation." << std::endl
              << "Your input was (" << matA.n << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  dgematrix newmat( matA.to_dgematrix() );
  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 dsymatrix matA,
const _dgsmatrix matB 
) [friend]

dsymatrix+_dgsmatrix operator

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

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.n!=matB.m || matA.n!=matB.n){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a summation." << std::endl
              << "Your input was (" << matA.n << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  dgematrix newmat( matA.to_dgematrix() );
  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);
}
_dsymatrix operator+ ( const dsymatrix ,
const dssmatrix  
) [friend]
_dsymatrix operator+ ( const dsymatrix ,
const _dssmatrix  
) [friend]
_dgematrix operator- ( const dsymatrix matA,
const dgematrix matB 
) [friend]

dsymatrix-dgematrix operator

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

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

_dgematrix-dgematrix operator

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

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

  for(long i=0; i<matA.n; i++){
    for(long j=0; j<matA.n; j++){
      matB(i,j) =matA(i,j)-matB(i,j);
    }
  }
  
  return matB;
}
_dsymatrix operator- ( const dsymatrix matA,
const dsymatrix matB 
) [friend]

dsymatrix-dsymatrix operator

Definition at line 85 of file dsymatrix-dsymatrix.hpp.

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

  long n = matA.n;
  dsymatrix newmat(n);
  for(long i=0; i<n; i++){
    for(long j=0; j<=i; j++){
      newmat.darray[j][i] =matA.darray[j][i] -matB.darray[j][i];
    }
  }

  return _(newmat);
}
_dsymatrix operator- ( const dsymatrix matA,
const _dsymatrix matB 
) [friend]

dsymatrix-_dsymatrix operator

Definition at line 87 of file dsymatrix-_dsymatrix.hpp.

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

  for(long i=0; i<matA.n; i++){
    for(long j=0; j<=i; j++){
      matB.darray[j][i] =matA.darray[j][i] -matB.darray[j][i];
    }
  }
  
  return matB;
}
_dgematrix operator- ( const dsymatrix matA,
const dgbmatrix matB 
) [friend]

dsymatrix-dgbmatrix operator

Definition at line 29 of file dsymatrix-dgbmatrix.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.n!=matB.n || matA.n!=matB.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a summation." << std::endl
              << "Your input was (" << matA.n << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  dgematrix newmat(matA.n, matA.n);
  for(long i=0; i<matB.m; i++){
    for(long j=i; j<matA.n; j++){
      newmat(i,j) = newmat(j,i) = 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);
}
_dgematrix operator- ( const dsymatrix matA,
const _dgbmatrix matB 
) [friend]

dsymatrix-_dgbmatrix operator

Definition at line 30 of file dsymatrix-_dgbmatrix.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.n!=matB.n || matA.n!=matB.m){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a summation." << std::endl
              << "Your input was (" << matA.n << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  dgematrix newmat(matA.n, matA.n);
  for(long i=0; i<matB.m; i++){
    for(long j=i; j<matA.n; j++){
      newmat(i,j) = newmat(j,i) = 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 dsymatrix matA,
const dgsmatrix matB 
) [friend]

dsymatrix-dgsmatrix operator

Definition at line 24 of file dsymatrix-dgsmatrix.hpp.

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

  dgematrix newmat( matA.to_dgematrix() );
  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 dsymatrix matA,
const _dgsmatrix matB 
) [friend]

dsymatrix-_dgsmatrix operator

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

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

  dgematrix newmat( matA.to_dgematrix() );
  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);
}
_dsymatrix operator- ( const dsymatrix ,
const dssmatrix  
) [friend]
_dsymatrix operator- ( const dsymatrix ,
const _dssmatrix  
) [friend]
_dcovector operator* ( const dsymatrix mat,
const dcovector vec 
) [friend]

dsymatrix*dcovector operator

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

dsymatrix*_dcovector operator

Definition at line 3 of file dsymatrix-_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.n << "x" << mat.n << ") * (" << vec.l << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  dcovector newvec(mat.n);
  dsymv_( 'l', mat.n, 1.0, mat.array, mat.n,
          vec.array, 1, 0.0, newvec.array, 1 );
  
  vec.destroy();
  return _(newvec);
}
_dgematrix operator* ( const dsymatrix matA,
const dgematrix matB 
) [friend]

dsymatrix*dgematrix operator

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

  dgematrix newmat( matA.n, matB.n );
  dsymm_( 'l', 'l', matA.n, matB.n, 1.0, matA.array, matA.n,
          matB.array, matB.m, 0.0, newmat.array, newmat.m );
  
  return _(newmat);
}
_dgematrix operator* ( const dsymatrix matA,
const _dgematrix matB 
) [friend]

_dgematrix*dgematrix operator

Definition at line 47 of file dsymatrix-_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.n << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  dgematrix newmat( matA.n, matB.n );
  dsymm_( 'l', 'l', matA.n, matB.n, 1.0, matA.array, matA.n, 
          matB.array, matB.m, 0.0, newmat.array, newmat.m );
  
  matB.destroy();
  return _(newmat);
}
_dgematrix operator* ( const dsymatrix matA,
const dsymatrix matB 
) [friend]

dsymatrix*dsymatrix operator

Definition at line 109 of file dsymatrix-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.n << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  matA.complete();
  matB.complete();
  dgematrix newmat(matA.n, matA.n);
  
  dgemm_( 'n', 'n', matA.n, matB.n, matA.n, 1.0, matA.array, matA.n,
          matB.array, matB.n, 0.0, newmat.array, matA.n );
  
  return _(newmat);
}
_dgematrix operator* ( const dsymatrix matA,
const _dsymatrix matB 
) [friend]

dsymatrix*_dsymatrix operator

Definition at line 109 of file dsymatrix-_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.n << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  matA.complete();
  matB.complete();  
  dgematrix newmat( matA.n, matA.n );
  
  dgemm_( 'n', 'n', matA.n, matB.n, matA.n, 1.0, matA.array, matA.n,
          matB.array, matB.n, 0.0, newmat.array, matA.n );
  
  matB.destroy();
  return _(newmat);
}
_dgematrix operator* ( const dsymatrix matA,
const dgbmatrix matB 
) [friend]

dsymatrix*dgbmatrix operator

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

  dgematrix newmat( matA.n, 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 dsymatrix matA,
const _dgbmatrix matB 
) [friend]

dsymatrix*_dgbmatrix operator

Definition at line 57 of file dsymatrix-_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.n << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  dgematrix newmat( matA.n, 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 dsymatrix matA,
const dgsmatrix matB 
) [friend]

dsymatrix*dgsmatrix operator

Definition at line 45 of file dsymatrix-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.n << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  dgematrix newmat(matA.n, 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.n; i++){
      newmat(i,it->j) += matB(i,it->i)*it->v;
    }
  }
  
  return _(newmat);
}
_dgematrix operator* ( const dsymatrix matA,
const _dgsmatrix matB 
) [friend]

dsymatrix*_dgsmatrix operator

Definition at line 47 of file dsymatrix-_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.n << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  dgematrix newmat(matA.n, 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.n; i++){
      newmat(i,it->j) += matB(i,it->i)*it->v;
    }
  }
  
  matB.destroy();
  return _(newmat);
}
_dsymatrix operator* ( const dsymatrix ,
const dssmatrix  
) [friend]
_dsymatrix operator* ( const dsymatrix ,
const _dssmatrix  
) [friend]
_dsymatrix operator* ( const dsymatrix mat,
const double &  d 
) [friend]

dsymatrix*double operator

Definition at line 32 of file dsymatrix-double.hpp.

{VERBOSE_REPORT;
  dsymatrix newmat(mat.n);
  for(long i=0; i<mat.n; i++){
    for(long j=0; j<=i; j++){
      newmat.darray[j][i] =mat.darray[j][i]*d;
    }
  }
  
  return _(newmat);
}
_dsymatrix operator/ ( const dsymatrix mat,
const double &  d 
) [friend]

dsymatrix/double operator

Definition at line 46 of file dsymatrix-double.hpp.

{VERBOSE_REPORT;
  dsymatrix newmat(mat.n);
  for(long i=0; i<mat.n; i++){
    for(long j=0; j<=i; j++){
      newmat.darray[j][i] =mat.darray[j][i]/d;
    }
  }
  
  return _(newmat);
}
_dsymatrix operator* ( const double &  d,
const dsymatrix mat 
) [friend]

double*dsymatrix operator

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

{VERBOSE_REPORT;
  dsymatrix newmat(mat.n);
  for(long i=0; i<mat.n; i++){
    for(long j=0; j<=i; j++){
      newmat.darray[j][i] =d*mat.darray[j][i];
    }
  }
  return _(newmat);
}

Member Data Documentation

long const& dsymatrix::m

matrix row size

Definition at line 9 of file dsymatrix.hpp.

Referenced by col(), dsymatrix_small< n >::dsymatrix_small(), idamax(), and row().


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