CPPLapack
 All Classes Files Functions Variables Friends Pages
zhematrix-zhematrix.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! zhematrix=zhematrix operator */
4 {CPPL_VERBOSE_REPORT;
5  if(array!=mat.array){ // if it is NOT self substitution
6  copy(mat);
7  }
8  return *this;
9 }
10 
11 ///////////////////////////////////////////////////////////////////////////////
12 ///////////////////////////////////////////////////////////////////////////////
13 ///////////////////////////////////////////////////////////////////////////////
14 
15 //=============================================================================
16 /*! zhematrix+=zhematrix operator */
18 {CPPL_VERBOSE_REPORT;
19 #ifdef CPPL_DEBUG
20  if(n!=mat.n){
21  ERROR_REPORT;
22  std::cerr << "These two matrises can not make a summation." << std::endl
23  << "Your input was (" << n << "x" << n << ") += (" << mat.n << "x" << mat.n << ")." << std::endl;
24  exit(1);
25  }
26 #endif//CPPL_DEBUG
27 
28  for(CPPL_INT j=0; j<n; j++){
29  for(CPPL_INT i=j; i<n; i++){
30  darray[j][i] += mat.darray[j][i];
31  }
32  }
33 
34  return *this;
35 }
36 
37 //=============================================================================
38 /*! zhematrix operator-= */
40 {CPPL_VERBOSE_REPORT;
41 #ifdef CPPL_DEBUG
42  if(n!=mat.n){
43  ERROR_REPORT;
44  std::cerr << "These two matrises can not make a sutraction." << std::endl
45  << "Your input was (" << n << "x" << n << ") -= (" << mat.n << "x" << mat.n << ")." << std::endl;
46  exit(1);
47  }
48 #endif//CPPL_DEBUG
49 
50  for(CPPL_INT j=0; j<n; j++){
51  for(CPPL_INT i=j; i<n; i++){
52  darray[j][i] -= mat.darray[j][i];
53  }
54  }
55 
56  return *this;
57 }
58 
59 //=============================================================================
60 /*! zhematrix+zhematrix operator */
61 inline _zhematrix operator+(const zhematrix& matA, const zhematrix& matB)
62 {CPPL_VERBOSE_REPORT;
63 #ifdef CPPL_DEBUG
64  if(matA.n!=matB.n){
65  ERROR_REPORT;
66  std::cerr << "These two matrises can not make a summation." << std::endl
67  << "Your input was (" << matA.n << "x" << matA.n << ") + (" << matB.n << "x" << matB.n << ")." << std::endl;
68  exit(1);
69  }
70 #endif//CPPL_DEBUG
71 
72  zhematrix newmat(matA.n);
73 
74  for(CPPL_INT j=0; j<matA.n; j++){
75  for(CPPL_INT i=j; i<matA.n; i++){
76  newmat.darray[j][i] =matA.darray[j][i] +matB.darray[j][i];
77  }
78  }
79 
80  return _(newmat);
81 }
82 
83 //=============================================================================
84 /*! zhematrix-zhematrix operator */
85 inline _zhematrix operator-(const zhematrix& matA, const zhematrix& matB)
86 {CPPL_VERBOSE_REPORT;
87 #ifdef CPPL_DEBUG
88  if(matA.n!=matB.n){
89  ERROR_REPORT;
90  std::cerr << "These two matrises can not make a subtraction." << std::endl
91  << "Your input was (" << matA.n << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
92  exit(1);
93  }
94 #endif//CPPL_DEBUG
95 
96  zhematrix newmat(matA.n);
97 
98  for(CPPL_INT j=0; j<matA.n; j++){
99  for(CPPL_INT i=j; i<matA.n; i++){
100  newmat.darray[j][i] =matA.darray[j][i] -matB.darray[j][i];
101  }
102  }
103 
104  return _(newmat);
105 }
106 
107 //=============================================================================
108 /*! zhematrix*zhematrix operator */
109 inline _zgematrix operator*(const zhematrix& matA, const zhematrix& matB)
110 {CPPL_VERBOSE_REPORT;
111 #ifdef CPPL_DEBUG
112  if(matA.n!=matB.n){
113  ERROR_REPORT;
114  std::cerr << "These two matrises can not make a product." << std::endl
115  << "Your input was (" << matA.n << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl;
116  exit(1);
117  }
118 #endif//CPPL_DEBUG
119 
120  matB.complete();
121 
122  zgematrix newmat( matA.n, matB.n );
123  char side ='l';
124  char uplo ='l';
125  comple alpha =comple(1.,0.);
126  comple beta =comple(0.,0.);
127 
128  zhemm_( &side, &uplo, &matA.n, &matB.n, &alpha, matA.array, &matA.n, matB.array, &matB.n, &beta, newmat.array, &newmat.m );
129 
130  return _(newmat);
131 }
(DO NOT USE) Smart-temporary Complex Double-precision Hermitian Matrix Class
Definition: _zhematrix.hpp:3
zhematrix & operator+=(const zhematrix &)
_dgematrix i(const _dgbmatrix &mat)
void complete() const
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
void copy(const zhematrix &)
CPPL_INT n
matrix column size
Definition: zhematrix.hpp:11
comple * array
1D array to store matrix data
Definition: zgematrix.hpp:11
(DO NOT USE) Smart-temporary Complex Double-precision General Dence Matrix Class
Definition: _zgematrix.hpp:3
friend _zgematrix i(const zhematrix &)
comple * array
1D array to store matrix data
Definition: zhematrix.hpp:12
_zhematrix operator+(const zhematrix &matA, const zhematrix &matB)
CPPL_INT m
matrix row size
Definition: zgematrix.hpp:9
zhematrix & operator=(const zhematrix &)
_zgematrix operator*(const zhematrix &matA, const zhematrix &matB)
_zhematrix operator-(const zhematrix &matA, const zhematrix &matB)
Complex Double-precision Hermitian Matrix Class [l-type (UPLO=l) Strage].
Definition: zhematrix.hpp:4
comple ** darray
array of pointers of column head addresses
Definition: zhematrix.hpp:13
zhematrix & operator-=(const zhematrix &)
_dcovector _(dcovector &vec)