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  return *this;
21 }
22 
23 //=============================================================================
24 /*! zgematrix-=zhematrix operator */
26 {CPPL_VERBOSE_REPORT;
27 #ifdef CPPL_DEBUG
28  if(n!=mat.n || m!=mat.n){
29  ERROR_REPORT;
30  std::cerr << "These two matrises can not make a sutraction." << std::endl
31  << "Your input was (" << m << "x" << n << ") -= (" << mat.n << "x" << mat.n << ")." << std::endl;
32  exit(1);
33  }
34 #endif//CPPL_DEBUG
35 
36  for(CPPL_INT i=0; i<m; i++){
37  for(CPPL_INT j=0; j<n; j++){
38  operator()(i,j) -= mat(i,j);
39  }
40  }
41 
42  return *this;
43 }
44 
45 //=============================================================================
46 /*! zgematrix*=zhematrix operator */
48 {CPPL_VERBOSE_REPORT;
49 #ifdef CPPL_DEBUG
50  if(n!=mat.n){
51  ERROR_REPORT;
52  std::cerr << "These two matrises can not make a product." << std::endl
53  << "Your input was (" << m << "x" << n << ") *= (" << mat.n << "x" << mat.n << ")." << std::endl;
54  exit(1);
55  }
56 #endif//CPPL_DEBUG
57 
58  zgematrix newmat( m, mat.n );
59  char side ='R';
60  char uplo ='l';
61  comple alpha =comple(1.,0.);
62  comple beta =comple(0.,0.);
63 
64  zhemm_( &side, &uplo, &mat.n, &n, &alpha, mat.array, &mat.n, array, &m, &beta, newmat.array, &newmat.m );
65 
66  swap(*this,newmat);
67  return *this;
68 }
69 
70 ///////////////////////////////////////////////////////////////////////////////
71 ///////////////////////////////////////////////////////////////////////////////
72 ///////////////////////////////////////////////////////////////////////////////
73 
74 //=============================================================================
75 /*! zgematrix+zhematrix operator */
76 inline _zgematrix operator+(const zgematrix& matA, const zhematrix& matB)
77 {CPPL_VERBOSE_REPORT;
78 #ifdef CPPL_DEBUG
79  if(matA.n!=matB.n || matA.m!=matB.n){
80  ERROR_REPORT;
81  std::cerr << "These two matrises can not make a summation." << std::endl
82  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.n << "x" << matB.n << ")." << std::endl;
83  exit(1);
84  }
85 #endif//CPPL_DEBUG
86 
87  zgematrix newmat =matA;
88 
89  for(CPPL_INT i=0; i<matA.m; i++){
90  for(CPPL_INT j=0; j<matA.n; j++){
91  newmat(i,j) += matB(i,j);
92  }
93  }
94 
95  return _(newmat);
96 }
97 
98 //=============================================================================
99 /*! zgematrix-zhematrix operator */
100 inline _zgematrix operator-(const zgematrix& matA, const zhematrix& matB)
101 {CPPL_VERBOSE_REPORT;
102 #ifdef CPPL_DEBUG
103  if(matA.n!=matB.n || matA.m!=matB.n){
104  ERROR_REPORT;
105  std::cerr << "These two matrises can not make a subtraction." << std::endl
106  << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
107  exit(1);
108  }
109 #endif//CPPL_DEBUG
110 
111  zgematrix newmat =matA;
112 
113  for(CPPL_INT i=0; i<matA.m; i++){
114  for(CPPL_INT j=0; j<matA.n; j++){
115  newmat(i,j) -= matB(i,j);
116  }
117  }
118 
119  return _(newmat);
120 }
121 
122 //=============================================================================
123 /*! zgematrix*zhematrix operator */
124 inline _zgematrix operator*(const zgematrix& matA, const zhematrix& matB)
125 {CPPL_VERBOSE_REPORT;
126 #ifdef CPPL_DEBUG
127  if(matA.n!=matB.n){
128  ERROR_REPORT;
129  std::cerr << "These two matrises can not make a product." << std::endl
130  << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl;
131  exit(1);
132  }
133 #endif//CPPL_DEBUG
134 
135  zgematrix newmat( matA.m, matA.n );
136  char side ='R';
137  char uplo ='l';
138  comple alpha =comple(1.,0.);
139  comple beta =comple(0.,0.);
140 
141  zhemm_( &side, &uplo, &newmat.m, &newmat.n, &alpha, matB.array, &matB.n, matA.array, &matA.m, &beta, newmat.array, &newmat.m );
142 
143  return _(newmat);
144 }
_zgematrix operator+(const zgematrix &matA, const zhematrix &matB)
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
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
comple * array
1D array to store matrix data
Definition: zhematrix.hpp:12
_zgematrix operator*(const zgematrix &matA, const zhematrix &matB)
_zgematrix operator-(const zgematrix &matA, const zhematrix &matB)
CPPL_INT m
matrix row size
Definition: zgematrix.hpp:9
zgematrix & operator+=(const zgematrix &)
friend void swap(zgematrix &, zgematrix &)
Complex Double-precision Hermitian Matrix Class [l-type (UPLO=l) Strage].
Definition: zhematrix.hpp:4
_dcovector _(dcovector &vec)