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  return *this;
21 }
22 
23 //=============================================================================
24 /*! dgematrix-=dsymatrix operator */
26 {CPPL_VERBOSE_REPORT;
27 #ifdef CPPL_DEBUG
28  if(n!=mat.n || m!=mat.n){
29  ERROR_REPORT;
30  std::cerr << "These two matrises can not make a sutraction." << std::endl
31  << "Your input was (" << m << "x" << n << ") -= (" << mat.n << "x" << mat.n << ")." << std::endl;
32  exit(1);
33  }
34 #endif//CPPL_DEBUG
35 
36  for(CPPL_INT i=0; i<m; i++){
37  for(CPPL_INT j=0; j<n; j++){
38  operator() (i,j) -= mat(i,j);
39  }
40  }
41 
42  return *this;
43 }
44 
45 //=============================================================================
46 /*! dgematrix*=dsymatrix operator */
48 {CPPL_VERBOSE_REPORT;
49 #ifdef CPPL_DEBUG
50  if(n!=mat.n){
51  ERROR_REPORT;
52  std::cerr << "These two matrises can not make a product." << std::endl
53  << "Your input was (" << m << "x" << n << ") *= (" << mat.n << "x" << mat.n << ")." << std::endl;
54  exit(1);
55  }
56 #endif//CPPL_DEBUG
57 
58  dgematrix newmat( m, mat.n );
59  char side ='R';
60  char uplo ='l';
61  double alpha =1.;
62  double beta =0.;
63 
64  dsymm_( &side, &uplo, &mat.n, &n, &alpha, mat.array, &mat.n, array, &m, &beta, newmat.array, &newmat.m );
65 
66  swap(*this,newmat);
67  return *this;
68 }
69 
70 ///////////////////////////////////////////////////////////////////////////////
71 ///////////////////////////////////////////////////////////////////////////////
72 ///////////////////////////////////////////////////////////////////////////////
73 
74 //=============================================================================
75 /*! dgematrix+dsymatrix operator */
76 inline _dgematrix operator+(const dgematrix& matA, const dsymatrix& matB)
77 {CPPL_VERBOSE_REPORT;
78 #ifdef CPPL_DEBUG
79  if(matA.n!=matB.n || matA.m!=matB.n){
80  ERROR_REPORT;
81  std::cerr << "These two matrises can not make a summation." << std::endl
82  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.n << "x" << matB.n << ")." << std::endl;
83  exit(1);
84  }
85 #endif//CPPL_DEBUG
86 
87  dgematrix newmat(matA);
88  for(CPPL_INT i=0; i<matA.m; i++){
89  for(CPPL_INT j=0; j<matA.n; j++){
90  newmat(i,j) += matB(i,j);
91  }
92  }
93 
94  return _(newmat);
95 }
96 
97 //=============================================================================
98 /*! dgematrix-dsymatrix operator */
99 inline _dgematrix operator-(const dgematrix& matA, const dsymatrix& matB)
100 {CPPL_VERBOSE_REPORT;
101 #ifdef CPPL_DEBUG
102  if(matA.n!=matB.n || matA.m!=matB.n){
103  ERROR_REPORT;
104  std::cerr << "These two matrises can not make a subtraction." << std::endl
105  << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
106  exit(1);
107  }
108 #endif//CPPL_DEBUG
109 
110  dgematrix newmat(matA);
111  for(CPPL_INT i=0; i<matA.m; i++){
112  for(CPPL_INT j=0; j<matA.n; j++){
113  newmat(i,j) -= matB(i,j);
114  }
115  }
116 
117  return _(newmat);
118 }
119 
120 //=============================================================================
121 /*! dgematrix*dsymatrix operator */
122 inline _dgematrix operator*(const dgematrix& matA, const dsymatrix& matB)
123 {CPPL_VERBOSE_REPORT;
124 #ifdef CPPL_DEBUG
125  if(matA.n!=matB.n){
126  ERROR_REPORT;
127  std::cerr << "These two matrises can not make a product." << std::endl
128  << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl;
129  exit(1);
130  }
131 #endif//CPPL_DEBUG
132 
133  dgematrix newmat( matA.m, matB.n );
134  char side ='R';
135  char uplo ='l';
136  double alpha =1.;
137  double beta =0.;
138 
139  dsymm_( &side, &uplo, &newmat.m, &newmat.n, &alpha, matB.array, &matB.n, matA.array, &matA.m, &beta, newmat.array, &newmat.m );
140 
141  return _(newmat);
142 }
_dgematrix operator-(const dgematrix &matA, const dsymatrix &matB)
CPPL_INT m
matrix row size
Definition: dgematrix.hpp:9
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
Real Double-precision Symmetric Matrix Class [l-type (UPLO=l) Strage].
Definition: dsymatrix.hpp:3
dgematrix & operator*=(const dgematrix &)
(DO NOT USE) Smart-temporary Real Double-precision General Dence Matrix Class
Definition: _dgematrix.hpp:3
_dgematrix operator+(const dgematrix &matA, const dsymatrix &matB)
CPPL_INT n
matrix column size
Definition: dsymatrix.hpp:10
dgematrix & operator-=(const dgematrix &)
friend _dgematrix i(const dgematrix &)
double * array
1D array to store matrix data
Definition: dsymatrix.hpp:11
dgematrix & operator+=(const dgematrix &)
_dcovector _(dcovector &vec)
_dgematrix operator*(const dgematrix &matA, const dsymatrix &matB)