CPPLapack
 All Classes Files Functions Variables Friends Pages
dsymatrix-_dsymatrix.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! dsymatrix=_dsymatrix operator */
4 {CPPL_VERBOSE_REPORT;
5  shallow_copy(mat);
6  return *this;
7 }
8 
9 ///////////////////////////////////////////////////////////////////////////////
10 ///////////////////////////////////////////////////////////////////////////////
11 ///////////////////////////////////////////////////////////////////////////////
12 
13 //=============================================================================
14 /*! dsymatrix+=_dsymatrix operator */
16 {CPPL_VERBOSE_REPORT;
17 #ifdef CPPL_DEBUG
18  if(n!=mat.n){
19  ERROR_REPORT;
20  std::cerr << "These two matrises can not make a summation." << std::endl
21  << "Your input was (" << n << "x" << n << ") += (" << mat.n << "x" << mat.n << ")." << std::endl;
22  exit(1);
23  }
24 #endif//CPPL_DEBUG
25 
26  for(CPPL_INT j=0; j<n; j++){
27  for(CPPL_INT i=j; i<n; i++){
28  darray[j][i] +=mat.darray[j][i];
29  }
30  }
31 
32  mat.destroy();
33  return *this;
34 }
35 
36 //=============================================================================
37 /*! dsymatrix-=_dsymatrix operator */
39 {CPPL_VERBOSE_REPORT;
40 #ifdef CPPL_DEBUG
41  if(n!=mat.n){
42  ERROR_REPORT;
43  std::cerr << "These two matrises can not make a sutraction." << std::endl
44  << "Your input was (" << n << "x" << n << ") -= (" << mat.n << "x" << mat.n << ")." << std::endl;
45  exit(1);
46  }
47 #endif//CPPL_DEBUG
48 
49  for(CPPL_INT j=0; j<n; j++){
50  for(CPPL_INT i=j; i<n; i++){
51  darray[j][i] -=mat.darray[j][i];
52  }
53  }
54 
55  mat.destroy();
56  return *this;
57 }
58 
59 ///////////////////////////////////////////////////////////////////////////////
60 ///////////////////////////////////////////////////////////////////////////////
61 ///////////////////////////////////////////////////////////////////////////////
62 
63 //=============================================================================
64 /*! dsymatrix+_dsymatrix operator */
65 inline _dsymatrix operator+(const dsymatrix& matA, const _dsymatrix& matB)
66 {CPPL_VERBOSE_REPORT;
67 #ifdef CPPL_DEBUG
68  if(matA.n!=matB.n){
69  ERROR_REPORT;
70  std::cerr << "These two matrises can not make a summation." << std::endl
71  << "Your input was (" << matA.n << "x" << matA.n << ") + (" << matB.n << "x" << matB.n << ")." << std::endl;
72  exit(1);
73  }
74 #endif//CPPL_DEBUG
75 
76  for(CPPL_INT j=0; j<matA.n; j++){
77  for(CPPL_INT i=j; i<matA.n; i++){
78  matB.darray[j][i] +=matA.darray[j][i];
79  }
80  }
81 
82  return matB;
83 }
84 
85 //=============================================================================
86 /*! dsymatrix-_dsymatrix operator */
87 inline _dsymatrix operator-(const dsymatrix& matA, const _dsymatrix& matB)
88 {CPPL_VERBOSE_REPORT;
89 #ifdef CPPL_DEBUG
90  if(matA.n!=matB.n){
91  ERROR_REPORT;
92  std::cerr << "These two matrises can not make a subtraction." << std::endl
93  << "Your input was (" << matA.n << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
94  exit(1);
95  }
96 #endif//CPPL_DEBUG
97 
98  for(CPPL_INT j=0; j<matA.n; j++){
99  for(CPPL_INT i=j; i<matA.n; i++){
100  matB.darray[j][i] =matA.darray[j][i] -matB.darray[j][i];
101  }
102  }
103 
104  return matB;
105 }
106 
107 //=============================================================================
108 /*! dsymatrix*_dsymatrix operator */
109 inline _dgematrix operator*(const dsymatrix& matA, const _dsymatrix& matB)
110 {CPPL_VERBOSE_REPORT;
111 #ifdef CPPL_DEBUG
112  if(matA.n!=matB.n){
113  ERROR_REPORT;
114  std::cerr << "These two matrises can not make a product." << std::endl
115  << "Your input was (" << matA.n << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl;
116  exit(1);
117  }
118 #endif//CPPL_DEBUG
119 
120  matB.complete();
121 
122  dgematrix newmat( matA.n, matA.n );
123  char side ='l';
124  char uplo ='l';
125  double alpha =1.;
126  double beta =0.;
127 
128  dsymm_( &side, &uplo, &matA.n, &matB.n, &alpha, matA.array, &matA.n, matB.array, &matB.m, &beta, newmat.array, &newmat.m );
129 
130  matB.destroy();
131  return _(newmat);
132 }
dsymatrix & operator-=(const dsymatrix &)
CPPL_INT m
matrix row size
Definition: dgematrix.hpp:9
void destroy() const
_dgematrix operator*(const dsymatrix &matA, const _dsymatrix &matB)
double * array
1D array to store matrix data
Definition: dgematrix.hpp:11
_dgematrix i(const _dgbmatrix &mat)
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
Real Double-precision Symmetric Matrix Class [l-type (UPLO=l) Strage].
Definition: dsymatrix.hpp:3
double * array
1D array to store matrix data
Definition: _dsymatrix.hpp:12
_dsymatrix operator+(const dsymatrix &matA, const _dsymatrix &matB)
(DO NOT USE) Smart-temporary Real Double-precision General Dence Matrix Class
Definition: _dgematrix.hpp:3
dsymatrix & operator+=(const dsymatrix &)
friend _dsymatrix i(const dsymatrix &)
double ** darray
array of pointers of column head addresses
Definition: _dsymatrix.hpp:13
CPPL_INT n
matrix column size
Definition: dsymatrix.hpp:10
void shallow_copy(const _dsymatrix &)
_dsymatrix operator-(const dsymatrix &matA, const _dsymatrix &matB)
dsymatrix & operator=(const dsymatrix &)
(DO NOT USE) Smart-temporary Real Double-precision Symmetric Matrix Class
Definition: _dsymatrix.hpp:3
void complete() const
double * array
1D array to store matrix data
Definition: dsymatrix.hpp:11
CPPL_INT n
matrix column size
Definition: _dsymatrix.hpp:11
double ** darray
array of pointers of column head addresses
Definition: dsymatrix.hpp:12
_dcovector _(dcovector &vec)
CPPL_INT const & m
matrix row size
Definition: _dsymatrix.hpp:10