CPPLapack
 All Classes Files Functions Variables Friends Pages
zgematrix-zgematrix.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! zgematrix=zgematrix 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 /*! zgematrix+=zgematrix operator */
18 {CPPL_VERBOSE_REPORT;
19 #ifdef CPPL_DEBUG
20  if(n!=mat.n || m!=mat.m){
21  ERROR_REPORT;
22  std::cerr << "These two matrises can not make a summation." << std::endl
23  << "Your input was (" << m << "x" << n << ") += (" << mat.m << "x" << mat.n << ")." << std::endl;
24  exit(1);
25  }
26 #endif//CPPL_DEBUG
27 
28  const CPPL_INT size =m*n;
29  for(CPPL_INT i=0; i<size; i++){
30  array[i]+=mat.array[i];
31  }
32  return *this;
33 }
34 
35 //=============================================================================
36 /*! zgematrix operator-= */
38 {CPPL_VERBOSE_REPORT;
39 #ifdef CPPL_DEBUG
40  if(n!=mat.n || m!=mat.m){
41  ERROR_REPORT;
42  std::cerr << "These two matrises can not make a sutraction." << std::endl
43  << "Your input was (" << m << "x" << n << ") -= (" << mat.m << "x" << mat.n << ")." << std::endl;
44  exit(1);
45  }
46 #endif//CPPL_DEBUG
47 
48  const CPPL_INT size =m*n;
49  for(CPPL_INT i=0; i<size; i++){
50  array[i]-=mat.array[i];
51  }
52  return *this;
53 }
54 
55 //=============================================================================
56 /*! zgematrix operator*= */
58 {CPPL_VERBOSE_REPORT;
59 #ifdef CPPL_DEBUG
60  if(n!=mat.m){
61  ERROR_REPORT;
62  std::cerr << "These two matrises can not make a product." << std::endl
63  << "Your input was (" << m << "x" << n << ") *= (" << mat.m << "x" << mat.n << ")." << std::endl;
64  exit(1);
65  }
66 #endif//CPPL_DEBUG
67 
68  zgematrix newmat( m, mat.n );
69  char transa ='n';
70  char transb ='n';
71  comple alpha =comple(1.,0.);
72  comple beta =comple(0.,0.);
73 
74  zgemm_( &transa, &transb, &m, &mat.n, &n, &alpha, array, &m, mat.array, &mat.m, &beta, newmat.array, &m );
75 
76  swap(*this,newmat);
77  return *this;
78 }
79 
80 ///////////////////////////////////////////////////////////////////////////////
81 ///////////////////////////////////////////////////////////////////////////////
82 ///////////////////////////////////////////////////////////////////////////////
83 
84 //=============================================================================
85 /*! zgematrix+zgematrix operator */
86 inline _zgematrix operator+(const zgematrix& matA, const zgematrix& matB)
87 {CPPL_VERBOSE_REPORT;
88 #ifdef CPPL_DEBUG
89  if(matA.n!=matB.n || matA.m!=matB.m){
90  ERROR_REPORT;
91  std::cerr << "These two matrises can not make a summation." << std::endl
92  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
93  exit(1);
94  }
95 #endif//CPPL_DEBUG
96 
97  zgematrix newmat(matA.m,matA.n);
98 
99  const CPPL_INT size =matA.m*matA.n;
100  for(CPPL_INT i=0; i<size; i++){
101  newmat.array[i] =matA.array[i]+matB.array[i];
102  }
103 
104  return _(newmat);
105 }
106 
107 //=============================================================================
108 /*! zgematrix-zgematrix operator */
109 inline _zgematrix operator-(const zgematrix& matA, const zgematrix& matB)
110 {CPPL_VERBOSE_REPORT;
111 #ifdef CPPL_DEBUG
112  if(matA.n!=matB.n || matA.m!=matB.m){
113  ERROR_REPORT;
114  std::cerr << "These two matrises can not make a subtraction." << std::endl
115  << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.m << "x" << matB.n << ")." << std::endl;
116  exit(1);
117  }
118 #endif//CPPL_DEBUG
119 
120  zgematrix newmat(matA.m,matA.n);
121 
122  const CPPL_INT size =matA.m*matA.n;
123  for(CPPL_INT i=0; i<size; i++){
124  newmat.array[i] =matA.array[i]-matB.array[i];
125  }
126 
127  return _(newmat);
128 }
129 
130 //=============================================================================
131 /*! zgematrix*zgematrix operator */
132 inline _zgematrix operator*(const zgematrix& matA, const zgematrix& matB)
133 {CPPL_VERBOSE_REPORT;
134 #ifdef CPPL_DEBUG
135  if(matA.n!=matB.m){
136  ERROR_REPORT;
137  std::cerr << "These two matrises can not make a product." << std::endl
138  << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
139  exit(1);
140  }
141 #endif//CPPL_DEBUG
142 
143  zgematrix newmat( matA.m, matB.n );
144  char transa ='n';
145  char transb ='n';
146  comple alpha =comple(1.,0.);
147  comple beta =comple(0.,0.);
148 
149  zgemm_( &transa, &transb, &matA.m, &matB.n, &matA.n, &alpha, matA.array, &matA.m, matB.array, &matB.m, &beta, newmat.array, &matA.m );
150 
151  return _(newmat);
152 }
153 
154 ///////////////////////////////////////////////////////////////////////////////
155 ///////////////////////////////////////////////////////////////////////////////
156 ///////////////////////////////////////////////////////////////////////////////
157 
158 //=============================================================================
159 /*! return Hadamerd product */
160 inline _zgematrix hadamerd(const zgematrix& matA, const zgematrix& matB)
161 {CPPL_VERBOSE_REPORT;
162 #ifdef CPPL_DEBUG
163  if( matA.m!=matB.m || matA.n!=matB.n ){
164  ERROR_REPORT;
165  std::cerr << "These two matrices can not make Hadamerd product." << std::endl
166  << "Your input was (" << matA.m << "x" << matA.n << ") and (" << matB.m << "x" << matB.n << ")." << std::endl;
167  exit(1);
168  }
169 #endif//CPPL_DEBUG
170 
171  zgematrix newmat(matA.m,matA.n);
172 
173  for(CPPL_INT i=0; i<newmat.m; i++){
174  for(CPPL_INT j=0; j<newmat.n; j++){
175  newmat(i,j) =matA(i,j)*matB(i,j);
176  }
177  }
178 
179  return _(newmat);
180 }
_zgematrix operator+(const zgematrix &matA, const zgematrix &matB)
void copy(const zgematrix &)
zgematrix & operator-=(const zgematrix &)
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
_zgematrix operator-(const zgematrix &matA, const zgematrix &matB)
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
CPPL_INT m
matrix row size
Definition: zgematrix.hpp:9
zgematrix & operator+=(const zgematrix &)
friend void swap(zgematrix &, zgematrix &)
_dcovector _(dcovector &vec)
_zgematrix hadamerd(const zgematrix &matA, const zgematrix &matB)
_zgematrix operator*(const zgematrix &matA, const zgematrix &matB)