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  shallow_copy(mat);
6  return *this;
7 }
8 
9 ///////////////////////////////////////////////////////////////////////////////
10 ///////////////////////////////////////////////////////////////////////////////
11 ///////////////////////////////////////////////////////////////////////////////
12 
13 //=============================================================================
14 /*! zgematrix+=_zgematrix operator */
16 {CPPL_VERBOSE_REPORT;
17 #ifdef CPPL_DEBUG
18  if(n!=mat.n || m!=mat.m){
19  ERROR_REPORT;
20  std::cerr << "These two matrises can not make a summation." << std::endl
21  << "Your input was (" << m << "x" << n << ") += (" << mat.m << "x" << mat.n << ")." << std::endl;
22  exit(1);
23  }
24 #endif//CPPL_DEBUG
25 
26  const CPPL_INT size =m*n;
27  for(CPPL_INT i=0; i<size; i++){
28  array[i] += mat.array[i];
29  }
30 
31  mat.destroy();
32  return *this;
33 }
34 
35 //=============================================================================
36 /*! zgematrix-=_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 
53  mat.destroy();
54  return *this;
55 }
56 
57 //=============================================================================
58 /*! zgematrix*=_zgematrix operator */
60 {CPPL_VERBOSE_REPORT;
61 #ifdef CPPL_DEBUG
62  if(n!=mat.m){
63  ERROR_REPORT;
64  std::cerr << "These two matrises can not make a product." << std::endl
65  << "Your input was (" << m << "x" << n << ") *= (" << mat.m << "x" << mat.n << ")." << std::endl;
66  exit(1);
67  }
68 #endif//CPPL_DEBUG
69 
70  zgematrix newmat( m, mat.n );
71  char transa ='n';
72  char transb ='n';
73  comple alpha =comple(1.,0.);
74  comple beta =comple(0.,0.);
75 
76  zgemm_( &transa, &transb, &m, &mat.n, &n, &alpha, array, &m, mat.array, &mat.m, &beta, newmat.array, &m );
77 
78  swap(*this,newmat);
79  mat.destroy();
80  return *this;
81 }
82 
83 ///////////////////////////////////////////////////////////////////////////////
84 ///////////////////////////////////////////////////////////////////////////////
85 ///////////////////////////////////////////////////////////////////////////////
86 
87 //=============================================================================
88 /*! zgematrix+_zgematrix operator */
89 inline _zgematrix operator+(const zgematrix& matA, const _zgematrix& matB)
90 {CPPL_VERBOSE_REPORT;
91 #ifdef CPPL_DEBUG
92  if(matA.n!=matB.n || matA.m!=matB.m){
93  ERROR_REPORT;
94  std::cerr << "These two matrises can not make a summation." << std::endl
95  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
96  exit(1);
97  }
98 #endif//CPPL_DEBUG
99 
100  const CPPL_INT size =matA.m*matA.n;
101  for(CPPL_INT i=0; i<size; i++){
102  matB.array[i] +=matA.array[i];
103  }
104 
105  return matB;
106 }
107 
108 //=============================================================================
109 /*! zgematrix-_zgematrix operator */
110 inline _zgematrix operator-(const zgematrix& matA, const _zgematrix& matB)
111 {CPPL_VERBOSE_REPORT;
112 #ifdef CPPL_DEBUG
113  if(matA.n!=matB.n || matA.m!=matB.m){
114  ERROR_REPORT;
115  std::cerr << "These two matrises can not make a subtraction." << std::endl
116  << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.m << "x" << matB.n << ")." << std::endl;
117  exit(1);
118  }
119 #endif//CPPL_DEBUG
120 
121  const CPPL_INT size =matA.m*matA.n;
122  for(CPPL_INT i=0; i<size; i++){
123  matB.array[i] =matA.array[i]-matB.array[i];
124  }
125 
126  return matB;
127 }
128 
129 //=============================================================================
130 /*! zgematrix*_zgematrix operator */
131 inline _zgematrix operator*(const zgematrix& matA, const _zgematrix& matB)
132 {CPPL_VERBOSE_REPORT;
133 #ifdef CPPL_DEBUG
134  if(matA.n!=matB.m){
135  ERROR_REPORT;
136  std::cerr << "These two matrises can not make a product." << std::endl
137  << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
138  exit(1);
139  }
140 #endif//CPPL_DEBUG
141 
142  zgematrix newmat( matA.m, matB.n );
143  char transa ='n';
144  char transb ='n';
145  comple alpha =comple(1.,0.);
146  comple beta =comple(0.,0.);
147 
148  zgemm_( &transa, &transb, &matA.m, &matB.n, &matA.n, &alpha, matA.array, &matA.m, matB.array, &matB.m, &beta, newmat.array, &matA.m );
149 
150  matB.destroy();
151  return _(newmat);
152 }
_zgematrix operator-(const zgematrix &matA, const _zgematrix &matB)
CPPL_INT m
matrix row size
Definition: _zgematrix.hpp:9
void shallow_copy(const _zgematrix &)
zgematrix & operator-=(const zgematrix &)
zgematrix & operator=(const zgematrix &)
_dgematrix i(const _dgbmatrix &mat)
_zgematrix operator+(const zgematrix &matA, const _zgematrix &matB)
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
void destroy() const
comple * array
1D array to store matrix data
Definition: _zgematrix.hpp:11
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 _zgematrix &matB)
CPPL_INT n
matrix column size
Definition: _zgematrix.hpp:10