CPPLapack
 All Classes Files Functions Variables Friends Pages
Public Member Functions | Public Attributes | Friends | List of all members
zgsmatrix Class Reference

Complex Double-precision General Sparse Matrix Class. More...

#include <zgsmatrix.hpp>

Public Member Functions

 zgsmatrix ()
 
 zgsmatrix (const zgsmatrix &)
 
 zgsmatrix (const _zgsmatrix &)
 
 zgsmatrix (const CPPL_INT &, const CPPL_INT &, const CPPL_INT=0)
 
 zgsmatrix (const char *)
 
 ~zgsmatrix ()
 
_zgematrix to_zgematrix () const
 
comple operator() (const CPPL_INT &, const CPPL_INT &) const
 
comple & operator() (const CPPL_INT &, const CPPL_INT &)
 
zgsmatrixput (const CPPL_INT &, const CPPL_INT &, const comple &)
 
zgsmatrixdel (const CPPL_INT, const CPPL_INT)
 
zgsmatrixdel (const CPPL_INT)
 
void write (const char *) const
 
void read (const char *)
 
void clear ()
 
zgsmatrixzero ()
 
zgsmatrixidentity ()
 
void chsign ()
 
void copy (const zgsmatrix &)
 
void shallow_copy (const _zgsmatrix &)
 
zgsmatrixresize (const CPPL_INT &, const CPPL_INT &, const CPPL_INT=0, const CPPL_INT=0)
 
void stretch (const CPPL_INT &, const CPPL_INT &)
 
void expand (const CPPL_INT &)
 
bool isListed (const CPPL_INT &, const CPPL_INT &)
 
CPPL_INT number (const CPPL_INT &, const CPPL_INT &)
 
void checkup ()
 
void diet (const double=DBL_MIN)
 
_zrovector row (const CPPL_INT &) const
 
_zcovector col (const CPPL_INT &) const
 
zgsmatrixoperator= (const zgsmatrix &)
 
zgsmatrixoperator= (const _zgsmatrix &)
 
zgsmatrixoperator+= (const zgsmatrix &)
 
zgsmatrixoperator+= (const _zgsmatrix &)
 
zgsmatrixoperator-= (const zgsmatrix &)
 
zgsmatrixoperator-= (const _zgsmatrix &)
 
zgsmatrixoperator*= (const zgsmatrix &)
 
zgsmatrixoperator*= (const _zgsmatrix &)
 
zgsmatrixoperator*= (const double &)
 
zgsmatrixoperator*= (const comple &)
 
zgsmatrixoperator/= (const double &)
 
zgsmatrixoperator/= (const comple &)
 

Public Attributes

CPPL_INT m
 matrix row size More...
 
CPPL_INT n
 matrix column size More...
 
std::vector< zcomponentdata
 matrix data More...
 
std::vector< std::vector
< CPPL_INT > > 
rows
 array of vector to store the entry information of component for each row More...
 
std::vector< std::vector
< CPPL_INT > > 
cols
 array of vector to store the entry information of component for each column More...
 

Friends

std::ostream & operator<< (std::ostream &, const zgsmatrix &)
 
void swap (zgsmatrix &, zgsmatrix &)
 
_zgsmatrix _ (zgsmatrix &)
 
_zgsmatrix t (const zgsmatrix &)
 
_zgsmatrix conj (const zgsmatrix &)
 
_zgsmatrix conjt (const zgsmatrix &)
 
void idamax (CPPL_INT &, CPPL_INT &, const zgsmatrix &)
 
comple damax (const zgsmatrix &)
 
const zgsmatrixoperator+ (const zgsmatrix &)
 
_zgsmatrix operator- (const zgsmatrix &)
 
_zgematrix operator+ (const zgsmatrix &, const zgematrix &)
 
_zgematrix operator+ (const zgsmatrix &, const _zgematrix &)
 
_zgematrix operator+ (const zgsmatrix &, const zhematrix &)
 
_zgematrix operator+ (const zgsmatrix &, const _zhematrix &)
 
_zgematrix operator+ (const zgsmatrix &, const zgbmatrix &)
 
_zgematrix operator+ (const zgsmatrix &, const _zgbmatrix &)
 
_zgsmatrix operator+ (const zgsmatrix &, const zgsmatrix &)
 
_zgsmatrix operator+ (const zgsmatrix &, const _zgsmatrix &)
 
_zgsmatrix operator+ (const zgsmatrix &, const zhsmatrix &)
 
_zgsmatrix operator+ (const zgsmatrix &, const _zhsmatrix &)
 
_zgematrix operator- (const zgsmatrix &, const zgematrix &)
 
_zgematrix operator- (const zgsmatrix &, const _zgematrix &)
 
_zgematrix operator- (const zgsmatrix &, const zhematrix &)
 
_zgematrix operator- (const zgsmatrix &, const _zhematrix &)
 
_zgematrix operator- (const zgsmatrix &, const zgbmatrix &)
 
_zgematrix operator- (const zgsmatrix &, const _zgbmatrix &)
 
_zgsmatrix operator- (const zgsmatrix &, const zgsmatrix &)
 
_zgsmatrix operator- (const zgsmatrix &, const _zgsmatrix &)
 
_zgsmatrix operator- (const zgsmatrix &, const zhsmatrix &)
 
_zgsmatrix operator- (const zgsmatrix &, const _zhsmatrix &)
 
_zcovector operator* (const zgsmatrix &, const zcovector &)
 
_zcovector operator* (const zgsmatrix &, const _zcovector &)
 
_zgematrix operator* (const zgsmatrix &, const zgematrix &)
 
_zgematrix operator* (const zgsmatrix &, const _zgematrix &)
 
_zgematrix operator* (const zgsmatrix &, const zhematrix &)
 
_zgematrix operator* (const zgsmatrix &, const _zhematrix &)
 
_zgematrix operator* (const zgsmatrix &, const zgbmatrix &)
 
_zgematrix operator* (const zgsmatrix &, const _zgbmatrix &)
 
_zgsmatrix operator* (const zgsmatrix &, const zgsmatrix &)
 
_zgsmatrix operator* (const zgsmatrix &, const _zgsmatrix &)
 
_zgsmatrix operator* (const zgsmatrix &, const zhsmatrix &)
 
_zgsmatrix operator* (const zgsmatrix &, const _zhsmatrix &)
 
_zgsmatrix operator* (const zgsmatrix &, const double &)
 
_zgsmatrix operator* (const zgsmatrix &, const comple &)
 
_zgsmatrix operator/ (const zgsmatrix &, const double &)
 
_zgsmatrix operator/ (const zgsmatrix &, const comple &)
 
_zgsmatrix operator* (const double &, const zgsmatrix &)
 
_zgsmatrix operator* (const comple &, const zgsmatrix &)
 

Detailed Description

Complex Double-precision General Sparse Matrix Class.

Definition at line 3 of file zgsmatrix.hpp.

Constructor & Destructor Documentation

zgsmatrix::zgsmatrix ( )
inline

zgsmatrix constructor without arguments

Definition at line 3 of file zgsmatrix-constructor.hpp.

References cols, data, m, n, and rows.

4 {CPPL_VERBOSE_REPORT;
5  //////// initialize ////////
6  m =0;
7  n =0;
8  data.clear();
9  rows.clear();
10  cols.clear();
11 }
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: zgsmatrix.hpp:12
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: zgsmatrix.hpp:13
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
zgsmatrix::zgsmatrix ( const zgsmatrix mat)
inline

zgsmatrix copy constructor

Definition at line 19 of file zgsmatrix-constructor.hpp.

References cols, copy(), data, m, n, and rows.

20 {CPPL_VERBOSE_REPORT;
21  m =mat.m;
22  n =mat.n;
23  data.clear();
24  rows.clear();
25  cols.clear();
26  copy(mat);
27 }
void copy(const zgsmatrix &)
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: zgsmatrix.hpp:12
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: zgsmatrix.hpp:13
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
zgsmatrix::zgsmatrix ( const _zgsmatrix mat)
inline

zgsmatrix constructor to cast _zgsmatrix

Definition at line 31 of file zgsmatrix-constructor.hpp.

References cols, _zgsmatrix::cols, _zgsmatrix::data, data, m, _zgsmatrix::m, _zgsmatrix::n, n, _zgsmatrix::nullify(), rows, and _zgsmatrix::rows.

32 {CPPL_VERBOSE_REPORT;
33  m =mat.m;
34  n =mat.n;
35  data.clear();
36  rows.clear();
37  cols.clear();
38 
39  data.swap(mat.data);
40  rows.swap(mat.rows);
41  cols.swap(mat.cols);
42 
43  mat.nullify();
44 }
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: _zgsmatrix.hpp:12
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: _zgsmatrix.hpp:13
CPPL_INT n
matrix column size
Definition: _zgsmatrix.hpp:10
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: zgsmatrix.hpp:12
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: _zgsmatrix.hpp:9
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: zgsmatrix.hpp:13
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
void nullify() const
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
std::vector< zcomponent > data
matrix data
Definition: _zgsmatrix.hpp:11
zgsmatrix::zgsmatrix ( const CPPL_INT &  _m,
const CPPL_INT &  _n,
const CPPL_INT  _c = 0 
)
inline

zgsmatrix constructor with size specification

Definition at line 52 of file zgsmatrix-constructor.hpp.

References cols, data, m, n, and rows.

53 {CPPL_VERBOSE_REPORT;
54 #ifdef CPPL_DEBUG
55  if( _m<0 || _n<0 || _c<0 ){
56  ERROR_REPORT;
57  std::cerr << "Matrix sizes and the length of arrays must be positive integers. " << std::endl
58  << "Your input was (" << _m << "," << _n << "," << _c << ")." << std::endl;
59  exit(1);
60  }
61 #endif//CPPL_DEBUG
62 
63  //////// initialize ////////
64  m =_m;
65  n =_n;
66  data.resize(0);
67  data.reserve(_c);
68  rows.resize(m);
69  cols.resize(n);
70 }
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: zgsmatrix.hpp:12
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: zgsmatrix.hpp:13
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
zgsmatrix::zgsmatrix ( const char *  filename)
inline

zgsmatrix constructor with filename

Definition at line 74 of file zgsmatrix-constructor.hpp.

References cols, data, read(), and rows.

75 {CPPL_VERBOSE_REPORT;
76  data.clear();
77  rows.clear();
78  cols.clear();
79 
80  //// read ////
81  read(filename);
82 }
void read(const char *)
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: zgsmatrix.hpp:12
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: zgsmatrix.hpp:13
zgsmatrix::~zgsmatrix ( )
inline

zgsmatrix destructor

Definition at line 90 of file zgsmatrix-constructor.hpp.

References cols, data, and rows.

91 {CPPL_VERBOSE_REPORT;
92  data.clear();
93  rows.clear();
94  cols.clear();
95 }
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: zgsmatrix.hpp:12
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: zgsmatrix.hpp:13

Member Function Documentation

_zgematrix zgsmatrix::to_zgematrix ( ) const
inline

convert to _zgematrix

Definition at line 3 of file zgsmatrix-cast.hpp.

References _, data, zcomponent::i, zcomponent::j, m, n, zcomponent::v, and zero().

Referenced by operator+(), and operator-().

4 {CPPL_VERBOSE_REPORT;
5  zgematrix newmat( zgematrix(m,n).zero() );
6 
7  const size_t data_size =data.size();
8  for(size_t c=0; c<data_size; c++){
9  const zcomponent& z =data[c];
10  newmat(z.i,z.j) =z.v;
11  }
12 
13  return _(newmat);
14 }
comple v
value of the component
Definition: zcomponent.hpp:11
friend _zgsmatrix _(zgsmatrix &)
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
Component Class for Complex Double-precision Sparse Matrix Classes.
Definition: zcomponent.hpp:3
CPPL_INT j
j index of the component
Definition: zcomponent.hpp:10
CPPL_INT i
i index of the component
Definition: zcomponent.hpp:9
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
zgsmatrix & zero()
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
comple zgsmatrix::operator() ( const CPPL_INT &  i,
const CPPL_INT &  j 
) const
inline

operator() for const object

Definition at line 3 of file zgsmatrix-io.hpp.

References data, i(), m, n, and rows.

4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if( i<0 || j<0 || m<=i || n<=j ){
7  ERROR_REPORT;
8  std::cerr << "The required component is out of the matrix size." << std::endl
9  << "Your input is (" << i << "," << j << "), whereas the matrix size is " << m << "x" << n << "." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13 
14  //// search (i,j) component ////
15  const std::vector<CPPL_INT>::const_iterator rows_i_end =rows[i].end();
16  for(std::vector<CPPL_INT>::const_iterator p=rows[i].begin(); p!=rows_i_end; p++){
17  if(data[*p].j==j){ return data[*p].v; }
18  }
19 
20  //// (i,j) component was not found ////
21  return comple(0.0,0.0);
22 }
_dgematrix i(const _dgbmatrix &mat)
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: zgsmatrix.hpp:12
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
comple & zgsmatrix::operator() ( const CPPL_INT &  i,
const CPPL_INT &  j 
)
inline

operator() for const object

Definition at line 26 of file zgsmatrix-io.hpp.

References cols, data, i(), m, n, and rows.

27 {CPPL_VERBOSE_REPORT;
28 #ifdef CPPL_DEBUG
29  if( i<0 || j<0 || m<=i || n<=j ){
30  ERROR_REPORT;
31  std::cerr << "The required component is out of the matrix size." << std::endl
32  << "Your input is (" << i << "," << j << "), whereas the matrix size is " << m << "x" << n << "." << std::endl;
33  exit(1);
34  }
35 #endif//CPPL_DEBUG
36 
37  //////// search (i,j) component ////////
38  const std::vector<CPPL_INT>::iterator rows_i_end =rows[i].end();
39  for(std::vector<CPPL_INT>::iterator p=rows[i].begin(); p!=rows_i_end; p++){
40  if(data[*p].j==j){ return data[*p].v; }
41  }
42 
43  //////// (i,j) component not found ////////
44  rows[i].push_back(CPPL_INT(data.size()));
45  cols[j].push_back(CPPL_INT(data.size()));
46  data.push_back( zcomponent(i,j, comple(0.,0.)) );
47  return data.back().v;
48 }
_dgematrix i(const _dgbmatrix &mat)
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: zgsmatrix.hpp:12
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
Component Class for Complex Double-precision Sparse Matrix Classes.
Definition: zcomponent.hpp:3
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: zgsmatrix.hpp:13
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
zgsmatrix & zgsmatrix::put ( const CPPL_INT &  i,
const CPPL_INT &  j,
const comple &  v 
)
inline

put value without isListed check

Definition at line 56 of file zgsmatrix-io.hpp.

References cols, data, i(), isListed(), m, n, and rows.

Referenced by identity(), read(), _dgsmatrix::to_zgsmatrix(), _zhsmatrix::to_zgsmatrix(), dgsmatrix::to_zgsmatrix(), and zhsmatrix::to_zgsmatrix().

57 {CPPL_VERBOSE_REPORT;
58 #ifdef CPPL_DEBUG
59  if( i<0 || j<0 || m<=i || n<=j ){
60  ERROR_REPORT;
61  std::cerr << "The required component is out of the matrix size." << std::endl
62  << "Your input is (" << i << "," << j << "), whereas the matrix size is " << m << "x" << n << "." << std::endl;
63  exit(1);
64  }
65 
66  if( isListed(i,j) ){
67  ERROR_REPORT;
68  std::cerr << "The required component is already listed." << std::endl
69  << "Your input was (" << i << "," << j << ")." << std::endl;
70  exit(1);
71  }
72 #endif//CPPL_DEBUG
73 
74  //// push ////
75  rows[i].push_back(CPPL_INT(data.size()));
76  cols[j].push_back(CPPL_INT(data.size()));
77  data.push_back(zcomponent(i,j,v));
78 
79  return *this;
80 }
bool isListed(const CPPL_INT &, const CPPL_INT &)
_dgematrix i(const _dgbmatrix &mat)
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: zgsmatrix.hpp:12
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
Component Class for Complex Double-precision Sparse Matrix Classes.
Definition: zcomponent.hpp:3
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: zgsmatrix.hpp:13
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
zgsmatrix & zgsmatrix::del ( const CPPL_INT  i,
const CPPL_INT  j 
)
inline

delete the entry of a component

Definition at line 88 of file zgsmatrix-io.hpp.

References cols, data, i(), m, n, and rows.

Referenced by diet(), and stretch().

89 {CPPL_VERBOSE_REPORT;
90 #ifdef CPPL_DEBUG
91  if( i<0 || j<0 || m<=i || n<=j ){
92  ERROR_REPORT;
93  std::cerr << "The required component is out of the matrix size." << std::endl
94  << "Your input is (" << i << "," << j << "), whereas the matrix size is " << m << "x" << n << "." << std::endl;
95  exit(1);
96  }
97 #endif//CPPL_DEBUG
98 
99  //// search (i,j) component ////
100  const std::vector<CPPL_INT>::iterator rows_i_end =rows[i].end();
101  for(std::vector<CPPL_INT>::iterator p=rows[i].begin(); p!=rows_i_end; p++){
102  if(data[*p].j==j){//exists
103  //// save position ////
104  CPPL_INT c =*p;
105  CPPL_INT C =CPPL_INT(data.size()-1);
106 
107  //// data translation ////
108  data[c]=data.back();
109  data.pop_back();
110 
111  //// remove from List ////
112  rows[i].erase(p);
113  const std::vector<CPPL_INT>::iterator cols_j_end =cols[j].end();
114  for(std::vector<CPPL_INT>::iterator q=cols[j].begin(); q!=cols_j_end; q++){
115  if(*q==c){ cols[j].erase(q); break; }
116  }
117 
118  //// modify the entry of translated component ////
119  CPPL_INT I(data[c].i), J(data[c].j);
120  const std::vector<CPPL_INT>::iterator rows_I_end =rows[I].end();
121  for(std::vector<CPPL_INT>::iterator q=rows[I].begin(); q!=rows_I_end; q++){
122  if(*q==C){ *q=c; break; }
123  }
124  const std::vector<CPPL_INT>::iterator cols_J_end =cols[J].end();
125  for(std::vector<CPPL_INT>::iterator q=cols[J].begin(); q!=cols_J_end; q++){
126  if(*q==C){ *q=c; break; }
127  }
128  return *this;
129  }
130  }
131 
132 #ifdef CPPL_DEBUG
133  std::cerr << "# [NOTE] zgsmatrix::del(CPPL_INT&, CPPL_INT&): The required component was not listed. Your input was (" << i << "," << j << ")." << std::endl;
134 #endif//CPPL_DEBUG
135 
136  return *this;
137 }
_dgematrix i(const _dgbmatrix &mat)
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: zgsmatrix.hpp:12
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: zgsmatrix.hpp:13
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
zgsmatrix & zgsmatrix::del ( const CPPL_INT  c)
inline

delete the entry of an element

Definition at line 141 of file zgsmatrix-io.hpp.

References cols, data, i(), and rows.

142 {CPPL_VERBOSE_REPORT;
143 #ifdef CPPL_DEBUG
144  if( c<0 || c>=CPPL_INT(data.size()) ){
145  ERROR_REPORT;
146  std::cerr << "The required element is out of the matrix volume." << std::endl
147  << "Your input was (" << c << ")." << std::endl;
148  exit(1);
149  }
150 #endif//CPPL_DEBUG
151 
152  if( c==CPPL_INT(data.size()-1) ){//if c is the last element
153  CPPL_INT i(data[c].i), j(data[c].j);
154  const std::vector<CPPL_INT>::iterator rows_i_end =rows[i].end();
155  for(std::vector<CPPL_INT>::iterator q=rows[i].begin(); q!=rows_i_end; q++){
156  if(*q==c){ rows[i].erase(q); break; }
157  }
158  const std::vector<CPPL_INT>::iterator cols_j_end =cols[j].end();
159  for(std::vector<CPPL_INT>::iterator q=cols[j].begin(); q!=cols_j_end; q++){
160  if(*q==c){ cols[j].erase(q); break; }
161  }
162  data.pop_back();
163  }
164 
165  else{//if c is NOT the last element
166  //// data translation ////
167  CPPL_INT C =CPPL_INT(data.size()-1);
168  CPPL_INT i(data[c].i), j(data[c].j), I(data.back().i), J(data.back().j);
169  data[c]=data.back();
170  //// remove entry of component ////
171  const std::vector<CPPL_INT>::iterator rows_i_end =rows[i].end();
172  for(std::vector<CPPL_INT>::iterator q=rows[i].begin(); q!=rows_i_end; q++){
173  if(*q==c){ rows[i].erase(q); break; }
174  }
175  const std::vector<CPPL_INT>::iterator cols_j_end =cols[j].end();
176  for(std::vector<CPPL_INT>::iterator q=cols[j].begin(); q!=cols_j_end; q++){
177  if(*q==c){ cols[j].erase(q); break; }
178  }
179  //// modify the entry of translated component ////
180  const std::vector<CPPL_INT>::iterator rows_I_end =rows[I].end();
181  for(std::vector<CPPL_INT>::iterator q=rows[I].begin(); q!=rows_I_end; q++){
182  if(*q==C){ *q=c; break; }
183  }
184  const std::vector<CPPL_INT>::iterator cols_J_end =cols[J].end();
185  for(std::vector<CPPL_INT>::iterator q=cols[J].begin(); q!=cols_J_end; q++){
186  if(*q==C){ *q=c; break; }
187  }
188  //// pop_back ////
189  data.pop_back();
190  }
191 
192  return *this;
193 }
_dgematrix i(const _dgbmatrix &mat)
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: zgsmatrix.hpp:12
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: zgsmatrix.hpp:13
void zgsmatrix::write ( const char *  filename) const
inline

Definition at line 223 of file zgsmatrix-io.hpp.

References data, m, and n.

224 {CPPL_VERBOSE_REPORT;
225  std::ofstream ofs(filename, std::ios::trunc);
226  ofs.setf(std::cout.flags());
227  ofs.precision(std::cout.precision());
228  ofs.width(std::cout.width());
229  ofs.fill(std::cout.fill());
230 
231  ofs << "#zgsmatrix " << m << " " << n << " " << data.size() << std::endl;
232 
233  const std::vector<zcomponent>::const_iterator data_end =data.end();
234  for(std::vector<zcomponent>::const_iterator it=data.begin(); it!=data_end; it++){
235  ofs << it->i << " " << it->j << " " << it->v << std::endl;
236  }
237 
238  ofs.close();
239 }
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
void zgsmatrix::read ( const char *  filename)
inline

Definition at line 242 of file zgsmatrix-io.hpp.

References data, i(), m, n, put(), and resize().

Referenced by zgsmatrix().

243 {CPPL_VERBOSE_REPORT;
244  std::ifstream s( filename );
245  if(!s){
246  ERROR_REPORT;
247  std::cerr << "The file \"" << filename << "\" can not be opened." << std::endl;
248  exit(1);
249  }
250 
251  std::string id;
252  s >> id;
253  if( id != "zgsmatrix" && id != "#zgsmatrix" ){
254  ERROR_REPORT;
255  std::cerr << "The type name of the file \"" << filename << "\" is not zgsmatrix." << std::endl
256  << "Its type name was " << id << " ." << std::endl;
257  exit(1);
258  }
259 
260  //////// m, n, size ////////
261  size_t size;
262  s >> m >> n >> size;
263  resize(m, n);
264  data.reserve(size);
265 
266  //////// i, j, v ////////
267  CPPL_INT i, j;
268  comple v;
269  for(size_t k=0; k<size; k++){
270  s >> i >> j >> v;
271  put(i,j, v);
272  }
273 
274  //// check ////
275  s >> i;
276  if(!s.eof()){
277  ERROR_REPORT;
278  std::cerr << "There is something is wrong with the file \"" << filename << " ." << std::endl
279  << "Most likely, there are too many data components over the context." << std::endl;
280  exit(1);
281  }
282  s.close();
283 }
zgsmatrix & resize(const CPPL_INT &, const CPPL_INT &, const CPPL_INT=0, const CPPL_INT=0)
_dgematrix i(const _dgbmatrix &mat)
zgsmatrix & put(const CPPL_INT &, const CPPL_INT &, const comple &)
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
void zgsmatrix::clear ( )
inline

clear all the matrix data and set the sizes 0

Definition at line 3 of file zgsmatrix-misc.hpp.

References cols, data, m, n, and rows.

4 {CPPL_VERBOSE_REPORT;
5  m =0;
6  n =0;
7  data.clear();
8  rows.clear();
9  cols.clear();
10 }
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: zgsmatrix.hpp:12
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: zgsmatrix.hpp:13
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
zgsmatrix & zgsmatrix::zero ( )
inline

change the matrix into a zero matrix

Definition at line 14 of file zgsmatrix-misc.hpp.

References cols, data, i(), m, n, and rows.

Referenced by col(), identity(), row(), to_zgematrix(), _zhsmatrix::to_zgsmatrix(), and zhsmatrix::to_zgsmatrix().

15 {CPPL_VERBOSE_REPORT;
16  data.resize(0);
17  for(CPPL_INT i=0; i<m; i++){ rows[i].resize(0); }
18  for(CPPL_INT j=0; j<n; j++){ cols[j].resize(0); }
19  return *this;
20 }
_dgematrix i(const _dgbmatrix &mat)
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: zgsmatrix.hpp:12
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: zgsmatrix.hpp:13
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
zgsmatrix & zgsmatrix::identity ( )
inline

change the matrix into an identity matrix

Definition at line 24 of file zgsmatrix-misc.hpp.

References i(), m, n, put(), and zero().

25 {CPPL_VERBOSE_REPORT;
26 #ifdef CPPL_DEBUG
27  if(m!=n){
28  ERROR_REPORT;
29  std::cerr << "Only square matrix can be a identity matrix." << std::endl
30  << "The matrix size was " << m << "x" << n << "." << std::endl;
31  exit(1);
32  }
33 #endif//CPPL_DEBUG
34 
35  zero();
36  for(CPPL_INT i=0; i<m; i++){
37  put(i,i, comple(1.,0.));
38  }
39  return *this;
40 }
_dgematrix i(const _dgbmatrix &mat)
zgsmatrix & put(const CPPL_INT &, const CPPL_INT &, const comple &)
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
zgsmatrix & zero()
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
void zgsmatrix::chsign ( )
inline

change sign(+/-) of the matrix

Definition at line 44 of file zgsmatrix-misc.hpp.

References data.

Referenced by operator-().

45 {CPPL_VERBOSE_REPORT;
46  const std::vector<zcomponent>::iterator data_end =data.end();
47  for(std::vector<zcomponent>::iterator it=data.begin(); it!=data_end; it++){
48  it->v =-it->v;
49  }
50 }
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
void zgsmatrix::copy ( const zgsmatrix mat)
inline

make a deep copy of the matrix

Definition at line 54 of file zgsmatrix-misc.hpp.

References cols, data, m, n, and rows.

Referenced by operator=(), and zgsmatrix().

55 {CPPL_VERBOSE_REPORT;
56  m =mat.m;
57  n =mat.n;
58  data =mat.data;
59  rows =mat.rows;
60  cols =mat.cols;
61 }
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: zgsmatrix.hpp:12
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: zgsmatrix.hpp:13
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
void zgsmatrix::shallow_copy ( const _zgsmatrix mat)
inline

make a shallow copy of the matrix
This function is not designed to be used in project codes.

Definition at line 66 of file zgsmatrix-misc.hpp.

References cols, _zgsmatrix::cols, _zgsmatrix::data, data, m, _zgsmatrix::m, _zgsmatrix::n, n, _zgsmatrix::nullify(), rows, and _zgsmatrix::rows.

Referenced by operator=().

67 {CPPL_VERBOSE_REPORT;
68  data.clear();
69  rows.clear();
70  cols.clear();
71 
72  m =mat.m;
73  n =mat.n;
74  data.swap(mat.data);
75  rows.swap(mat.rows);
76  cols.swap(mat.cols);
77 
78  mat.nullify();
79 }
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: _zgsmatrix.hpp:12
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: _zgsmatrix.hpp:13
CPPL_INT n
matrix column size
Definition: _zgsmatrix.hpp:10
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: zgsmatrix.hpp:12
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: _zgsmatrix.hpp:9
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: zgsmatrix.hpp:13
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
void nullify() const
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
std::vector< zcomponent > data
matrix data
Definition: _zgsmatrix.hpp:11
zgsmatrix & zgsmatrix::resize ( const CPPL_INT &  _m,
const CPPL_INT &  _n,
const CPPL_INT  _c = 0,
const CPPL_INT  _l = 0 
)
inline

resize the matrix

Definition at line 83 of file zgsmatrix-misc.hpp.

References cols, data, i(), m, n, and rows.

Referenced by read().

84 {CPPL_VERBOSE_REPORT;
85 #ifdef CPPL_DEBUG
86  if( _m<0 || _n<0 || _c<0 ){
87  ERROR_REPORT;
88  std::cerr << "Matrix sizes and the length of arrays must be positive integers. " << std::endl
89  << "Your input was (" << _m << "," << _n << "," << _c << "," << _l << ")." << std::endl;
90  exit(1);
91  }
92 #endif//CPPL_DEBUG
93 
94  m =_m;
95  n =_n;
96  data.resize(0);
97  data.reserve(_c);
98  rows.resize(m);
99  for(CPPL_INT i=0; i<m; i++){
100  rows[i].resize(0);
101  rows[i].reserve(_l);
102  }
103  cols.resize(n);
104  for(CPPL_INT i=0; i<n; i++){
105  cols[i].resize(0);
106  cols[i].reserve(_l);
107  }
108 
109  return *this;
110 }
_dgematrix i(const _dgbmatrix &mat)
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: zgsmatrix.hpp:12
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: zgsmatrix.hpp:13
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
void zgsmatrix::stretch ( const CPPL_INT &  dm,
const CPPL_INT &  dn 
)
inline

stretch the matrix size

Definition at line 114 of file zgsmatrix-misc.hpp.

References cols, data, del(), i(), m, n, and rows.

115 {CPPL_VERBOSE_REPORT;
116 #ifdef CPPL_DEBUG
117  if( m+dm<0 || n+dn<0 ){
118  ERROR_REPORT;
119  std::cerr << "The new matrix size must be larger than zero. " << std::endl
120  << "Your input was (" << dm << ", " << dn << ")." << std::endl;
121  exit(1);
122  }
123 #endif//CPPL_DEBUG
124 
125  //////// zero ////////
126  if(dm==0 && dn==0){ return; }
127 
128  //////// non-zero ////////
129  m +=dm;
130  n +=dn;
131 
132  //// for rows ////
133  if(dm<0){
134  //// delete components over the new size ////
135  const std::vector<zcomponent>::reverse_iterator data_rend =data.rend();
136  for(std::vector<zcomponent>::reverse_iterator it=data.rbegin(); it!=data_rend; it++){
137  if( it->i>=m ){ del( CPPL_INT(data_rend-it-1) ); }
138  }
139  //// shrink rows ////
140  for(CPPL_INT i=0; i<-dm; i++){
141  rows.pop_back();
142  }
143  }
144  else{//dm>0
145  //// expand rows ////
146  for(CPPL_INT i=0; i<dm; i++){
147  rows.push_back( std::vector<CPPL_INT>(0) );
148  }
149  }
150 
151  //// for cols ////
152  if(dn<0){
153  //// delete components over the new size ////
154  const std::vector<zcomponent>::reverse_iterator data_rend =data.rend();
155  for(std::vector<zcomponent>::reverse_iterator it=data.rbegin(); it!=data_rend; it++){
156  if( it->j>=n ){ del( CPPL_INT(data_rend-it-1) ); }
157  }
158  for(CPPL_INT j=0; j<-dn; j++){
159  cols.pop_back();
160  }
161  }
162  else{//dn>0
163  //// expand cols ////
164  for(CPPL_INT j=0; j<dn; j++){
165  cols.push_back( std::vector<CPPL_INT>(0) );
166  }
167  }
168 }
zgsmatrix & del(const CPPL_INT, const CPPL_INT)
_dgematrix i(const _dgbmatrix &mat)
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: zgsmatrix.hpp:12
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: zgsmatrix.hpp:13
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
void zgsmatrix::expand ( const CPPL_INT &  )
inline
bool zgsmatrix::isListed ( const CPPL_INT &  i,
const CPPL_INT &  j 
)
inline

check if the component is listed

Definition at line 172 of file zgsmatrix-misc.hpp.

References data, i(), m, n, and rows.

Referenced by put().

173 {CPPL_VERBOSE_REPORT;
174 #ifdef CPPL_DEBUG
175  if( i<0 || j<0 || m<=i || n<=j ){
176  ERROR_REPORT;
177  std::cerr << "The required component is out of the matrix size." << std::endl
178  << "Your input is (" << i << "," << j << "), whereas the matrix size is " << m << "x" << n << "." << std::endl;
179  exit(1);
180  }
181 #endif//CPPL_DEBUG
182 
183  const std::vector<CPPL_INT>::const_iterator rows_i_end =rows[i].end();
184  for(std::vector<CPPL_INT>::const_iterator p=rows[i].begin(); p!=rows_i_end; p++){
185  if( data[*p].j==j ){ return 1; }
186  }
187 
188  return 0;
189 }
_dgematrix i(const _dgbmatrix &mat)
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: zgsmatrix.hpp:12
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
CPPL_INT zgsmatrix::number ( const CPPL_INT &  i,
const CPPL_INT &  j 
)
inline

return the element number of the component

Definition at line 193 of file zgsmatrix-misc.hpp.

References data, i(), m, n, and rows.

194 {CPPL_VERBOSE_REPORT;
195 #ifdef CPPL_DEBUG
196  if( i<0 || j<0 || m<=i || n<=j ){
197  ERROR_REPORT;
198  std::cerr << "The required component is out of the matrix size." << std::endl
199  << "Your input is (" << i << "," << j << "), whereas the matrix size is " << m << "x" << n << "." << std::endl;
200  exit(1);
201  }
202 #endif//CPPL_DEBUG
203 
204  const std::vector<CPPL_INT>::iterator rows_i_end =rows[i].end();
205  for(std::vector<CPPL_INT>::iterator p=rows[i].begin(); p!=rows_i_end; p++){
206  if( data[*p].j==j ){ return *p; }
207  }
208 
209  return -1;
210 }
_dgematrix i(const _dgbmatrix &mat)
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: zgsmatrix.hpp:12
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
void zgsmatrix::checkup ( )
inline

health checkup

Definition at line 224 of file zgsmatrix-misc.hpp.

References data, m, and n.

225 {CPPL_VERBOSE_REPORT;
226  //////////////// data ////////////////
227  //////// check i,j ////////
228  const std::vector<zcomponent>::const_iterator data_end =data.end();
229  for(std::vector<zcomponent>::const_iterator it=data.begin(); it!=data_end; it++){
230  if( it->i>=m || it->j>=n ){
231  ERROR_REPORT;
232  std::cerr << "A component, (" << it->i << ", " << it->j << "), is out of matrix size." << std::endl;
233  exit(1);
234  }
235  }
236  //////// check double listing ////////
237 
238  //////////////// rows ////////////////
239  //////////////// cols ////////////////
240 
241  //////////////// NOTE ////////////////
242  std::cerr << "# [NOTE] zgsmatrix::checkup(): This sparse matrix is fine." << std::endl;
243 }
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
void zgsmatrix::diet ( const double  eps = DBL_MIN)
inline

erase components less than DBL_MIN

Definition at line 214 of file zgsmatrix-misc.hpp.

References data, and del().

215 {CPPL_VERBOSE_REPORT;
216  const std::vector<zcomponent>::reverse_iterator data_rend =data.rend();
217  for(std::vector<zcomponent>::reverse_iterator it=data.rbegin(); it!=data_rend; it++){
218  if( fabs(it->v.real())<eps && fabs(it->v.imag())<eps ){ del( CPPL_INT(data_rend-it-1) ); }
219  }
220 }
zgsmatrix & del(const CPPL_INT, const CPPL_INT)
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
_zrovector zgsmatrix::row ( const CPPL_INT &  _m) const
inline

get row of the matrix

Definition at line 251 of file zgsmatrix-misc.hpp.

References _, data, m, n, rows, and zero().

252 {CPPL_VERBOSE_REPORT;
253 #ifdef CPPL_DEBUG
254  if( _m<0 || _m>m ){
255  ERROR_REPORT;
256  std::cerr << "Input row number must be between 0 and " << m << "." << std::endl
257  << "Your input was " << _m << "." << std::endl;
258  exit(1);
259  }
260 #endif//CPPL_DEBUG
261 
262  zrovector vec( zrovector(n).zero() );
263 
264  const std::vector<CPPL_INT>::const_iterator rows__m_end =rows[_m].end();
265  for(std::vector<CPPL_INT>::const_iterator p=rows[_m].begin(); p!=rows__m_end; p++){
266  vec(data[*p].j) =data[*p].v;
267  }
268 
269  return _(vec);
270 }
friend _zgsmatrix _(zgsmatrix &)
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: zgsmatrix.hpp:12
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
Complex Double-precision Row Vector Class.
Definition: zrovector.hpp:3
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
zgsmatrix & zero()
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
_zcovector zgsmatrix::col ( const CPPL_INT &  _n) const
inline

get column of the matrix

Definition at line 274 of file zgsmatrix-misc.hpp.

References _, cols, data, i(), m, n, and zero().

275 {CPPL_VERBOSE_REPORT;
276 #ifdef CPPL_DEBUG
277  if( _n<0 || _n>n ){
278  ERROR_REPORT;
279  std::cerr << "Input row number must be between 0 and " << n << "." << std::endl
280  << "Your input was " << _n << "." << std::endl;
281  exit(1);
282  }
283 #endif//CPPL_DEBUG
284 
285  zcovector vec( zcovector(m).zero() );
286 
287  const std::vector<CPPL_INT>::const_iterator cols__n_end =cols[_n].end();
288  for(std::vector<CPPL_INT>::const_iterator p=cols[_n].begin(); p!=cols__n_end; p++){
289  vec(data[*p].i) =data[*p].v;
290  }
291 
292  return _(vec);
293 }
friend _zgsmatrix _(zgsmatrix &)
_dgematrix i(const _dgbmatrix &mat)
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: zgsmatrix.hpp:13
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
zgsmatrix & zero()
Complex Double-precision Column Vector Class.
Definition: zcovector.hpp:3
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
zgsmatrix & zgsmatrix::operator= ( const zgsmatrix mat)
inline

zgsmatrix=zgsmatrix operator

Definition at line 3 of file zgsmatrix-zgsmatrix.hpp.

References copy(), and data.

4 {CPPL_VERBOSE_REPORT;
5  if(&data!=&mat.data){ // if it is NOT self substitution
6  copy(mat);
7  }
8  return *this;
9 }
void copy(const zgsmatrix &)
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
zgsmatrix & zgsmatrix::operator= ( const _zgsmatrix mat)
inline

zgsmatrix=_zgsmatrix operator

Definition at line 3 of file zgsmatrix-_zgsmatrix.hpp.

References shallow_copy().

4 {CPPL_VERBOSE_REPORT;
5  shallow_copy(mat);
6  return *this;
7 }
void shallow_copy(const _zgsmatrix &)
zgsmatrix & zgsmatrix::operator+= ( const zgsmatrix mat)
inline

zgsmatrix+=zgsmatrix operator

Definition at line 17 of file zgsmatrix-zgsmatrix.hpp.

References data, m, and n.

18 {CPPL_VERBOSE_REPORT;
19 #ifdef CPPL_DEBUG
20  if(n!=mat.n || m!=mat.m){
21  ERROR_REPORT;
22  std::cerr << "These two matrises can not make a summation." << std::endl
23  << "Your input was (" << m << "x" << n << ") += (" << mat.m << "x" << mat.n << ")." << std::endl;
24  exit(1);
25  }
26 #endif//CPPL_DEBUG
27 
28  const std::vector<zcomponent>::const_iterator mat_data_end =mat.data.end();
29  for(std::vector<zcomponent>::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 }
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
zgsmatrix & zgsmatrix::operator+= ( const _zgsmatrix mat)
inline

zgsmatrix+=_zgsmatrix operator

Definition at line 15 of file zgsmatrix-_zgsmatrix.hpp.

References _zgsmatrix::data, _zgsmatrix::destroy(), _zgsmatrix::m, m, n, and _zgsmatrix::n.

16 {CPPL_VERBOSE_REPORT;
17 #ifdef CPPL_DEBUG
18  if(n!=mat.n || m!=mat.m){
19  ERROR_REPORT;
20  std::cerr << "These two matrises can not make a summation." << std::endl
21  << "Your input was (" << m << "x" << n << ") += (" << mat.m << "x" << mat.n << ")." << std::endl;
22  exit(1);
23  }
24 #endif//CPPL_DEBUG
25 
26  const std::vector<zcomponent>::const_iterator mat_data_end =mat.data.end();
27  for(std::vector<zcomponent>::const_iterator it=mat.data.begin(); it!=mat_data_end; it++){
28  (*this)(it->i,it->j) += it->v;
29  }
30 
31  mat.destroy();
32  return *this;
33 }
CPPL_INT n
matrix column size
Definition: _zgsmatrix.hpp:10
CPPL_INT m
matrix row size
Definition: _zgsmatrix.hpp:9
void destroy() const
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
std::vector< zcomponent > data
matrix data
Definition: _zgsmatrix.hpp:11
zgsmatrix & zgsmatrix::operator-= ( const zgsmatrix mat)
inline

zgsmatrix-=zgsmatrix operator

Definition at line 38 of file zgsmatrix-zgsmatrix.hpp.

References data, m, and n.

39 {CPPL_VERBOSE_REPORT;
40 #ifdef CPPL_DEBUG
41  if(n!=mat.n || m!=mat.m){
42  ERROR_REPORT;
43  std::cerr << "These two matrises can not make a sutraction." << std::endl
44  << "Your input was (" << m << "x" << n << ") -= (" << mat.m << "x" << mat.n << ")." << std::endl;
45  exit(1);
46  }
47 #endif//CPPL_DEBUG
48 
49  const std::vector<zcomponent>::const_iterator mat_data_end =mat.data.end();
50  for(std::vector<zcomponent>::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 }
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
zgsmatrix & zgsmatrix::operator-= ( const _zgsmatrix mat)
inline

zgsmatrix-=_zgsmatrix operator

Definition at line 37 of file zgsmatrix-_zgsmatrix.hpp.

References _zgsmatrix::data, _zgsmatrix::destroy(), _zgsmatrix::m, m, n, and _zgsmatrix::n.

38 {CPPL_VERBOSE_REPORT;
39 #ifdef CPPL_DEBUG
40  if(n!=mat.n || m!=mat.m){
41  ERROR_REPORT;
42  std::cerr << "These two matrises can not make a sutraction." << std::endl
43  << "Your input was (" << m << "x" << n << ") -= (" << mat.m << "x" << mat.n << ")." << std::endl;
44  exit(1);
45  }
46 #endif//CPPL_DEBUG
47 
48  const std::vector<zcomponent>::const_iterator mat_data_end =mat.data.end();
49  for(std::vector<zcomponent>::const_iterator it=mat.data.begin(); it!=mat_data_end; it++){
50  (*this)(it->i,it->j) -= it->v;
51  }
52 
53  mat.destroy();
54  return *this;
55 }
CPPL_INT n
matrix column size
Definition: _zgsmatrix.hpp:10
CPPL_INT m
matrix row size
Definition: _zgsmatrix.hpp:9
void destroy() const
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
std::vector< zcomponent > data
matrix data
Definition: _zgsmatrix.hpp:11
zgsmatrix & zgsmatrix::operator*= ( const zgsmatrix mat)
inline

zgsmatrix*=zgsmatrix operator

Definition at line 59 of file zgsmatrix-zgsmatrix.hpp.

References data, m, n, rows, and swap.

60 {CPPL_VERBOSE_REPORT;
61 #ifdef CPPL_DEBUG
62  if(n!=mat.m){
63  ERROR_REPORT;
64  std::cerr << "These two matrises can not make a product." << std::endl
65  << "Your input was (" << m << "x" << n << ") *= (" << mat.m << "x" << mat.n << ")." << std::endl;
66  exit(1);
67  }
68 #endif//CPPL_DEBUG
69 
70  zgsmatrix newmat(m, mat.n);
71 
72  const std::vector<zcomponent>::const_iterator data_end =data.end();
73  for(std::vector<zcomponent>::const_iterator it=data.begin(); it!=data_end; it++){
74  CPPL_INT k =it->j;
75  const std::vector<CPPL_INT>::const_iterator mat_rows_k_end =mat.rows[k].end();
76  for(std::vector<CPPL_INT>::const_iterator p=mat.rows[k].begin(); p!=mat_rows_k_end; p++){
77  newmat(it->i,mat.data[*p].j) +=it->v*mat.data[*p].v;
78  }
79  }
80 
81  swap(*this,newmat);
82  return *this;
83 }
Complex Double-precision General Sparse Matrix Class.
Definition: zgsmatrix.hpp:3
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: zgsmatrix.hpp:12
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
friend void swap(zgsmatrix &, zgsmatrix &)
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
zgsmatrix & zgsmatrix::operator*= ( const _zgsmatrix mat)
inline

zgsmatrix*=_zgsmatrix operator

Definition at line 59 of file zgsmatrix-_zgsmatrix.hpp.

References data, _zgsmatrix::data, _zgsmatrix::destroy(), _zgsmatrix::m, m, n, _zgsmatrix::n, _zgsmatrix::rows, and swap.

60 {CPPL_VERBOSE_REPORT;
61 #ifdef CPPL_DEBUG
62  if(n!=mat.m){
63  ERROR_REPORT;
64  std::cerr << "These two matrises can not make a product." << std::endl
65  << "Your input was (" << m << "x" << n << ") *= (" << mat.m << "x" << mat.n << ")." << std::endl;
66  exit(1);
67  }
68 #endif//CPPL_DEBUG
69 
70  zgsmatrix newmat( m, mat.n, 0 );
71 
72  const std::vector<zcomponent>::const_iterator data_end =data.end();
73  for(std::vector<zcomponent>::const_iterator it=data.begin(); it!=data_end; it++){
74  CPPL_INT k =it->j;
75  const std::vector<CPPL_INT>::iterator mat_rows_k_end =mat.rows[k].end();
76  for(std::vector<CPPL_INT>::iterator p=mat.rows[k].begin(); p!=mat_rows_k_end; p++){
77  newmat(it->i,mat.data[*p].j) += it->v*mat.data[*p].v;
78  }
79  }
80 
81  swap(*this,newmat);
82  mat.destroy();
83  return *this;
84 }
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: _zgsmatrix.hpp:12
Complex Double-precision General Sparse Matrix Class.
Definition: zgsmatrix.hpp:3
CPPL_INT n
matrix column size
Definition: _zgsmatrix.hpp:10
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
friend void swap(zgsmatrix &, zgsmatrix &)
CPPL_INT m
matrix row size
Definition: _zgsmatrix.hpp:9
void destroy() const
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
std::vector< zcomponent > data
matrix data
Definition: _zgsmatrix.hpp:11
zgsmatrix & zgsmatrix::operator*= ( const double &  d)
inline

zgsmatrix*=double operator

Definition at line 3 of file zgsmatrix-double.hpp.

References data.

4 {CPPL_VERBOSE_REPORT;
5  const std::vector<zcomponent>::iterator data_end =data.end();
6  for(std::vector<zcomponent>::iterator it=data.begin(); it!=data_end; it++){
7  it->v *=d;
8  }
9 
10  return *this;
11 }
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
zgsmatrix & zgsmatrix::operator*= ( const comple &  d)
inline

zgsmatrix*=comple operator

Definition at line 3 of file zgsmatrix-complex.hpp.

References data.

4 {CPPL_VERBOSE_REPORT;
5  const std::vector<zcomponent>::iterator data_end =data.end();
6  for(std::vector<zcomponent>::iterator it=data.begin(); it!=data_end; it++){
7  it->v *=d;
8  }
9 
10  return *this;
11 }
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
zgsmatrix & zgsmatrix::operator/= ( const double &  d)
inline

zgsmatrix/=double operator

Definition at line 15 of file zgsmatrix-double.hpp.

References data.

16 {CPPL_VERBOSE_REPORT;
17  const std::vector<zcomponent>::iterator data_end =data.end();
18  for(std::vector<zcomponent>::iterator it=data.begin(); it!=data_end; it++){
19  it->v /=d;
20  }
21  return *this;
22 }
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
zgsmatrix & zgsmatrix::operator/= ( const comple &  d)
inline

zgsmatrix/=comple operator

Definition at line 15 of file zgsmatrix-complex.hpp.

References data.

16 {CPPL_VERBOSE_REPORT;
17  const std::vector<zcomponent>::iterator data_end =data.end();
18  for(std::vector<zcomponent>::iterator it=data.begin(); it!=data_end; it++){
19  it->v /=d;
20  }
21 
22  return *this;
23 }
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  s,
const zgsmatrix mat 
)
friend

Definition at line 200 of file zgsmatrix-io.hpp.

201 {CPPL_VERBOSE_REPORT;
202  for(CPPL_INT i=0; i<mat.m; i++){
203  const std::vector<CPPL_INT>::const_iterator mat_rows_i_end =mat.rows[i].end();
204  for(CPPL_INT j=0; j<mat.n; j++){
205  std::vector<CPPL_INT>::const_iterator q;
206  for(q=mat.rows[i].begin(); q!=mat_rows_i_end; q++){
207  if(mat.data[*q].j==j){ break; }
208  }
209  if(q!=mat_rows_i_end){ s << " " << mat.data[*q].v; }
210  else{ s << " x"; }
211  }
212  s << std::endl;
213  }
214 
215  return s;
216 }
_dgematrix i(const _dgbmatrix &mat)
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: zgsmatrix.hpp:12
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
void swap ( zgsmatrix A,
zgsmatrix B 
)
friend

swap two matrices

Definition at line 301 of file zgsmatrix-misc.hpp.

Referenced by operator*=().

302 {CPPL_VERBOSE_REPORT;
303  std::swap(A.n,B.n);
304  std::swap(A.m,B.m);
305  std::swap(A.data,B.data);
306  std::swap(A.rows,B.rows);
307  std::swap(A.cols,B.cols);
308 }
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: zgsmatrix.hpp:12
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
void swap(zgsmatrix &A, zgsmatrix &B)
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: zgsmatrix.hpp:13
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
_zgsmatrix _ ( zgsmatrix mat)
friend

convert user object to smart-temporary object

Definition at line 312 of file zgsmatrix-misc.hpp.

Referenced by col(), row(), and to_zgematrix().

313 {CPPL_VERBOSE_REPORT;
314  _zgsmatrix newmat;
315 
316  //////// shallow copy ////////
317  newmat.n =mat.n;
318  newmat.m =mat.m;
319  std::swap(newmat.data,mat.data);
320  std::swap(newmat.rows,mat.rows);
321  std::swap(newmat.cols,mat.cols);
322 
323  //////// nullify ////////
324  mat.m =0;
325  mat.n =0;
326 
327  return newmat;
328 }
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: _zgsmatrix.hpp:12
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: _zgsmatrix.hpp:13
CPPL_INT n
matrix column size
Definition: _zgsmatrix.hpp:10
(DO NOT USE) Smart-temporary Real Double-precision General Sparse Matrix Class
Definition: _zgsmatrix.hpp:3
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: zgsmatrix.hpp:12
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
void swap(zgsmatrix &A, zgsmatrix &B)
CPPL_INT m
matrix row size
Definition: _zgsmatrix.hpp:9
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: zgsmatrix.hpp:13
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
std::vector< zcomponent > data
matrix data
Definition: _zgsmatrix.hpp:11
_zgsmatrix t ( const zgsmatrix mat)
friend

return transposed zgsmatrix

Definition at line 3 of file zgsmatrix-calc.hpp.

4 {CPPL_VERBOSE_REPORT;
5  zgsmatrix newmat =mat;
6 
7  std::swap(newmat.m,newmat.n);
8  std::swap(newmat.rows,newmat.cols);
9  const std::vector<zcomponent>::iterator newmat_data_end =newmat.data.end();
10  for(std::vector<zcomponent>::iterator it=newmat.data.begin(); it!=newmat_data_end; it++){
11  std::swap(it->i,it->j);
12  }
13 
14  return _(newmat);
15 }
Complex Double-precision General Sparse Matrix Class.
Definition: zgsmatrix.hpp:3
friend _zgsmatrix _(zgsmatrix &)
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: zgsmatrix.hpp:12
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
void swap(dcovector &u, dcovector &v)
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
Definition: zgsmatrix.hpp:13
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
_zgsmatrix conj ( const zgsmatrix mat)
friend

return its conjugate matrix

Definition at line 23 of file zgsmatrix-calc.hpp.

24 {CPPL_VERBOSE_REPORT;
25  zgsmatrix newmat(mat);
26 
27  const std::vector<zcomponent>::iterator newmat_data_end =newmat.data.end();
28  for(std::vector<zcomponent>::iterator it=newmat.data.begin(); it!=newmat_data_end; it++){
29  it->v =std::conj(it->v);
30  }
31 
32  return _(newmat);
33 }
Complex Double-precision General Sparse Matrix Class.
Definition: zgsmatrix.hpp:3
friend _zgsmatrix _(zgsmatrix &)
_zgsmatrix conj(const zgsmatrix &mat)
_zgsmatrix conjt ( const zgsmatrix mat)
friend

return its conjugate transposed matrix

Definition at line 37 of file zgsmatrix-calc.hpp.

38 {CPPL_VERBOSE_REPORT;
39  zgsmatrix newmat(mat);
40  std::swap(newmat.rows,newmat.cols);
41 
42  const std::vector<zcomponent>::iterator newmat_data_end =newmat.data.end();
43  for(std::vector<zcomponent>::iterator it=newmat.data.begin(); it!=newmat_data_end; it++){
44  std::swap(it->i,it->j);
45  it->v =std::conj(it->v);
46  }
47 
48  return _(newmat);
49 }
Complex Double-precision General Sparse Matrix Class.
Definition: zgsmatrix.hpp:3
friend _zgsmatrix _(zgsmatrix &)
void swap(dcovector &u, dcovector &v)
_zgsmatrix conj(const zgsmatrix &mat)
void idamax ( CPPL_INT &  i,
CPPL_INT &  j,
const zgsmatrix mat 
)
friend

search the index of element having the largest absolute value in 0-based numbering system

Definition at line 57 of file zgsmatrix-calc.hpp.

58 {CPPL_VERBOSE_REPORT;
59  std::vector<zcomponent>::const_iterator itx(mat.data.begin());
60  double vmax =0.;
61 
62  const std::vector<zcomponent>::const_iterator mat_data_end =mat.data.end();
63  for(std::vector<zcomponent>::const_iterator it=mat.data.begin(); it!=mat_data_end; it++){
64  if( vmax < norm(it->v) ){
65  vmax =norm(it->v);
66  itx =it;
67  }
68  }
69 
70  i=itx->i;
71  j=itx->j;
72 }
_dgematrix i(const _dgbmatrix &mat)
friend _dgematrix i(const _dgematrix &)
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
comple damax ( const zgsmatrix mat)
friend

return its largest absolute value

Definition at line 76 of file zgsmatrix-calc.hpp.

77 {CPPL_VERBOSE_REPORT;
78  std::vector<zcomponent>::const_iterator itx(mat.data.begin());
79  double vmax =0.;
80 
81  const std::vector<zcomponent>::const_iterator mat_data_end =mat.data.end();
82  for(std::vector<zcomponent>::const_iterator it=mat.data.begin(); it!=mat_data_end; it++){
83  if( vmax < norm(it->v) ){
84  vmax =norm(it->v);
85  itx =it;
86  }
87  }
88 
89  return itx->v;
90 }
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
const zgsmatrix& operator+ ( const zgsmatrix mat)
friend

+zgsmatrix operator

Definition at line 3 of file zgsmatrix-unary.hpp.

4 {CPPL_VERBOSE_REPORT;
5  return mat;
6 }
_zgsmatrix operator- ( const zgsmatrix mat)
friend

-zgsmatrix operator

Definition at line 10 of file zgsmatrix-unary.hpp.

11 {CPPL_VERBOSE_REPORT;
12  zgsmatrix newmat(mat);
13 
14  const std::vector<zcomponent>::iterator newmat_data_end =newmat.data.end();
15  for(std::vector<zcomponent>::iterator it=newmat.data.begin(); it!=newmat_data_end; it++){
16  it->v =-it->v;
17  }
18 
19  return _(newmat);
20 }
Complex Double-precision General Sparse Matrix Class.
Definition: zgsmatrix.hpp:3
friend _zgsmatrix _(zgsmatrix &)
_zgematrix operator+ ( const zgsmatrix matA,
const zgematrix matB 
)
friend

zgsmatrix+zgematrix operator

Definition at line 3 of file zgsmatrix-zgematrix.hpp.

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 
14  zgematrix newmat(matB);
15 
16  const std::vector<zcomponent>::const_iterator matA_data_end =matA.data.end();
17  for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
18  newmat(it->i,it->j) += it->v;
19  }
20 
21  return _(newmat);
22 }
friend _zgsmatrix _(zgsmatrix &)
CPPL_INT n
matrix column size
Definition: zgematrix.hpp:10
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: zgematrix.hpp:9
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
_zgematrix operator+ ( const zgsmatrix matA,
const _zgematrix matB 
)
friend

zgsmatrix+_zgematrix operator

Definition at line 3 of file zgsmatrix-_zgematrix.hpp.

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 
14  const std::vector<zcomponent>::const_iterator matA_data_end =matA.data.end();
15  for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
16  matB(it->i,it->j) += it->v;
17  }
18 
19  return matB;
20 }
CPPL_INT m
matrix row size
Definition: _zgematrix.hpp:9
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
CPPL_INT n
matrix column size
Definition: _zgematrix.hpp:10
_zgematrix operator+ ( const zgsmatrix matA,
const zhematrix matB 
)
friend

zgsmatrix+zhematrix operator

Definition at line 3 of file zgsmatrix-zhematrix.hpp.

4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if(matA.m!=matB.n || 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.n << "x" << matB.n << ")." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13 
14  zgematrix newmat( matB.to_zgematrix() );
15 
16  const std::vector<zcomponent>::const_iterator matA_data_end =matA.data.end();
17  for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
18  newmat(it->i,it->j) += it->v;
19  }
20 
21  return _(newmat);
22 }
friend _zgsmatrix _(zgsmatrix &)
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
_zgematrix to_zgematrix() const
CPPL_INT n
matrix column size
Definition: zhematrix.hpp:11
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
_zgematrix operator+ ( const zgsmatrix matA,
const _zhematrix matB 
)
friend

zgsmatrix+_zhematrix operator

Definition at line 3 of file zgsmatrix-_zhematrix.hpp.

4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if(matA.m!=matB.n || 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.n << "x" << matB.n << ")." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13 
14  zgematrix newmat( matB.to_zgematrix() );
15 
16  const std::vector<zcomponent>::const_iterator matA_data_end =matA.data.end();
17  for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
18  newmat(it->i,it->j) += it->v;
19  }
20 
21  matB.destroy();
22  return _(newmat);
23 }
friend _zgsmatrix _(zgsmatrix &)
CPPL_INT n
matrix column size
Definition: _zhematrix.hpp:11
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
void destroy() const
_zgematrix to_zgematrix() const
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
_zgematrix operator+ ( const zgsmatrix matA,
const zgbmatrix matB 
)
friend

zgsmatrix+zgbmatrix operator

Definition at line 3 of file zgsmatrix-zgbmatrix.hpp.

4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if(matA.n!=matB.n || matA.m!=matB.m){
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 
14  zgematrix newmat( matA.to_zgematrix() );
15 
16  for(CPPL_INT i=0; i<matB.m; i++){
17  const CPPL_INT jmax =std::min(matB.n,i+matB.ku+1);
18  for(CPPL_INT j=std::max(CPPL_INT(0),i-matB.kl); j<jmax; j++){
19  newmat(i,j) +=matB(i,j);
20  }
21  }
22 
23  return _(newmat);
24 }
friend _zgsmatrix _(zgsmatrix &)
_dgematrix i(const _dgbmatrix &mat)
CPPL_INT n
matrix column size
Definition: zgbmatrix.hpp:10
CPPL_INT ku
upper band width
Definition: zgbmatrix.hpp:12
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
_zgematrix to_zgematrix() const
CPPL_INT m
matrix row size
Definition: zgbmatrix.hpp:9
CPPL_INT kl
lower band width
Definition: zgbmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
_zgematrix operator+ ( const zgsmatrix matA,
const _zgbmatrix matB 
)
friend

zgsmatrix+_zgbmatrix operator

Definition at line 3 of file zgsmatrix-_zgbmatrix.hpp.

4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if(matA.n!=matB.n || matA.m!=matB.m){
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 
14  zgematrix newmat( matA.to_zgematrix() );
15 
16  for(CPPL_INT i=0; i<matB.m; i++){
17  const CPPL_INT jmax =std::min(matB.n,i+matB.ku+1);
18  for(CPPL_INT j=std::max(CPPL_INT(0),i-matB.kl); j<jmax; j++){
19  newmat(i,j) +=matB(i,j);
20  }
21  }
22 
23  matB.destroy();
24  return _(newmat);
25 }
CPPL_INT ku
upper band width
Definition: _zgbmatrix.hpp:12
friend _zgsmatrix _(zgsmatrix &)
CPPL_INT kl
lower band width
Definition: _zgbmatrix.hpp:11
_dgematrix i(const _dgbmatrix &mat)
void destroy() const
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
_zgematrix to_zgematrix() const
CPPL_INT m
matrix row size
Definition: _zgbmatrix.hpp:9
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
CPPL_INT n
matrix column size
Definition: _zgbmatrix.hpp:10
_zgsmatrix operator+ ( const zgsmatrix matA,
const zgsmatrix matB 
)
friend

zgsmatrix+zgsmatrix operator

Definition at line 91 of file zgsmatrix-zgsmatrix.hpp.

92 {CPPL_VERBOSE_REPORT;
93 #ifdef CPPL_DEBUG
94  if(matA.n!=matB.n || matA.m!=matB.m){
95  ERROR_REPORT;
96  std::cerr << "These two matrises can not make a summation." << std::endl
97  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
98  exit(1);
99  }
100 #endif//CPPL_DEBUG
101 
102  zgsmatrix newmat(matA);
103 
104  const std::vector<zcomponent>::const_iterator matB_data_end =matB.data.end();
105  for(std::vector<zcomponent>::const_iterator it=matB.data.begin(); it!=matB_data_end; it++){
106  newmat(it->i, it->j) +=it->v;
107  }
108 
109  return _(newmat);
110 }
Complex Double-precision General Sparse Matrix Class.
Definition: zgsmatrix.hpp:3
friend _zgsmatrix _(zgsmatrix &)
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
_zgsmatrix operator+ ( const zgsmatrix matA,
const _zgsmatrix matB 
)
friend

zgsmatrix+_zgsmatrix operator

Definition at line 92 of file zgsmatrix-_zgsmatrix.hpp.

93 {CPPL_VERBOSE_REPORT;
94 #ifdef CPPL_DEBUG
95  if(matA.n!=matB.n || matA.m!=matB.m){
96  ERROR_REPORT;
97  std::cerr << "These two matrises can not make a summation." << std::endl
98  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
99  exit(1);
100  }
101 #endif//CPPL_DEBUG
102 
103  zgsmatrix newmat(matB);
104 
105  const std::vector<zcomponent>::const_iterator matA_data_end =matA.data.end();
106  for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
107  newmat(it->i,it->j) += it->v;
108  }
109 
110  return _(newmat);
111 }
Complex Double-precision General Sparse Matrix Class.
Definition: zgsmatrix.hpp:3
friend _zgsmatrix _(zgsmatrix &)
CPPL_INT n
matrix column size
Definition: _zgsmatrix.hpp:10
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: _zgsmatrix.hpp:9
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
_zgsmatrix operator+ ( const zgsmatrix ,
const zhsmatrix  
)
friend
_zgsmatrix operator+ ( const zgsmatrix ,
const _zhsmatrix  
)
friend
_zgematrix operator- ( const zgsmatrix matA,
const zgematrix matB 
)
friend

zgsmatrix-zgematrix operator

Definition at line 26 of file zgsmatrix-zgematrix.hpp.

27 {CPPL_VERBOSE_REPORT;
28 #ifdef CPPL_DEBUG
29  if(matA.m!=matB.m || matA.n!=matB.n){
30  ERROR_REPORT;
31  std::cerr << "These two matrises can not make a subtraction." << std::endl
32  << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
33  exit(1);
34  }
35 #endif//CPPL_DEBUG
36 
37  zgematrix newmat(-matB);
38 
39  const std::vector<zcomponent>::const_iterator matA_data_end =matA.data.end();
40  for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
41  newmat(it->i,it->j) += it->v;
42  }
43 
44  return _(newmat);
45 }
friend _zgsmatrix _(zgsmatrix &)
CPPL_INT n
matrix column size
Definition: zgematrix.hpp:10
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: zgematrix.hpp:9
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
_zgematrix operator- ( const zgsmatrix matA,
const _zgematrix matB 
)
friend

zgsmatrix-_zgematrix operator

Definition at line 24 of file zgsmatrix-_zgematrix.hpp.

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

zgsmatrix-zhematrix operator

Definition at line 26 of file zgsmatrix-zhematrix.hpp.

27 {CPPL_VERBOSE_REPORT;
28 #ifdef CPPL_DEBUG
29  if(matA.m!=matB.n || matA.n!=matB.n){
30  ERROR_REPORT;
31  std::cerr << "These two matrises can not make a subtraction." << std::endl
32  << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
33  exit(1);
34  }
35 #endif//CPPL_DEBUG
36 
37  //// shallow copy to zgematrix ////
38  zgematrix newmat( (-matB).to_zgematrix() );
39 
40  //// add ////
41  const std::vector<zcomponent>::const_iterator matA_data_end =matA.data.end();
42  for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
43  newmat(it->i,it->j) += it->v;
44  }
45 
46  return _(newmat);
47 }
friend _zgsmatrix _(zgsmatrix &)
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT n
matrix column size
Definition: zhematrix.hpp:11
_zgematrix to_zgematrix() const
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
_zgematrix operator- ( const zgsmatrix matA,
const _zhematrix matB 
)
friend

zgsmatrix-_zhematrix operator

Definition at line 27 of file zgsmatrix-_zhematrix.hpp.

28 {CPPL_VERBOSE_REPORT;
29 #ifdef CPPL_DEBUG
30  if(matA.m!=matB.n || matA.n!=matB.n){
31  ERROR_REPORT;
32  std::cerr << "These two matrises can not make a subtraction." << std::endl
33  << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
34  exit(1);
35  }
36 #endif//CPPL_DEBUG
37 
38  zgematrix newmat( (-matB).to_zgematrix() );
39 
40  const std::vector<zcomponent>::const_iterator matA_data_end =matA.data.end();
41  for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
42  newmat(it->i,it->j) += it->v;
43  }
44 
45  matB.destroy();
46  return _(newmat);
47 }
friend _zgsmatrix _(zgsmatrix &)
CPPL_INT n
matrix column size
Definition: _zhematrix.hpp:11
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
_zgematrix to_zgematrix() const
void destroy() const
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
_zgematrix operator- ( const zgsmatrix matA,
const zgbmatrix matB 
)
friend

zgsmatrix-zgbmatrix operator

Definition at line 28 of file zgsmatrix-zgbmatrix.hpp.

29 {CPPL_VERBOSE_REPORT;
30 #ifdef CPPL_DEBUG
31  if(matA.n!=matB.n || matA.m!=matB.m){
32  ERROR_REPORT;
33  std::cerr << "These two matrises can not make a summation." << std::endl
34  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
35  exit(1);
36  }
37 #endif//CPPL_DEBUG
38 
39  zgematrix newmat( matA.to_zgematrix() );
40 
41  for(CPPL_INT i=0; i<matB.m; i++){
42  const CPPL_INT jmax =std::min(matB.n,i+matB.ku+1);
43  for(CPPL_INT j=std::max(CPPL_INT(0),i-matB.kl); j<jmax; j++){
44  newmat(i,j) -=matB(i,j);
45  }
46  }
47 
48  return _(newmat);
49 }
friend _zgsmatrix _(zgsmatrix &)
_dgematrix i(const _dgbmatrix &mat)
CPPL_INT n
matrix column size
Definition: zgbmatrix.hpp:10
CPPL_INT ku
upper band width
Definition: zgbmatrix.hpp:12
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
_zgematrix to_zgematrix() const
CPPL_INT m
matrix row size
Definition: zgbmatrix.hpp:9
CPPL_INT kl
lower band width
Definition: zgbmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
_zgematrix operator- ( const zgsmatrix matA,
const _zgbmatrix matB 
)
friend

zgsmatrix-_zgbmatrix operator

Definition at line 29 of file zgsmatrix-_zgbmatrix.hpp.

30 {CPPL_VERBOSE_REPORT;
31 #ifdef CPPL_DEBUG
32  if(matA.n!=matB.n || matA.m!=matB.m){
33  ERROR_REPORT;
34  std::cerr << "These two matrises can not make a summation." << std::endl
35  << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
36  exit(1);
37  }
38 #endif//CPPL_DEBUG
39 
40  zgematrix newmat( matA.to_zgematrix() );
41 
42  for(CPPL_INT i=0; i<matB.m; i++){
43  const CPPL_INT jmax =std::min(matB.n,i+matB.ku+1);
44  for(CPPL_INT j=std::max(CPPL_INT(0),i-matB.kl); j<jmax; j++){
45  newmat(i,j) -=matB(i,j);
46  }
47  }
48 
49  matB.destroy();
50  return _(newmat);
51 }
CPPL_INT ku
upper band width
Definition: _zgbmatrix.hpp:12
friend _zgsmatrix _(zgsmatrix &)
CPPL_INT kl
lower band width
Definition: _zgbmatrix.hpp:11
_dgematrix i(const _dgbmatrix &mat)
void destroy() const
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
_zgematrix to_zgematrix() const
CPPL_INT m
matrix row size
Definition: _zgbmatrix.hpp:9
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
CPPL_INT n
matrix column size
Definition: _zgbmatrix.hpp:10
_zgsmatrix operator- ( const zgsmatrix matA,
const zgsmatrix matB 
)
friend

zgsmatrix-zgsmatrix operator

Definition at line 114 of file zgsmatrix-zgsmatrix.hpp.

115 {CPPL_VERBOSE_REPORT;
116 #ifdef CPPL_DEBUG
117  if(matA.n!=matB.n || matA.m!=matB.m){
118  ERROR_REPORT;
119  std::cerr << "These two matrises can not make a subtraction." << std::endl
120  << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.m << "x" << matB.n << ")." << std::endl;
121  exit(1);
122  }
123 #endif//CPPL_DEBUG
124 
125  zgsmatrix newmat(matA);
126 
127  const std::vector<zcomponent>::const_iterator matB_data_end =matB.data.end();
128  for(std::vector<zcomponent>::const_iterator it=matB.data.begin(); it!=matB_data_end; it++){
129  newmat(it->i, it->j) -=it->v;
130  }
131 
132  return _(newmat);
133 }
Complex Double-precision General Sparse Matrix Class.
Definition: zgsmatrix.hpp:3
friend _zgsmatrix _(zgsmatrix &)
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
_zgsmatrix operator- ( const zgsmatrix matA,
const _zgsmatrix matB 
)
friend

zgsmatrix-_zgsmatrix operator

Definition at line 115 of file zgsmatrix-_zgsmatrix.hpp.

116 {CPPL_VERBOSE_REPORT;
117 #ifdef CPPL_DEBUG
118  if(matA.n!=matB.n || matA.m!=matB.m){
119  ERROR_REPORT;
120  std::cerr << "These two matrises can not make a subtraction." << std::endl
121  << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.m << "x" << matB.n << ")." << std::endl;
122  exit(1);
123  }
124 #endif//CPPL_DEBUG
125 
126  zgsmatrix newmat(matB);
127  newmat.chsign();
128 
129  const std::vector<zcomponent>::const_iterator matA_data_end =matA.data.end();
130  for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
131  newmat(it->i,it->j) += it->v;
132  }
133 
134  return _(newmat);
135 }
Complex Double-precision General Sparse Matrix Class.
Definition: zgsmatrix.hpp:3
friend _zgsmatrix _(zgsmatrix &)
CPPL_INT n
matrix column size
Definition: _zgsmatrix.hpp:10
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: _zgsmatrix.hpp:9
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
_zgsmatrix operator- ( const zgsmatrix ,
const zhsmatrix  
)
friend
_zgsmatrix operator- ( const zgsmatrix ,
const _zhsmatrix  
)
friend
_zcovector operator* ( const zgsmatrix mat,
const zcovector vec 
)
friend

zgsmatrix*zcovector operator

Definition at line 3 of file zgsmatrix-zcovector.hpp.

4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if(mat.n!=vec.l){
7  ERROR_REPORT;
8  std::cerr << "These matrix and vector can not make a product." << std::endl
9  << "Your input was (" << mat.m << "x" << mat.n << ") * (" << vec.l << ")." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13 
14  zcovector newvec(mat.m);
15  newvec.zero();
16 
17  const std::vector<zcomponent>::const_iterator mat_data_end =mat.data.end();
18  for(std::vector<zcomponent>::const_iterator it=mat.data.begin(); it!=mat_data_end; it++){
19  newvec(it->i) += it->v*vec(it->j);
20  }
21 
22  return _(newvec);
23 }
friend _zgsmatrix _(zgsmatrix &)
CPPL_INT l
vector size
Definition: zcovector.hpp:9
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
Complex Double-precision Column Vector Class.
Definition: zcovector.hpp:3
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
_zcovector operator* ( const zgsmatrix mat,
const _zcovector vec 
)
friend

zgsmatrix*_zcovector operator

Definition at line 3 of file zgsmatrix-_zcovector.hpp.

4 {CPPL_VERBOSE_REPORT;
5 #ifdef CPPL_DEBUG
6  if(mat.n!=vec.l){
7  ERROR_REPORT;
8  std::cerr << "These matrix and vector can not make a product." << std::endl
9  << "Your input was (" << mat.m << "x" << mat.n << ") * (" << vec.l << ")." << std::endl;
10  exit(1);
11  }
12 #endif//CPPL_DEBUG
13 
14  zcovector newvec(mat.m);
15  newvec.zero();
16 
17  const std::vector<zcomponent>::const_iterator mat_data_end =mat.data.end();
18  for(std::vector<zcomponent>::const_iterator it=mat.data.begin(); it!=mat_data_end; it++){
19  newvec(it->i) += it->v*vec(it->j);
20  }
21 
22  vec.destroy();
23  return _(newvec);
24 }
friend _zgsmatrix _(zgsmatrix &)
void destroy() const
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
Complex Double-precision Column Vector Class.
Definition: zcovector.hpp:3
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
CPPL_INT l
vector size
Definition: _zcovector.hpp:9
_zgematrix operator* ( const zgsmatrix matA,
const zgematrix matB 
)
friend

zgsmatrix*zgematrix operator

Definition at line 49 of file zgsmatrix-zgematrix.hpp.

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

zgsmatrix*_zgematrix operator

Definition at line 51 of file zgsmatrix-_zgematrix.hpp.

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

zgsmatrix*zhematrix operator

Definition at line 51 of file zgsmatrix-zhematrix.hpp.

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

zgsmatrix*_zhematrix operator

Definition at line 51 of file zgsmatrix-_zhematrix.hpp.

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

zgsmatrix*zgbmatrix operator

Definition at line 53 of file zgsmatrix-zgbmatrix.hpp.

54 {CPPL_VERBOSE_REPORT;
55 #ifdef CPPL_DEBUG
56  if(matA.n!=matB.m){
57  ERROR_REPORT;
58  std::cerr << "These two matrises can not make a product." << std::endl
59  << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
60  exit(1);
61  }
62 #endif//CPPL_DEBUG
63 
64  zgematrix newmat( matA.m, matB.n );
65  newmat.zero();
66 
67  const std::vector<zcomponent>::const_iterator matA_data_end =matA.data.end();
68  for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
69  const CPPL_INT jmax =std::min(matB.n,it->j+matB.ku+1);
70  for(CPPL_INT j=std::max(CPPL_INT(0),it->j-matB.kl); j<jmax; j++){
71  newmat(it->i,j) += it->v*matB(it->j,j);
72  }
73  }
74 
75  return _(newmat);
76 }
friend _zgsmatrix _(zgsmatrix &)
CPPL_INT n
matrix column size
Definition: zgbmatrix.hpp:10
CPPL_INT ku
upper band width
Definition: zgbmatrix.hpp:12
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: zgbmatrix.hpp:9
CPPL_INT kl
lower band width
Definition: zgbmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
_zgematrix operator* ( const zgsmatrix matA,
const _zgbmatrix matB 
)
friend

zgsmatrix*_zgbmatrix operator

Definition at line 55 of file zgsmatrix-_zgbmatrix.hpp.

56 {CPPL_VERBOSE_REPORT;
57 #ifdef CPPL_DEBUG
58  if(matA.n!=matB.m){
59  ERROR_REPORT;
60  std::cerr << "These two matrises can not make a product." << std::endl
61  << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
62  exit(1);
63  }
64 #endif//CPPL_DEBUG
65 
66  zgematrix newmat( matA.m, matB.n );
67  newmat.zero();
68 
69  const std::vector<zcomponent>::const_iterator matA_data_end =matA.data.end();
70  for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
71  const CPPL_INT jmax =std::min(matB.n,it->j+matB.ku+1);
72  for(CPPL_INT j=std::max(CPPL_INT(0),it->j-matB.kl); j<jmax; j++){
73  newmat(it->i,j) += it->v*matB(it->j,j);
74  }
75  }
76 
77  matB.destroy();
78  return _(newmat);
79 }
CPPL_INT ku
upper band width
Definition: _zgbmatrix.hpp:12
friend _zgsmatrix _(zgsmatrix &)
CPPL_INT kl
lower band width
Definition: _zgbmatrix.hpp:11
void destroy() const
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: _zgbmatrix.hpp:9
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
CPPL_INT n
matrix column size
Definition: _zgbmatrix.hpp:10
_zgsmatrix operator* ( const zgsmatrix matA,
const zgsmatrix matB 
)
friend

zgsmatrix*zgsmatrix operator

Definition at line 137 of file zgsmatrix-zgsmatrix.hpp.

138 {CPPL_VERBOSE_REPORT;
139 #ifdef CPPL_DEBUG
140  if(matA.n!=matB.m){
141  ERROR_REPORT;
142  std::cerr << "These two matrises can not make a product." << std::endl
143  << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
144  exit(1);
145  }
146 #endif//CPPL_DEBUG
147 
148  zgsmatrix newmat(matA.m, matB.n);
149 
150  const std::vector<zcomponent>::const_iterator matA_data_end =matA.data.end();
151  for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
152  CPPL_INT k =it->j;
153  const std::vector<CPPL_INT>::const_iterator matB_rows_k_end =matB.rows[k].end();
154  for(std::vector<CPPL_INT>::const_iterator p=matB.rows[k].begin(); p!=matB_rows_k_end; p++){
155  newmat(it->i,matB.data[*p].j) +=it->v*matB.data[*p].v;
156  }
157  }
158 
159  return _(newmat);
160 }
Complex Double-precision General Sparse Matrix Class.
Definition: zgsmatrix.hpp:3
friend _zgsmatrix _(zgsmatrix &)
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: zgsmatrix.hpp:12
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
_zgsmatrix operator* ( const zgsmatrix matA,
const _zgsmatrix matB 
)
friend

zgsmatrix*_zgsmatrix operator

Definition at line 139 of file zgsmatrix-_zgsmatrix.hpp.

140 {CPPL_VERBOSE_REPORT;
141 #ifdef CPPL_DEBUG
142  if(matA.n!=matB.m){
143  ERROR_REPORT;
144  std::cerr << "These two matrises can not make a product." << std::endl
145  << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
146  exit(1);
147  }
148 #endif//CPPL_DEBUG
149 
150  zgsmatrix newmat(matA.m, matB.n);
151 
152  const std::vector<zcomponent>::const_iterator matA_data_end =matA.data.end();
153  for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA_data_end; it++){
154  CPPL_INT k =it->j;
155  const std::vector<CPPL_INT>::iterator matB_rows_k_end =matB.rows[k].end();
156  for(std::vector<CPPL_INT>::iterator p=matB.rows[k].begin(); p!=matB_rows_k_end; p++){
157  newmat(it->i,matB.data[*p].j) += it->v*matB.data[*p].v;
158  }
159  }
160 
161  matB.destroy();
162  return _(newmat);
163 }
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
Definition: _zgsmatrix.hpp:12
Complex Double-precision General Sparse Matrix Class.
Definition: zgsmatrix.hpp:3
friend _zgsmatrix _(zgsmatrix &)
CPPL_INT n
matrix column size
Definition: _zgsmatrix.hpp:10
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
CPPL_INT m
matrix row size
Definition: _zgsmatrix.hpp:9
void destroy() const
CPPL_INT m
matrix row size
Definition: zgsmatrix.hpp:9
CPPL_INT n
matrix column size
Definition: zgsmatrix.hpp:10
std::vector< zcomponent > data
matrix data
Definition: _zgsmatrix.hpp:11
_zgsmatrix operator* ( const zgsmatrix ,
const zhsmatrix  
)
friend
_zgsmatrix operator* ( const zgsmatrix ,
const _zhsmatrix  
)
friend
_zgsmatrix operator* ( const zgsmatrix mat,
const double &  d 
)
friend

zgsmatrix*double operator

Definition at line 30 of file zgsmatrix-double.hpp.

31 {CPPL_VERBOSE_REPORT;
32  zgsmatrix newmat(mat);
33 
34  const std::vector<zcomponent>::iterator newmat_data_end =newmat.data.end();
35  for(std::vector<zcomponent>::iterator it=newmat.data.begin(); it!=newmat_data_end; it++){
36  it->v *=d;
37  }
38 
39  return _(newmat);
40 }
Complex Double-precision General Sparse Matrix Class.
Definition: zgsmatrix.hpp:3
friend _zgsmatrix _(zgsmatrix &)
_zgsmatrix operator* ( const zgsmatrix mat,
const comple &  d 
)
friend

zgsmatrix*comple operator

Definition at line 31 of file zgsmatrix-complex.hpp.

32 {CPPL_VERBOSE_REPORT;
33  zgsmatrix newmat(mat);
34 
35  const std::vector<zcomponent>::iterator newmat_data_end =newmat.data.end();
36  for(std::vector<zcomponent>::iterator it=newmat.data.begin(); it!=newmat_data_end; it++){
37  it->v *=d;
38  }
39 
40  return _(newmat);
41 }
Complex Double-precision General Sparse Matrix Class.
Definition: zgsmatrix.hpp:3
friend _zgsmatrix _(zgsmatrix &)
_zgsmatrix operator/ ( const zgsmatrix mat,
const double &  d 
)
friend

zgsmatrix/double operator

Definition at line 44 of file zgsmatrix-double.hpp.

45 {CPPL_VERBOSE_REPORT;
46  zgsmatrix newmat(mat);
47 
48  const std::vector<zcomponent>::iterator newmat_data_end =newmat.data.end();
49  for(std::vector<zcomponent>::iterator it=newmat.data.begin(); it!=newmat_data_end; it++){
50  it->v /=d;
51  }
52 
53  return _(newmat);
54 }
Complex Double-precision General Sparse Matrix Class.
Definition: zgsmatrix.hpp:3
friend _zgsmatrix _(zgsmatrix &)
_zgsmatrix operator/ ( const zgsmatrix mat,
const comple &  d 
)
friend

zgsmatrix/comple operator

Definition at line 45 of file zgsmatrix-complex.hpp.

46 {CPPL_VERBOSE_REPORT;
47  zgsmatrix newmat(mat);
48 
49  const std::vector<zcomponent>::iterator newmat_data_end =newmat.data.end();
50  for(std::vector<zcomponent>::iterator it=newmat.data.begin(); it!=newmat_data_end; it++){
51  it->v /=d;
52  }
53 
54  return _(newmat);
55 }
Complex Double-precision General Sparse Matrix Class.
Definition: zgsmatrix.hpp:3
friend _zgsmatrix _(zgsmatrix &)
_zgsmatrix operator* ( const double &  d,
const zgsmatrix mat 
)
friend

double*zgsmatrix operator

Definition at line 3 of file double-zgsmatrix.hpp.

4 {CPPL_VERBOSE_REPORT;
5  zgsmatrix newmat =mat;
6 
7  const std::vector<zcomponent>::iterator newmat_data_end =newmat.data.end();
8  for(std::vector<zcomponent>::iterator it=newmat.data.begin(); it!=newmat_data_end; it++){
9  it->v *= d;
10  }
11 
12  return _(newmat);
13 }
Complex Double-precision General Sparse Matrix Class.
Definition: zgsmatrix.hpp:3
friend _zgsmatrix _(zgsmatrix &)
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11
_zgsmatrix operator* ( const comple &  d,
const zgsmatrix mat 
)
friend

complex*zgsmatrix operator

Definition at line 3 of file complex-zgsmatrix.hpp.

4 {CPPL_VERBOSE_REPORT;
5  zgsmatrix newmat =mat;
6 
7  const std::vector<zcomponent>::iterator newmat_data_end =newmat.data.end();
8  for(std::vector<zcomponent>::iterator it=newmat.data.begin(); it!=newmat_data_end; it++){
9  it->v *= d;
10  }
11 
12  return _(newmat);
13 }
Complex Double-precision General Sparse Matrix Class.
Definition: zgsmatrix.hpp:3
friend _zgsmatrix _(zgsmatrix &)
std::vector< zcomponent > data
matrix data
Definition: zgsmatrix.hpp:11

Member Data Documentation

CPPL_INT zgsmatrix::m
CPPL_INT zgsmatrix::n
std::vector<zcomponent> zgsmatrix::data
std::vector< std::vector<CPPL_INT> > zgsmatrix::rows

array of vector to store the entry information of component for each row

Definition at line 12 of file zgsmatrix.hpp.

Referenced by _(), clear(), conjt(), copy(), del(), isListed(), number(), operator()(), operator*(), operator*=(), operator<<(), put(), resize(), row(), shallow_copy(), stretch(), swap(), t(), zero(), zgsmatrix(), and ~zgsmatrix().

std::vector< std::vector<CPPL_INT> > zgsmatrix::cols

array of vector to store the entry information of component for each column

Definition at line 13 of file zgsmatrix.hpp.

Referenced by _(), clear(), col(), conjt(), copy(), del(), operator()(), put(), resize(), shallow_copy(), stretch(), swap(), t(), zero(), zgsmatrix(), and ~zgsmatrix().


The documentation for this class was generated from the following files: