CPPLapack
|
Complex Double-precision Hermitian Matrix Class [l-type (UPLO=l) Strage]. More...
#include <zhematrix.hpp>
Complex Double-precision Hermitian Matrix Class [l-type (UPLO=l) Strage].
The imaginary part of every diagonal component is not referenced.
Definition at line 4 of file zhematrix.hpp.
zhematrix::zhematrix | ( | ) | [inline] |
zhematrix::zhematrix | ( | const zhematrix & | mat | ) | [inline] |
zhematrix copy constructor
Definition at line 18 of file zhematrix-constructor.hpp.
zhematrix::zhematrix | ( | const _zhematrix & | mat | ) | [inline] |
zhematrix constructor to cast _zhematrix
Definition at line 33 of file zhematrix-constructor.hpp.
References _zhematrix::array, array, _zhematrix::darray, darray, _zhematrix::n, n, and _zhematrix::nullify().
zhematrix::zhematrix | ( | const long & | _n | ) | [inline] |
zhematrix constructor with size specification
Definition at line 49 of file zhematrix-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 comple[n*n]; darray =new comple*[n]; for(int i=0; i<n; i++){ darray[i] =&array[i*n]; } }
zhematrix::zhematrix | ( | const char * | filename | ) | [inline] |
zhematrix::~zhematrix | ( | ) | [inline] |
_zgematrix zhematrix::to_zgematrix | ( | ) | const [inline] |
zhecomplex zhematrix::operator() | ( | const long & | i, |
const long & | j | ||
) | [inline] |
operator() for non-const object
Definition at line 3 of file zhematrix-io.hpp.
Referenced by operator+=(), operator-=(), 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 zhecomplex(i,j, darray[j][i]); } else { return zhecomplex(i,j, darray[i][j]); } }
comple zhematrix::operator() | ( | const long & | i, |
const long & | j | ||
) | const [inline] |
operator() for const object
Definition at line 20 of file zhematrix-io.hpp.
References conj, 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 darray[j][i]; } else { return std::conj(darray[i][j]); } }
zhematrix & zhematrix::set | ( | const long & | i, |
const long & | j, | ||
const comple & | v | ||
) | [inline] |
set value for const object
Definition at line 41 of file zhematrix-io.hpp.
References conj, 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; } //else{ array[j+n*i] = std::conj(v); } if(i>=j){ darray[j][i] = v; } else{ darray[i][j] = std::conj(v); } return *this; }
void zhematrix::write | ( | const char * | filename | ) | const [inline] |
Definition at line 91 of file zhematrix-io.hpp.
References i, imag(), 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 << "#zhematrix" << " " << n << std::endl; for(long i=0; i<n; i++){ for(long j=0; j<=i; j++ ){ ofs << operator()(i,j) << " "; } ofs << std::endl; #ifdef CPPL_DEBUG if(std::fabs(std::imag(operator()(i,i))) > DBL_MIN){ WARNING_REPORT; std::cerr << "The " << i << "th diagonal component of the zhematrix is not a real number." << std::endl; } #endif//CPPL_DEBUG } ofs.close(); }
void zhematrix::read | ( | const char * | filename | ) | [inline] |
Definition at line 118 of file zhematrix-io.hpp.
References darray, i, n, and resize().
Referenced by zhematrix().
{VERBOSE_REPORT; std::ifstream s(filename); if(!s){ ERROR_REPORT; std::cerr << "The file \"" << filename << "\" can not be opened." << std::endl; exit(1); } std::string id; s >> id; if( id != "zhematrix" && id != "#zhematrix" ){ ERROR_REPORT; std::cerr << "The type name of the file \"" << filename << "\" is not zhematrix." << std::endl << "Its type name was " << id << " ." << std::endl; exit(1); } s >> n; resize(n); for(long i=0; i<n; i++){ for(long j=0; j<=i; j++ ){ s >> darray[j][i]; //s >> operator()(i,j); //NG } } 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 zhematrix::complete | ( | ) | const [inline] |
complete the upper-right components
Definition at line 3 of file zhematrix-misc.hpp.
References conj, darray, i, imag(), and n.
Referenced by operator*(), and operator/().
{VERBOSE_REPORT; for(long i=0; i<n; i++){ for(long j=0; j<i; j++){ darray[i][j] =std::conj(darray[j][i]); } #ifdef CPPL_DEBUG if(std::fabs(std::imag(operator()(i,i))) > DBL_MIN){ WARNING_REPORT; std::cerr << "The " << i << "th diagonal component of the zhematrix is not a real number." << std::endl; } #endif//CPPL_DEBUG } }
void zhematrix::clear | ( | ) | [inline] |
zhematrix & zhematrix::zero | ( | ) | [inline] |
change the matrix into a zero matrix
Definition at line 31 of file zhematrix-misc.hpp.
Referenced by _zhsmatrix::to_zhematrix(), and zhsmatrix::to_zhematrix().
zhematrix & zhematrix::identity | ( | ) | [inline] |
void zhematrix::chsign | ( | ) | [inline] |
void zhematrix::copy | ( | const zhematrix & | mat | ) | [inline] |
make a deep copy of the matrix
Definition at line 68 of file zhematrix-misc.hpp.
References array, darray, i, and n.
Referenced by operator=().
void zhematrix::shallow_copy | ( | const _zhematrix & | mat | ) | [inline] |
make a shallow copy of the matrix
This function is not designed to be used in project codes.
Definition at line 83 of file zhematrix-misc.hpp.
References _zhematrix::array, array, _zhematrix::darray, darray, _zhematrix::n, n, and _zhematrix::nullify().
Referenced by operator=().
void zhematrix::resize | ( | const long & | _n | ) | [inline] |
resize the matrix
Definition at line 96 of file zhematrix-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 comple[n*n]; delete [] darray; darray =new comple*[n]; for(int i=0; i<n; i++){ darray[i] =&array[i*n]; } }
_zrovector zhematrix::row | ( | const long & | _m | ) | const [inline] |
get row of the matrix
Definition at line 121 of file zhematrix-misc.hpp.
{VERBOSE_REPORT; #ifdef CPPL_DEBUG if( _m<0 || _m>m ){ ERROR_REPORT; std::cerr << "Input row number must be between 0 and " << m << "." << std::endl << "Your input was " << _m << "." << std::endl; exit(1); } #endif//CPPL_DEBUG zrovector v(n); for(long j=0; j<n; j++){ v(j)=(*this)(_m,j); } return _(v); }
_zcovector zhematrix::col | ( | const long & | _n | ) | const [inline] |
get column of the matrix
Definition at line 139 of file zhematrix-misc.hpp.
{VERBOSE_REPORT; #ifdef CPPL_DEBUG if( _n<0 || _n>n ){ ERROR_REPORT; std::cerr << "Input row number must be between 0 and " << n << "." << std::endl << "Your input was " << _n << "." << std::endl; exit(1); } #endif//CPPL_DEBUG zcovector v(m); for(long i=0; i<m; i++){ v(i)=(*this)(i,_n); } return _(v); }
long zhematrix::zhesv | ( | zgematrix & | mat | ) | [inline] |
solve A*X=Y using zhesv
The argument is dmatrix Y. Y is overwritten and become the solution X. A is also overwritten.
Definition at line 6 of file zhematrix-lapack.hpp.
References zgematrix::array, array, zgematrix::n, and n.
Referenced by i().
{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.n), LWORK(-1), INFO(1); comple *WORK(new comple[1]); zhesv_(UPLO, n, NRHS, array, LDA, IPIV, mat.array, LDB, WORK, LWORK, INFO); INFO=1; LWORK = long(std::real(WORK[0])); delete [] WORK; WORK =new comple[LWORK]; zhesv_(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 zhematrix::zhesv | ( | zcovector & | vec | ) | [inline] |
solve A*x=y using zhesv
The argument is zcovector y. y is overwritten and become the solution x. A is also overwritten.
Definition at line 40 of file zhematrix-lapack.hpp.
References zcovector::array, array, zcovector::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); comple *WORK( new comple[1] ); zhesv_(UPLO, n, NRHS, array, LDA, IPIV, vec.array, LDB, WORK, LWORK, INFO); INFO=1; LWORK = long(std::real(WORK[0])); delete [] WORK; WORK = new comple[LWORK]; zhesv_(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 zhematrix::zheev | ( | 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 80 of file zhematrix-lapack.hpp.
{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 *RWORK(new double[std::max(long(1), 3*n-2)]); comple *WORK(new comple[1]); zheev_(JOBZ, UPLO, n, array, LDA, &w[0], WORK, LWORK, RWORK, INFO); INFO=1; LWORK = long(std::real(WORK[0])); delete [] WORK; WORK = new comple[LWORK]; zheev_(JOBZ, UPLO, n, array, LDA, &w[0], WORK, LWORK, RWORK, INFO); delete [] RWORK; delete [] WORK; if(INFO!=0){ WARNING_REPORT; std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl; } return INFO; }
long zhematrix::zheev | ( | std::vector< double > & | w, |
std::vector< zcovector > & | 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 zhematrix-lapack.hpp.
{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 *RWORK(new double[std::max(long(1), 3*n-2)]); comple *WORK(new comple[1]); zheev_(JOBZ, UPLO, n, array, LDA, &w[0], WORK, LWORK, RWORK, INFO); INFO=1; LWORK = long(std::real(WORK[0])); delete [] WORK; WORK = new comple[LWORK]; zheev_(JOBZ, UPLO, n, array, LDA, &w[0], WORK, LWORK, RWORK, INFO); delete [] RWORK; 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 zhematrix::zheev | ( | std::vector< double > & | w, |
std::vector< zrovector > & | 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 147 of file zhematrix-lapack.hpp.
{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 *RWORK(new double[std::max(long(1), 3*n-2)]); comple *WORK(new comple[1]); zheev_(JOBZ, UPLO, n, array, LDA, &w[0], WORK, LWORK, RWORK, INFO); INFO=1; LWORK = long(std::real(WORK[0])); delete [] WORK; WORK = new comple[LWORK]; zheev_(JOBZ, UPLO, n, array, LDA, &w[0], WORK, LWORK, RWORK, INFO); delete [] RWORK; 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; }
zhematrix & zhematrix::operator= | ( | const _zhematrix & | mat | ) | [inline] |
zhematrix=_zhematrix operator
Definition at line 3 of file zhematrix-_zhematrix.hpp.
References shallow_copy().
{VERBOSE_REPORT; shallow_copy(mat); return *this; }
zhematrix+=zhematrix operator
Definition at line 17 of file zhematrix-zhematrix.hpp.
References i, n, and operator()().
{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++){ operator()(i,j) +=mat(i,j); }} return *this; }
zhematrix & zhematrix::operator+= | ( | const _zhematrix & | mat | ) | [inline] |
zhematrix+=_zhematrix operator
Definition at line 15 of file zhematrix-_zhematrix.hpp.
References _zhematrix::array, array, _zhematrix::destroy(), i, _zhematrix::n, 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++){ array[i+n*j]+=mat.array[i+n*j]; }} mat.destroy(); return *this; }
zhematrix operator-=
Definition at line 37 of file zhematrix-zhematrix.hpp.
References i, n, and operator()().
{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++){ operator()(i,j) -=mat(i,j); }} return *this; }
zhematrix & zhematrix::operator-= | ( | const _zhematrix & | mat | ) | [inline] |
zhematrix-=_zhematrix operator
Definition at line 36 of file zhematrix-_zhematrix.hpp.
References _zhematrix::array, array, _zhematrix::destroy(), i, _zhematrix::n, 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++){ array[i+n*j]-=mat.array[i+n*j]; }} mat.destroy(); return *this; }
zhematrix& zhematrix::operator*= | ( | const _zhematrix & | ) | [inline] |
zhematrix & zhematrix::operator*= | ( | const double & | d | ) | [inline] |
zhematrix & zhematrix::operator/= | ( | const double & | d | ) | [inline] |
std::ostream& operator<< | ( | std::ostream & | s, |
const zhematrix & | mat | ||
) | [friend] |
Definition at line 65 of file zhematrix-io.hpp.
{VERBOSE_REPORT; for(long i=0; i<mat.n; i++){ for(long j=0; j<mat.n; j++){ if(i>j){ s << " " << mat(i,j) << " "; } else if(i==j){ s << " " << std::real(mat(i,i)) << " "; } else{ s << "{" << std::conj(mat(j,i)) << "} "; } } s << std::endl; #ifdef CPPL_DEBUG if(std::fabs(std::imag(mat(i,i))) > DBL_MIN){ WARNING_REPORT; std::cerr << "The " << i << "th diagonal component of the zhematrix is not a real number." << std::endl; } #endif//CPPL_DEBUG } return s; }
swap two matrices
Definition at line 161 of file zhematrix-misc.hpp.
_zhematrix _ | ( | zhematrix & | mat | ) | [friend] |
convert user object to smart-temporary object
Definition at line 173 of file zhematrix-misc.hpp.
Referenced by col(), row(), and to_zgematrix().
_zhematrix t | ( | const zhematrix & | mat | ) | [friend] |
_zgematrix i | ( | const zhematrix & | mat | ) | [friend] |
return its inverse matrix
Definition at line 15 of file zhematrix-calc.hpp.
Referenced by chsign(), col(), complete(), copy(), identity(), operator()(), operator+=(), operator-=(), read(), resize(), set(), to_zgematrix(), write(), zero(), zheev(), and zhematrix().
_zhematrix conj | ( | const zhematrix & | mat | ) | [friend] |
_zhematrix conjt | ( | const zhematrix & | mat | ) | [friend] |
return its conjugate transposed matrix
Definition at line 46 of file zhematrix-calc.hpp.
+zhematrix operator
Definition at line 3 of file zhematrix-unary.hpp.
{VERBOSE_REPORT;
return mat;
}
_zhematrix operator- | ( | const zhematrix & | mat | ) | [friend] |
_zgematrix operator+ | ( | const zhematrix & | matA, |
const zgematrix & | matB | ||
) | [friend] |
zhematrix+zgematrix operator
Definition at line 3 of file zhematrix-zgematrix.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 zgematrix 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); }
_zgematrix operator+ | ( | const zhematrix & | matA, |
const _zgematrix & | matB | ||
) | [friend] |
_zgematrix+zhematrix operator
Definition at line 3 of file zhematrix-_zgematrix.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; }
_zhematrix operator+ | ( | const zhematrix & | matA, |
const zhematrix & | matB | ||
) | [friend] |
zhematrix+zhematrix operator
Definition at line 57 of file zhematrix-zhematrix.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; zhematrix newmat(n); for(long i=0; i<n; i++){ for(long j=0; j<=i; j++){ newmat.array[i+n*j] = matA.array[i+n*j] + matB.array[i+n*j]; }} return _(newmat); }
_zhematrix operator+ | ( | const zhematrix & | matA, |
const _zhematrix & | matB | ||
) | [friend] |
zhematrix+_zhematrix operator
Definition at line 61 of file zhematrix-_zhematrix.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.array[i+matA.n*j]+=matA.array[i+matA.n*j]; }} return matB; }
_zgematrix operator+ | ( | const zhematrix & | matA, |
const zgbmatrix & | matB | ||
) | [friend] |
zhematrix+zgbmatrix operator
Definition at line 3 of file zhematrix-zgbmatrix.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 zgematrix newmat(matA.n, matA.n); for(long i=0; i<matB.m; i++){ for(long j=0; j<matA.n; j++){ newmat(i,j) =matA(i,j); } for(long j=std::max(long(0),i-matB.kl); j<std::min(matB.n,i+matB.ku+1); j++){ newmat(i,j)+=matB(i,j); } } return _(newmat); }
_zgematrix operator+ | ( | const zhematrix & | matA, |
const _zgbmatrix & | matB | ||
) | [friend] |
zhematrix+_zgbmatrix operator
Definition at line 3 of file zhematrix-_zgbmatrix.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 zgematrix newmat(matA.n, matA.n); for(long i=0; i<matB.m; i++){ for(long j=i; j<matA.n; j++){ newmat(i,j) =matA(i,j); } for(long j=std::max(long(0),i-matB.kl); j<std::min(matB.n,i+matB.ku+1); j++){ newmat(i,j)+=matB(i,j); } } matB.destroy(); return _(newmat); }
_zgematrix operator+ | ( | const zhematrix & | , |
const zgsmatrix & | |||
) | [friend] |
_zgematrix operator+ | ( | const zhematrix & | , |
const _zgsmatrix & | |||
) | [friend] |
_zgematrix operator+ | ( | const zhematrix & | , |
const zhsmatrix & | |||
) | [friend] |
_zgematrix operator+ | ( | const zhematrix & | , |
const _zhsmatrix & | |||
) | [friend] |
_zgematrix operator- | ( | const zhematrix & | matA, |
const zgematrix & | matB | ||
) | [friend] |
zhematrix-zgematrix operator
Definition at line 24 of file zhematrix-zgematrix.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 zgematrix 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); }
_zgematrix operator- | ( | const zhematrix & | matA, |
const _zgematrix & | matB | ||
) | [friend] |
_zgematrix-zgematrix operator
Definition at line 23 of file zhematrix-_zgematrix.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; }
_zhematrix operator- | ( | const zhematrix & | matA, |
const zhematrix & | matB | ||
) | [friend] |
zhematrix-zhematrix operator
Definition at line 79 of file zhematrix-zhematrix.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; zhematrix newmat(n); for(long i=0; i<n; i++){ for(long j=0; j<=i; j++){ newmat.array[i+n*j] =matA.array[i+n*j]-matB.array[i+n*j]; }} return _(newmat); }
_zhematrix operator- | ( | const zhematrix & | matA, |
const _zhematrix & | matB | ||
) | [friend] |
zhematrix-_zhematrix operator
Definition at line 81 of file zhematrix-_zhematrix.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.array[i] =matA.array[i]-matB.array[i]; }} return matB; }
_zgematrix operator- | ( | const zhematrix & | matA, |
const zgbmatrix & | matB | ||
) | [friend] |
zhematrix-zgbmatrix operator
Definition at line 29 of file zhematrix-zgbmatrix.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 zgematrix newmat(matA.n, matA.n); for(long i=0; i<matB.m; i++){ for(long j=0; j<matA.n; j++){ newmat(i,j) =matA(i,j); } for(long j=std::max(long(0),i-matB.kl); j<std::min(matB.n,i+matB.ku+1); j++){ newmat(i,j)-=matB(i,j); } } return _(newmat); }
_zgematrix operator- | ( | const zhematrix & | matA, |
const _zgbmatrix & | matB | ||
) | [friend] |
zhematrix-_zgbmatrix operator
Definition at line 30 of file zhematrix-_zgbmatrix.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 zgematrix newmat(matA.n, matA.n); for(long i=0; i<matB.m; i++){ for(long j=i; j<matA.n; j++){ newmat(i,j) =matA(i,j); } for(long j=std::max(long(0),i-matB.kl); j<std::min(matB.n,i+matB.ku+1); j++){ newmat(i,j)-=matB(i,j); } } matB.destroy(); return _(newmat); }
_zgematrix operator- | ( | const zhematrix & | , |
const zgsmatrix & | |||
) | [friend] |
_zgematrix operator- | ( | const zhematrix & | , |
const _zgsmatrix & | |||
) | [friend] |
_zgematrix operator- | ( | const zhematrix & | , |
const zhsmatrix & | |||
) | [friend] |
_zgematrix operator- | ( | const zhematrix & | , |
const _zhsmatrix & | |||
) | [friend] |
_zcovector operator* | ( | const zhematrix & | mat, |
const zcovector & | vec | ||
) | [friend] |
zhematrix*zcovector operator
Definition at line 3 of file zhematrix-zcovector.hpp.
{VERBOSE_REPORT; #ifdef CPPL_DEBUG if(mat.n!=vec.l){ ERROR_REPORT; std::cerr << "These matrix and vector can not make a product." << std::endl << "Your input was (" << mat.n << "x" << mat.n << ") * (" << vec.l << ")." << std::endl; exit(1); } #endif//CPPL_DEBUG zcovector newvec(mat.n); zhemv_( 'l', mat.n, comple(1.0,0.0), mat.array, mat.n, vec.array, 1, comple(0.0,0.0), newvec.array, 1 ); return _(newvec); }
_zcovector operator* | ( | const zhematrix & | mat, |
const _zcovector & | vec | ||
) | [friend] |
zhematrix*_zcovector operator
Definition at line 3 of file zhematrix-_zcovector.hpp.
{VERBOSE_REPORT; #ifdef CPPL_DEBUG if(mat.n!=vec.l){ ERROR_REPORT; std::cerr << "These matrix and vector can not make a product." << std::endl << "Your input was (" << mat.n << "x" << mat.n << ") * (" << vec.l << ")." << std::endl; exit(1); } #endif//CPPL_DEBUG zcovector newvec(mat.n); zhemv_( 'l', mat.n, comple(1.0,0.0), mat.array, mat.n, vec.array, 1, comple(0.0,0.0), newvec.array, 1 ); vec.destroy(); return _(newvec); }
_zgematrix operator* | ( | const zhematrix & | matA, |
const zgematrix & | matB | ||
) | [friend] |
zhematrix*zgematrix operator
Definition at line 46 of file zhematrix-zgematrix.hpp.
{VERBOSE_REPORT; #ifdef CPPL_DEBUG if(matA.n!=matB.m){ ERROR_REPORT; std::cerr << "These two matrises can not make a product." << std::endl << "Your input was (" << matA.n << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl; exit(1); } #endif//CPPL_DEBUG zgematrix newmat( matA.n, matB.n ); zhemm_( 'l', 'l', matA.n, matB.n, comple(1.0,0.0), matA.array, matA.n, matB.array, matB.m, comple(0.0,0.0), newmat.array, newmat.m ); return _(newmat); }
_zgematrix operator* | ( | const zhematrix & | matA, |
const _zgematrix & | matB | ||
) | [friend] |
_zgematrix*zgematrix operator
Definition at line 43 of file zhematrix-_zgematrix.hpp.
{VERBOSE_REPORT; #ifdef CPPL_DEBUG if(matA.n!=matB.m){ ERROR_REPORT; std::cerr << "These two matrises can not make a product." << std::endl << "Your input was (" << matA.n << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl; exit(1); } #endif//CPPL_DEBUG zgematrix newmat( matA.n, matB.n ); zhemm_( 'l', 'l', matA.n, matB.n, comple(1.0,0.0), matA.array, matA.n, matB.array, matB.m, comple(0.0,0.0), newmat.array, newmat.m ); matB.destroy(); return _(newmat); }
_zgematrix operator* | ( | const zhematrix & | matA, |
const zhematrix & | matB | ||
) | [friend] |
zhematrix*zhematrix operator
Definition at line 101 of file zhematrix-zhematrix.hpp.
{VERBOSE_REPORT; #ifdef CPPL_DEBUG if(matA.n!=matB.n){ ERROR_REPORT; std::cerr << "These two matrises can not make a product." << std::endl << "Your input was (" << matA.n << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl; exit(1); } #endif//CPPL_DEBUG matB.complete(); zgematrix newmat( matA.n, matB.n ); zhemm_( 'l', 'l', matA.n, matB.n, comple(1.0,0.0), matA.array, matA.n, matB.array, matB.n, comple(0.0,0.0), newmat.array, newmat.m ); return _(newmat); }
_zgematrix operator* | ( | const zhematrix & | matA, |
const _zhematrix & | matB | ||
) | [friend] |
zhematrix*_zhematrix operator
Definition at line 101 of file zhematrix-_zhematrix.hpp.
{VERBOSE_REPORT; #ifdef CPPL_DEBUG if(matA.n!=matB.n){ ERROR_REPORT; std::cerr << "These two matrises can not make a product." << std::endl << "Your input was (" << matA.n << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl; exit(1); } #endif//CPPL_DEBUG matB.complete(); zgematrix newmat( matA.n, matB.n ); zhemm_( 'l', 'l', matA.n, matB.n, comple(1.0,0.0), matA.array, matA.n, matB.array, matB.n, comple(0.0,0.0), newmat.array, newmat.m ); matB.destroy(); return _(newmat); }
_zgematrix operator* | ( | const zhematrix & | matA, |
const zgbmatrix & | matB | ||
) | [friend] |
zhematrix*zgbmatrix operator
Definition at line 55 of file zhematrix-zgbmatrix.hpp.
{VERBOSE_REPORT; #ifdef CPPL_DEBUG if(matA.n!=matB.m){ ERROR_REPORT; std::cerr << "These two matrises can not make a product." << std::endl << "Your input was (" << matA.n << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl; exit(1); } #endif//CPPL_DEBUG zgematrix 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); }
_zgematrix operator* | ( | const zhematrix & | matA, |
const _zgbmatrix & | matB | ||
) | [friend] |
zhematrix*_zgbmatrix operator
Definition at line 57 of file zhematrix-_zgbmatrix.hpp.
{VERBOSE_REPORT; #ifdef CPPL_DEBUG if(matA.n!=matB.m){ ERROR_REPORT; std::cerr << "These two matrises can not make a product." << std::endl << "Your input was (" << matA.n << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl; exit(1); } #endif//CPPL_DEBUG zgematrix 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); }
_zgematrix operator* | ( | const zhematrix & | , |
const zgsmatrix & | |||
) | [friend] |
_zgematrix operator* | ( | const zhematrix & | , |
const _zgsmatrix & | |||
) | [friend] |
_zgematrix operator* | ( | const zhematrix & | , |
const zhsmatrix & | |||
) | [friend] |
_zgematrix operator* | ( | const zhematrix & | , |
const _zhsmatrix & | |||
) | [friend] |
_zhematrix operator* | ( | const zhematrix & | mat, |
const double & | d | ||
) | [friend] |
_zgematrix operator* | ( | const zhematrix & | mat, |
const comple & | d | ||
) | [friend] |
_zhematrix operator/ | ( | const zhematrix & | mat, |
const double & | d | ||
) | [friend] |
_zgematrix operator/ | ( | const zhematrix & | mat, |
const comple & | d | ||
) | [friend] |
_zhematrix operator* | ( | const double & | d, |
const zhematrix & | mat | ||
) | [friend] |
_zgematrix operator* | ( | const comple & | d, |
const zhematrix & | mat | ||
) | [friend] |
long const& zhematrix::m |
matrix row size
Definition at line 10 of file zhematrix.hpp.
Referenced by col(), operator*(), operator+(), operator-(), row(), and zhematrix_small< n >::zhematrix_small().
long zhematrix::n |
matrix column size
Definition at line 11 of file zhematrix.hpp.
Referenced by _(), chsign(), clear(), col(), complete(), conj(), copy(), i(), identity(), operator()(), operator*(), operator*=(), zgematrix::operator*=(), operator+(), operator+=(), zgematrix::operator+=(), operator-(), operator-=(), zgematrix::operator-=(), operator/(), operator/=(), operator<<(), read(), resize(), row(), set(), shallow_copy(), swap(), t(), to_zgematrix(), write(), zero(), zheev(), zhematrix(), zhematrix_small< n >::zhematrix_small(), and zhesv().
comple* zhematrix::array |
1D array to store matrix data
Definition at line 12 of file zhematrix.hpp.
Referenced by _(), clear(), copy(), operator*(), operator*=(), zgematrix::operator*=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), operator=(), resize(), shallow_copy(), swap(), zheev(), zhematrix(), zhematrix_small< n >::zhematrix_small(), zhesv(), and ~zhematrix().
comple** zhematrix::darray |
array of pointers of column head addresses
Definition at line 13 of file zhematrix.hpp.
Referenced by _(), chsign(), clear(), complete(), copy(), identity(), operator()(), read(), resize(), set(), shallow_copy(), swap(), zero(), zhematrix(), and ~zhematrix().