CPPLapack
 All Classes Files Functions Variables Friends Pages
dssmatrix-dssmatrix.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! dssmatrix=dssmatrix operator */
4 {CPPL_VERBOSE_REPORT;
5  if(&data!=&mat.data){ // if it is NOT self substitution
6  copy(mat);
7  }
8  return *this;
9 }
10 
11 ///////////////////////////////////////////////////////////////////////////////
12 ///////////////////////////////////////////////////////////////////////////////
13 ///////////////////////////////////////////////////////////////////////////////
14 
15 //=============================================================================
16 /*! dssmatrix+=dssmatrix 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  const std::vector<dcomponent>::const_iterator mat_data_end =mat.data.end();
29  for(std::vector<dcomponent>::const_iterator it=mat.data.begin(); it!=mat_data_end; it++){
30  (*this)(it->i,it->j) +=it->v;
31  }
32 
33  return *this;
34 }
35 
36 //=============================================================================
37 /*! dssmatrix-=dssmatrix 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  const std::vector<dcomponent>::const_iterator mat_data_end =mat.data.end();
50  for(std::vector<dcomponent>::const_iterator it=mat.data.begin(); it!=mat_data_end; it++){
51  (*this)(it->i,it->j) -=it->v;
52  }
53 
54  return *this;
55 }
56 
57 ///////////////////////////////////////////////////////////////////////////////
58 ///////////////////////////////////////////////////////////////////////////////
59 ///////////////////////////////////////////////////////////////////////////////
60 
61 //=============================================================================
62 /*! dssmatrix+dssmatrix operator */
63 inline _dssmatrix operator+(const dssmatrix& matA, const dssmatrix& matB)
64 {CPPL_VERBOSE_REPORT;
65 #ifdef CPPL_DEBUG
66  if(matA.n!=matB.n){
67  ERROR_REPORT;
68  std::cerr << "These two matrises can not make a summation." << std::endl
69  << "Your input was (" << matA.n << "x" << matA.n << ") + (" << matB.n << "x" << matB.n << ")." << std::endl;
70  exit(1);
71  }
72 #endif//CPPL_DEBUG
73 
74  dssmatrix newmat(matA);
75 
76  const std::vector<dcomponent>::const_iterator matB_data_end =matB.data.end();
77  for(std::vector<dcomponent>::const_iterator it=matB.data.begin(); it!=matB_data_end; it++){
78  newmat(it->i,it->j) +=it->v;
79  }
80 
81  return _(newmat);
82 }
83 
84 //=============================================================================
85 /*! dssmatrix-dssmatrix operator */
86 inline _dssmatrix operator-(const dssmatrix& matA, const dssmatrix& matB)
87 {CPPL_VERBOSE_REPORT;
88 #ifdef CPPL_DEBUG
89  if(matA.n!=matB.n){
90  ERROR_REPORT;
91  std::cerr << "These two matrises can not make a subtraction." << std::endl
92  << "Your input was (" << matA.n << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
93  exit(1);
94  }
95 #endif//CPPL_DEBUG
96 
97  dssmatrix newmat(matA);
98 
99  const std::vector<dcomponent>::const_iterator matB_data_end =matB.data.end();
100  for(std::vector<dcomponent>::const_iterator it=matB.data.begin(); it!=matB_data_end; it++){
101  newmat(it->i,it->j) -=it->v;
102  }
103 
104  return _(newmat);
105 }
106 
107 //=============================================================================
108 /*! dssmatrix*dssmatrix operator */
109 /*
110 inline _dgsmatrix operator*(const dssmatrix& matA, const dssmatrix& matB)
111 {CPPL_VERBOSE_REPORT;
112 #ifdef CPPL_DEBUG
113  if(matA.n!=matB.n){
114  ERROR_REPORT;
115  std::cerr << "These two matrises can not make a product." << std::endl
116  << "Your input was (" << matA.n << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl;
117  exit(1);
118  }
119 #endif//CPPL_DEBUG
120 
121  dssmatrix newmat( matA.n, 0 );
122 
123  for(CPPL_INT c=0; c<matA.vol; c++){
124  CPPL_INT k(matA.jndx[c]);
125  std::vector< std::pair<CPPL_INT,CPPL_INT> >::iterator p;
126  for(p=matB.Col[k].begin(); p!=matB.Col[k].end(); p++){
127  newmat(matA.indx[c],p->first) +=matA.array[c]*matB.array[p->second];
128  }
129  }
130 
131  return _(newmat);
132 }
133 */
std::vector< dcomponent > data
matrix data
Definition: dssmatrix.hpp:11
void copy(const dssmatrix &)
_dssmatrix operator-(const dssmatrix &matA, const dssmatrix &matB)
(DO NOT USE) Smart-temporary Real Double-precision Symmetric Sparse Matrix Class
Definition: _dssmatrix.hpp:3
dssmatrix & operator+=(const dssmatrix &)
_dssmatrix operator+(const dssmatrix &matA, const dssmatrix &matB)
dssmatrix & operator=(const dssmatrix &)
dssmatrix & operator-=(const dssmatrix &)
Real Double-precision Symmetric Sparse Matrix Class.
Definition: dssmatrix.hpp:3
CPPL_INT n
matrix column size
Definition: dssmatrix.hpp:10
_dcovector _(dcovector &vec)