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  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 /*! dsymatrix+=dsymatrix operator */
18 {CPPL_VERBOSE_REPORT;
19 #ifdef CPPL_DEBUG
20  if(n!=mat.n){
21  ERROR_REPORT;
22  std::cerr << "These two matrises can not make a summation." << std::endl
23  << "Your input was (" << n << "x" << n << ") += (" << mat.n << "x" << mat.n << ")." << std::endl;
24  exit(1);
25  }
26 #endif//CPPL_DEBUG
27 
28  for(CPPL_INT j=0; j<n; j++){
29  for(CPPL_INT i=j; i<n; i++){
30  darray[j][i] +=mat.darray[j][i];
31  }
32  }
33 
34  return *this;
35 }
36 
37 //=============================================================================
38 /*! dsymatrix operator-= */
40 {CPPL_VERBOSE_REPORT;
41 #ifdef CPPL_DEBUG
42  if(n!=mat.n){
43  ERROR_REPORT;
44  std::cerr << "These two matrises can not make a sutraction." << std::endl
45  << "Your input was (" << n << "x" << n << ") -= (" << mat.n << "x" << mat.n << ")." << std::endl;
46  exit(1);
47  }
48 #endif//CPPL_DEBUG
49 
50  for(CPPL_INT j=0; j<n; j++){
51  for(CPPL_INT i=j; i<n; i++){
52  darray[j][i] -=mat.darray[j][i];
53  }
54  }
55 
56  return *this;
57 }
58 
59 //=============================================================================
60 /*! dsymatrix+dsymatrix operator */
61 inline _dsymatrix operator+(const dsymatrix& matA, const dsymatrix& matB)
62 {CPPL_VERBOSE_REPORT;
63 #ifdef CPPL_DEBUG
64  if(matA.n!=matB.n){
65  ERROR_REPORT;
66  std::cerr << "These two matrises can not make a summation." << std::endl
67  << "Your input was (" << matA.n << "x" << matA.n << ") + (" << matB.n << "x" << matB.n << ")." << std::endl;
68  exit(1);
69  }
70 #endif//CPPL_DEBUG
71 
72  dsymatrix newmat(matA.n);
73 
74  for(CPPL_INT j=0; j<matA.n; j++){
75  for(CPPL_INT i=j; i<matA.n; i++){
76  newmat.darray[j][i] =matA.darray[j][i] +matB.darray[j][i];
77  }
78  }
79 
80  return _(newmat);
81 }
82 
83 //=============================================================================
84 /*! dsymatrix-dsymatrix operator */
85 inline _dsymatrix operator-(const dsymatrix& matA, const dsymatrix& matB)
86 {CPPL_VERBOSE_REPORT;
87 #ifdef CPPL_DEBUG
88  if(matA.n!=matB.n){
89  ERROR_REPORT;
90  std::cerr << "These two matrises can not make a subtraction." << std::endl
91  << "Your input was (" << matA.n << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
92  exit(1);
93  }
94 #endif//CPPL_DEBUG
95 
96  dsymatrix newmat(matA.n);
97 
98  for(CPPL_INT j=0; j<matA.n; j++){
99  for(CPPL_INT i=j; i<matA.n; i++){
100  newmat.darray[j][i] =matA.darray[j][i] -matB.darray[j][i];
101  }
102  }
103 
104  return _(newmat);
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  return _(newmat);
131 }
dsymatrix & operator-=(const dsymatrix &)
CPPL_INT m
matrix row size
Definition: dgematrix.hpp:9
double * array
1D array to store matrix data
Definition: dgematrix.hpp:11
_dsymatrix operator-(const dsymatrix &matA, const dsymatrix &matB)
_dsymatrix operator+(const dsymatrix &matA, const dsymatrix &matB)
_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
CPPL_INT const & m
matrix row size
Definition: dsymatrix.hpp:9
(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 &)
CPPL_INT n
matrix column size
Definition: dsymatrix.hpp:10
dsymatrix & operator=(const dsymatrix &)
_dgematrix operator*(const dsymatrix &matA, const dsymatrix &matB)
(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
void copy(const dsymatrix &)
double ** darray
array of pointers of column head addresses
Definition: dsymatrix.hpp:12
_dcovector _(dcovector &vec)