My Project
dgematrix-dsymatrix.hpp
1 //=============================================================================
4 {
5 #ifdef CPPL_VERBOSE
6  std::cerr << "# [MARK] dgematrix::operator=(const dsymatrix&)"
7  << std::endl;
8 #endif//CPPL_VERBOSE
9 
10  resize(mat.N, mat.N);
11  for(long i=0; i<mat.N; i++){
12  for(long j=0; j<mat.N; j++){
13  operator()(i,j) =mat(i,j);
14  }
15  }
16 
17  return *this;
18 }
19 
23 
24 //=============================================================================
27 {
28 #ifdef CPPL_VERBOSE
29  std::cerr << "# [MARK] dgematrix::operator+=(const dsymatrix&)"
30  << std::endl;
31 #endif//CPPL_VERBOSE
32 
33 #ifdef CPPL_DEBUG
34  if(N!=mat.N || M!=mat.N){
35  std::cerr << "[ERROR] dgematrix::operator+=(dsymatrix&)" << std::endl
36  << "These two matrises can not make a summation." << std::endl
37  << "Your input was (" << M << "x" << N << ") += ("
38  << mat.N << "x" << mat.N << ")." << std::endl;
39  exit(1);
40  }
41 #endif//CPPL_DEBUG
42 
43  for(long i=0; i<M; i++){
44  for( long j=0; j<N; j++){
45  operator() (i,j) += mat(i,j);
46  }
47  }
48 
49  return *this;
50 }
51 
52 //=============================================================================
55 {
56 #ifdef CPPL_VERBOSE
57  std::cerr << "# [MARK] dgematrix::operator-=(const dsymatrix&)"
58  << std::endl;
59 #endif//CPPL_VERBOSE
60 
61 #ifdef CPPL_DEBUG
62  if(N!=mat.N || M!=mat.N){
63  std::cerr << "[ERROR] dgematrix::operator-=(dsymatrix&)" << std::endl
64  << "These two matrises can not make a sutraction." << std::endl
65  << "Your input was (" << M << "x" << N << ") -= ("
66  << mat.N << "x" << mat.N << ")." << std::endl;
67  exit(1);
68  }
69 #endif//CPPL_DEBUG
70 
71  for(long i=0; i<M; i++){
72  for(long j=0; j<N; j++){
73  operator() (i,j) -= mat(i,j);
74  }
75  }
76 
77  return *this;
78 }
79 
80 //=============================================================================
83 {
84 #ifdef CPPL_VERBOSE
85  std::cerr << "# [MARK] dgematrix::operator*=(const dsymatrix&)"
86  << std::endl;
87 #endif//CPPL_VERBOSE
88 
89 #ifdef CPPL_DEBUG
90  if(N!=mat.N){
91  std::cerr << "[ERROR] dgematrix::operator*=(dsymatrix&)" << std::endl
92  << "These two matrises can not make a product." << std::endl
93  << "Your input was (" << M << "x" << N << ") *= ("
94  << mat.N << "x" << mat.N << ")." << std::endl;
95  exit(1);
96  }
97 #endif//CPPL_DEBUG
98 
99  dgematrix newmat( M, mat.N );
100  dsymm_( 'R', 'L', mat.N, N, 1.0, mat.Array, mat.N,
101  Array, M, 0.0, newmat.Array, newmat.M );
102 
103  swap(*this,newmat);
104  return *this;
105 }
106 
110 
111 //=============================================================================
113 inline _dgematrix operator+(const dgematrix& matA, const dsymatrix& matB)
114 {
115 #ifdef CPPL_VERBOSE
116  std::cerr << "# [MARK] operator+(const dgematrix&, const dsymatrix&)"
117  << std::endl;
118 #endif//CPPL_VERBOSE
119 
120 #ifdef CPPL_DEBUG
121  if(matA.N!=matB.N || matA.M!=matB.N){
122  std::cerr << "[ERROR] operator+(const dgematrix&, const dsymatrix&)"
123  << std::endl
124  << "These two matrises can not make a summation." << std::endl
125  << "Your input was (" << matA.M << "x" << matA.N << ") + ("
126  << matB.N << "x" << matB.N << ")." << std::endl;
127  exit(1);
128  }
129 #endif//CPPL_DEBUG
130 
131  dgematrix newmat(matA);
132  for(long i=0; i<matA.M; i++){
133  for(long j=0; j<matA.N; j++){
134  newmat(i,j) += matB(i,j);
135  }
136  }
137 
138  return _(newmat);
139 }
140 
141 //=============================================================================
143 inline _dgematrix operator-(const dgematrix& matA, const dsymatrix& matB)
144 {
145 #ifdef CPPL_VERBOSE
146  std::cerr << "# [MARK] operator-(const dgematrix&, const dsymatrix&)"
147  << std::endl;
148 #endif//CPPL_VERBOSE
149 
150 #ifdef CPPL_DEBUG
151  if(matA.N!=matB.N || matA.M!=matB.N){
152  std::cerr << "[ERROR] operator-(const dgematrix&, const dsymatrix&)"
153  << std::endl
154  << "These two matrises can not make a subtraction." << std::endl
155  << "Your input was (" << matA.M << "x" << matA.N << ") - ("
156  << matB.N << "x" << matB.N << ")." << std::endl;
157  exit(1);
158  }
159 #endif//CPPL_DEBUG
160 
161  dgematrix newmat(matA);
162  for(long i=0; i<matA.M; i++){
163  for(long j=0; j<matA.N; j++){
164  newmat(i,j) -= matB(i,j);
165  }
166  }
167 
168  return _(newmat);
169 }
170 
171 //=============================================================================
173 inline _dgematrix operator*(const dgematrix& matA, const dsymatrix& matB)
174 {
175 #ifdef CPPL_VERBOSE
176  std::cerr << "# [MARK] operator*(const dgematrix&, const dsymatrix&)"
177  << std::endl;
178 #endif//CPPL_VERBOSE
179 
180 #ifdef CPPL_DEBUG
181  if(matA.N!=matB.N){
182  std::cerr << "[ERROR] operator*(const dgematrix&, const dsymatrix&)"
183  << std::endl
184  << "These two matrises can not make a product." << std::endl
185  << "Your input was (" << matA.M << "x" << matA.N << ") * ("
186  << matB.N << "x" << matB.N << ")." << std::endl;
187  exit(1);
188  }
189 #endif//CPPL_DEBUG
190 
191  dgematrix newmat( matA.N, matB.N );
192  dsymm_( 'R', 'L', matB.N, matA.N, 1.0, matB.Array, matB.N,
193  matA.Array, matA.M, 0.0, newmat.Array, newmat.M );
194 
195  return _(newmat);
196 }
void resize(const long &, const long &)
Definition: dgematrix-misc.hpp:126
friend void swap(dgematrix &, dgematrix &)
Definition: dgematrix-misc.hpp:154
double * Array
1D Array to store vector data
Definition: _drovector.hpp:8
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
dgematrix & operator=(const dgematrix &)
Definition: dgematrix-dgematrix.hpp:3
Real Double-precision Symmetric Matrix Class [L-type (UPLO=L) Strage].
Definition: dsymatrix.hpp:3
dgematrix & operator*=(const dgematrix &)
Definition: dgematrix-dgematrix.hpp:68
friend _drovector operator-(const _drovector &)
Definition: _drovector-unary.hpp:15
(DO NOT USE) Smart-temporary Real Double-precision General Dence Matrix Class
Definition: _dgematrix.hpp:3
friend _drovector operator*(const drovector &, const dgematrix &)
Definition: drovector-dgematrix.hpp:3
dgematrix & operator-=(const dgematrix &)
Definition: dgematrix-dgematrix.hpp:45
friend _dgematrix i(const dgematrix &)
Definition: dgematrix-calc.hpp:21
dgematrix & operator+=(const dgematrix &)
Definition: dgematrix-dgematrix.hpp:22
friend const _drovector & operator+(const _drovector &)
Definition: _drovector-unary.hpp:3
double & operator()(const long &, const long &)
Definition: dgematrix-io.hpp:3