CPPLapack
 All Classes Files Functions Variables Friends Pages
Functions
_dgematrix-dgsmatrix.hpp File Reference

Go to the source code of this file.

Functions

_dgematrix operator+ (const _dgematrix &matA, const dgsmatrix &matB)
 
_dgematrix operator- (const _dgematrix &matA, const dgsmatrix &matB)
 
_dgematrix operator* (const _dgematrix &matA, const dgsmatrix &matB)
 

Function Documentation

_dgematrix operator+ ( const _dgematrix matA,
const dgsmatrix matB 
)
inline

_dgematrix+dgsmatrix operator

Definition at line 3 of file _dgematrix-dgsmatrix.hpp.

References dgsmatrix::data, dgsmatrix::m, _dgematrix::m, _dgematrix::n, and dgsmatrix::n.

4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if(matA.m!=matB.m || matA.n!=matB.n){
7  ERROR_REPORT;
8  std::cerr << "These two matrises can not make a summation." << std::endl
9  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13  const std::vector<dcomponent>::const_iterator matB_data_end =matB.data.end();
14  for(std::vector<dcomponent>::const_iterator it=matB.data.begin(); it!=matB_data_end; it++){
15  matA(it->i,it->j) += it->v;
16  }
17 
18  return matA;
19 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
CPPL_INT m
matrix row size
Definition: _dgematrix.hpp:9
CPPL_INT n
matrix column size
Definition: _dgematrix.hpp:10
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
_dgematrix operator- ( const _dgematrix matA,
const dgsmatrix matB 
)
inline

_dgematrix-dgsmatrix operator

Definition at line 23 of file _dgematrix-dgsmatrix.hpp.

References _dgematrix::array, dgsmatrix::data, i(), dgsmatrix::m, _dgematrix::m, _dgematrix::n, and dgsmatrix::n.

24 {CPPL_VERBOSE_REPORT;
25 #ifdef CPPL_DEBUG
26  if(matA.m!=matB.m || matA.n!=matB.n){
27  ERROR_REPORT;
28  std::cerr << "These two matrises can not make a subtraction." << std::endl
29  << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.m << "x" << matB.n << ")." << std::endl;
30  exit(1);
31  }
32 #endif//CPPL_DEBUG
33 
34  //// change sign ////
35  for(CPPL_INT i=0; i<matA.m*matA.n; i++){
36  matA.array[i]=-matA.array[i];
37  }
38 
39  //// add ////
40  const std::vector<dcomponent>::const_iterator matB_data_end =matB.data.end();
41  for(std::vector<dcomponent>::const_iterator it=matB.data.begin(); it!=matB_data_end; it++){
42  matA(it->i,it->j) += it->v;
43  }
44 
45  return matA;
46 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
_dgematrix i(const _dgbmatrix &mat)
CPPL_INT m
matrix row size
Definition: _dgematrix.hpp:9
double * array
1D array to store matrix data
Definition: _dgematrix.hpp:11
CPPL_INT n
matrix column size
Definition: _dgematrix.hpp:10
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9
_dgematrix operator* ( const _dgematrix matA,
const dgsmatrix matB 
)
inline

_dgematrix*dgsmatrix operator

Definition at line 50 of file _dgematrix-dgsmatrix.hpp.

References _(), dgsmatrix::data, _dgematrix::destroy(), i(), _dgematrix::i, dgsmatrix::m, _dgematrix::m, _dgematrix::n, dgsmatrix::n, and dgematrix::zero().

51 {CPPL_VERBOSE_REPORT;
52 #ifdef CPPL_DEBUG
53  if(matA.n!=matB.m){
54  ERROR_REPORT;
55  std::cerr << "These two matrises can not make a product." << std::endl
56  << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
57  exit(1);
58  }
59 #endif//CPPL_DEBUG
60 
61  dgematrix newmat(matA.m, matB.n);
62  newmat.zero();
63 
64  const std::vector<dcomponent>::const_iterator matB_data_end =matB.data.end();
65  for(std::vector<dcomponent>::const_iterator it=matB.data.begin(); it!=matB_data_end; it++){
66  for(CPPL_INT i=0; i<matA.m; i++){
67  newmat(i,it->j) += matA(i,it->i)*it->v;
68  }
69  }
70 
71  matA.destroy();
72  return _(newmat);
73 }
std::vector< dcomponent > data
matrix data
Definition: dgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgsmatrix.hpp:10
_dgematrix i(const _dgbmatrix &mat)
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
friend _dgematrix i(const _dgematrix &)
CPPL_INT m
matrix row size
Definition: _dgematrix.hpp:9
CPPL_INT n
matrix column size
Definition: _dgematrix.hpp:10
void destroy() const
_dcovector _(dcovector &vec)
CPPL_INT m
matrix row size
Definition: dgsmatrix.hpp:9