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