CPPLapack
 All Classes Files Functions Variables Friends Pages
dgematrix-_dsymatrix.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! dgematrix+=_dsymatrix 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 /*! dgematrix-=_dsymatrix 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 /*! dgematrix*=_dsymatrix 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  dgematrix newmat( m, mat.n );
61  char side ='R';
62  char uplo ='l';
63  double alpha =1.;
64  double beta =0.;
65 
66  dsymm_( &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 /*! dgematrix+_dsymatrix operator */
79 inline _dgematrix operator+(const dgematrix& matA, const _dsymatrix& 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  dgematrix newmat(matA);
91  for(CPPL_INT i=0; i<matA.m; i++){
92  for(CPPL_INT j=0; j<matA.n; j++){
93  newmat(i,j) += matB(i,j);
94  }
95  }
96 
97  matB.destroy();
98  return _(newmat);
99 }
100 
101 //=============================================================================
102 /*! dgematrix-_dsymatrix operator */
103 inline _dgematrix operator-(const dgematrix& matA, const _dsymatrix& matB)
104 {CPPL_VERBOSE_REPORT;
105 #ifdef CPPL_DEBUG
106  if(matA.n!=matB.n || matA.m!=matB.n){
107  ERROR_REPORT;
108  std::cerr << "These two matrises can not make a subtraction." << std::endl
109  << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
110  exit(1);
111  }
112 #endif//CPPL_DEBUG
113 
114  dgematrix newmat(matA);
115  for(CPPL_INT i=0; i<matA.m; i++){
116  for(CPPL_INT j=0; j<matA.n; j++){
117  newmat(i,j) -= matB(i,j);
118  }
119  }
120 
121  matB.destroy();
122  return _(newmat);
123 }
124 
125 //=============================================================================
126 /*! dgematrix*_dsymatrix operator */
127 inline _dgematrix operator*(const dgematrix& matA, const _dsymatrix& matB)
128 {CPPL_VERBOSE_REPORT;
129 #ifdef CPPL_DEBUG
130  if(matA.n!=matB.n){
131  ERROR_REPORT;
132  std::cerr << "These two matrises can not make a product." << std::endl
133  << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl;
134  exit(1);
135  }
136 #endif//CPPL_DEBUG
137 
138  dgematrix newmat( matA.m, matB.n );
139  char side ='R';
140  char uplo ='l';
141  double alpha =1.;
142  double beta =0.;
143 
144  dsymm_( &side, &uplo, &newmat.m, &newmat.n, &alpha, matB.array, &matB.n, matA.array, &matA.m, &beta, newmat.array, &newmat.m );
145 
146  matB.destroy();
147  return _(newmat);
148 }
_dgematrix operator*(const dgematrix &matA, const _dsymatrix &matB)
_dgematrix operator+(const dgematrix &matA, const _dsymatrix &matB)
CPPL_INT m
matrix row size
Definition: dgematrix.hpp:9
void destroy() const
double * array
1D array to store matrix data
Definition: dgematrix.hpp:11
_dgematrix i(const _dgbmatrix &mat)
friend void swap(dgematrix &, dgematrix &)
double & operator()(const CPPL_INT &, const CPPL_INT &)
Definition: dgematrix-io.hpp:3
CPPL_INT n
matrix column size
Definition: dgematrix.hpp:10
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
_dgematrix operator-(const dgematrix &matA, const _dsymatrix &matB)
double * array
1D array to store matrix data
Definition: _dsymatrix.hpp:12
dgematrix & operator*=(const dgematrix &)
(DO NOT USE) Smart-temporary Real Double-precision General Dence Matrix Class
Definition: _dgematrix.hpp:3
(DO NOT USE) Smart-temporary Real Double-precision Symmetric Matrix Class
Definition: _dsymatrix.hpp:3
dgematrix & operator-=(const dgematrix &)
friend _dgematrix i(const dgematrix &)
CPPL_INT n
matrix column size
Definition: _dsymatrix.hpp:11
dgematrix & operator+=(const dgematrix &)
_dcovector _(dcovector &vec)