CPPLapack
 All Classes Files Functions Variables Friends Pages
Public Member Functions | Public Attributes | Friends | List of all members
zgematrix_small< m, n > Class Template Reference

Samll Complex Double-precision General Dence Matrix Class. More...

#include <zgematrix_small.hpp>

Public Member Functions

 zgematrix_small ()
 
 zgematrix_small (const zgematrix &)
 
 ~zgematrix_small ()
 
_zgematrix to_zgematrix () const
 
comple & operator() (const CPPL_INT &i, const CPPL_INT &j)
 
comple operator() (const CPPL_INT &i, const CPPL_INT &j) const
 
zgematrix_small< m, n > & set (const CPPL_INT &i, const CPPL_INT &j, const comple &v)
 
void read (const char *filename)
 
void write (const char *filename) const
 
zgematrix_small< m, n > & zero ()
 
zgematrix_small< m, n > & identity ()
 
zcovector_small< m > col (const CPPL_INT &j) const
 
zrovector_small< n > row (const CPPL_INT &i) const
 
template<CPPL_INT M, CPPL_INT N>
zgematrix_small< M, N > & operator= (const zgematrix_small< M, N > &)
 

Public Attributes

comple array [m *n]
 

Friends

template<CPPL_INT _m, CPPL_INT _n>
std::ostream & operator<< (std::ostream &, const zgematrix_small< _m, _n > &)
 
template<CPPL_INT _m, CPPL_INT _n>
zgematrix_small< n, m > t (const zgematrix_small< m, n > &)
 
template<CPPL_INT M, CPPL_INT N>
zgematrix_small< M, N > & operator+= (zgematrix_small< M, N > &, const zgematrix_small< M, N > &)
 
template<CPPL_INT M, CPPL_INT N>
zgematrix_small< M, N > & operator-= (zgematrix_small< M, N > &, const zgematrix_small< M, N > &)
 
template<CPPL_INT M, CPPL_INT L, CPPL_INT N>
zgematrix_small< M, N > & operator*= (zgematrix_small< M, L > &, const zgematrix_small< L, N > &)
 
template<CPPL_INT M, CPPL_INT N>
zgematrix_small< M, N > & operator*= (zgematrix_small< M, N > &, const double &)
 
template<CPPL_INT M, CPPL_INT N>
zgematrix_small< M, N > & operator*= (zgematrix_small< M, N > &, const comple &)
 
template<CPPL_INT M, CPPL_INT N>
zgematrix_small< M, N > & operator/= (zgematrix_small< M, N > &, const double &)
 
template<CPPL_INT M, CPPL_INT N>
zgematrix_small< M, N > & operator/= (zgematrix_small< M, N > &, const comple &)
 
template<CPPL_INT M, CPPL_INT N>
const zgematrix_small< M, N > & operator+ (const zgematrix_small< M, N > &)
 
template<CPPL_INT M, CPPL_INT N>
zgematrix_small< M, N > operator- (const zgematrix_small< M, N > &)
 
template<CPPL_INT M, CPPL_INT N>
zgematrix_small< M, N > operator+ (const zgematrix_small< M, N > &, const zgematrix_small< M, N > &)
 
template<CPPL_INT M, CPPL_INT N>
zgematrix_small< M, N > operator+ (const zgematrix_small< M, N > &, const zhematrix_small< N > &)
 
template<CPPL_INT M, CPPL_INT N>
zgematrix_small< M, N > operator- (const zgematrix_small< M, N > &, const zgematrix_small< M, N > &)
 
template<CPPL_INT M, CPPL_INT N>
zgematrix_small< M, N > operator- (const zgematrix_small< M, N > &, const zhematrix_small< N > &)
 
template<CPPL_INT M, CPPL_INT N>
zcovector_small< M > operator* (const zgematrix_small< M, N > &, const zcovector_small< N > &)
 
template<CPPL_INT M, CPPL_INT L, CPPL_INT N>
zgematrix_small< M, N > operator* (const zgematrix_small< M, L > &, const zgematrix_small< L, N > &)
 
template<CPPL_INT M, CPPL_INT N>
zgematrix_small< M, N > operator* (const zgematrix_small< M, N > &, const zhematrix_small< N > &)
 
template<CPPL_INT M, CPPL_INT N>
zgematrix_small< M, N > operator* (const zgematrix_small< M, N > &, const double &)
 
template<CPPL_INT M, CPPL_INT N>
zgematrix_small< M, N > operator* (const zgematrix_small< M, N > &, const comple &)
 
template<CPPL_INT M, CPPL_INT N>
zgematrix_small< M, N > operator/ (const zgematrix_small< M, N > &, const double &)
 
template<CPPL_INT M, CPPL_INT N>
zgematrix_small< M, N > operator/ (const zgematrix_small< M, N > &, const comple &)
 
template<CPPL_INT M, CPPL_INT N>
zgematrix_small< M, N > operator* (const double &, const zgematrix_small< M, N > &)
 
template<CPPL_INT M, CPPL_INT N>
zgematrix_small< M, N > operator* (const comple &, const zgematrix_small< M, N > &)
 
template<CPPL_INT M, CPPL_INT N>
zgematrix_small< M, N > hadamerd (const zgematrix_small< M, N > &, const zgematrix_small< M, N > &)
 
template<CPPL_INT N>
zgematrix_small< N, N > hadamerd (const zgematrix_small< N, N > &, const zhematrix_small< N > &)
 

Detailed Description

template<CPPL_INT m, CPPL_INT n>
class zgematrix_small< m, n >

Samll Complex Double-precision General Dence Matrix Class.

Definition at line 3 of file zgematrix_small.hpp.

Constructor & Destructor Documentation

template<CPPL_INT m, CPPL_INT n>
zgematrix_small< m, n >::zgematrix_small ( )
inline

zgematrix_small constructor

Definition at line 4 of file zgematrix_small-constructors.hpp.

5 {CPPL_VERBOSE_REPORT;
6  ;
7 }
template<CPPL_INT m, CPPL_INT n>
zgematrix_small< m, n >::zgematrix_small ( const zgematrix mat)
inlineexplicit

zgematrix_small constructor

Definition at line 12 of file zgematrix_small-constructors.hpp.

References zgematrix::array, zgematrix::m, and zgematrix::n.

13 {CPPL_VERBOSE_REPORT;
14 #ifdef CPPL_DEBUG
15  if( m!=mat.m || n!=mat.n ){
16  ERROR_REPORT;
17  std::cerr << "Matrix sizes must be the same." << std::endl
18  << "Your input was " << m << "x" << n << " and " << mat.m << "x" << mat.n << "." << std::endl;
19  exit(1);
20  }
21 #endif//CPPL_DEBUG
22 
23  for(CPPL_INT k=0; k<m*n; k++){
24  array[k] =mat.array[k];
25  }
26 }
comple array[m *n]
CPPL_INT n
matrix column size
Definition: zgematrix.hpp:10
comple * array
1D array to store matrix data
Definition: zgematrix.hpp:11
CPPL_INT m
matrix row size
Definition: zgematrix.hpp:9
template<CPPL_INT m, CPPL_INT n>
zgematrix_small< m, n >::~zgematrix_small ( )
inline

zgematrix_small destructor

Definition at line 35 of file zgematrix_small-constructors.hpp.

36 {CPPL_VERBOSE_REPORT;
37  ;
38 }

Member Function Documentation

template<CPPL_INT m, CPPL_INT n>
_zgematrix zgematrix_small< m, n >::to_zgematrix ( ) const
inline

convert zgematrix_small to zgematrix

Definition at line 4 of file zgematrix_small-functions.hpp.

References _(), and i().

5 {CPPL_VERBOSE_REPORT;
6  zgematrix mat(m,n);
7  for(CPPL_INT i=0; i<m; i++){
8  for(CPPL_INT j=0; j<n; j++){
9  mat(i,j) =(*this)(i,j);
10  }
11  }
12  return _(mat);
13 }
_dgematrix i(const _dgbmatrix &mat)
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
_dcovector _(dcovector &vec)
template<CPPL_INT m, CPPL_INT n>
comple & zgematrix_small< m, n >::operator() ( const CPPL_INT &  i,
const CPPL_INT &  j 
)
inline

operator()

Definition at line 22 of file zgematrix_small-functions.hpp.

23 {CPPL_VERBOSE_REPORT;
24 #ifdef CPPL_DEBUG
25  if( i<0 || j<0 || m<=i || n<=j ){
26  ERROR_REPORT;
27  std::cerr << "The required component is out of the matrix size." << std::endl
28  << "Your input is (" << i << "," << j << "), whereas the matrix size is " << m << "x" << n << "." << std::endl;
29  exit(1);
30  }
31 #endif//CPPL_DEBUG
32 
33  return array[i+m*j];
34 }
comple array[m *n]
_dgematrix i(const _dgbmatrix &mat)
template<CPPL_INT m, CPPL_INT n>
comple zgematrix_small< m, n >::operator() ( const CPPL_INT &  i,
const CPPL_INT &  j 
) const
inline

operator() for const

Definition at line 39 of file zgematrix_small-functions.hpp.

40 {CPPL_VERBOSE_REPORT;
41 #ifdef CPPL_DEBUG
42  if( i<0 || j<0 || m<=i || n<=j ){
43  ERROR_REPORT;
44  std::cerr << "The required component is out of the matrix size." << std::endl
45  << "Your input is (" << i << "," << j << "), whereas the matrix size is " << m << "x" << n << "." << std::endl;
46  exit(1);
47  }
48 #endif//CPPL_DEBUG
49 
50  return array[i+m*j];
51 }
comple array[m *n]
_dgematrix i(const _dgbmatrix &mat)
template<CPPL_INT m, CPPL_INT n>
zgematrix_small< m, n > & zgematrix_small< m, n >::set ( const CPPL_INT &  i,
const CPPL_INT &  j,
const comple &  v 
)
inline

set

Definition at line 56 of file zgematrix_small-functions.hpp.

References i().

57 {CPPL_VERBOSE_REPORT;
58  (*this)(i,j) =v;
59  return *this;
60 }
_dgematrix i(const _dgbmatrix &mat)
template<CPPL_INT m, CPPL_INT n>
void zgematrix_small< m, n >::read ( const char *  filename)
inline

read from file

Definition at line 100 of file zgematrix_small-functions.hpp.

References i().

101 {CPPL_VERBOSE_REPORT;
102  std::ifstream s( filename );
103  if(!s){
104  ERROR_REPORT;
105  std::cerr << "The file \"" << filename << "\" can not be opened." << std::endl;
106  exit(1);
107  }
108 
109  std::string id;
110  s >> id;
111  if( id != "zgematrix" && id != "#zgematrix" ){
112  ERROR_REPORT;
113  std::cerr << "The type name of the file \"" << filename << "\" is not zgematrix." << std::endl
114  << "Its type name was " << id << " ." << std::endl;
115  exit(1);
116  }
117 
118  CPPL_INT _m, _n;
119  s >> _m >> _n;
120  if(m!=_m || n!=_n){
121  ERROR_REPORT;
122  std::cerr << "Matrix size is invalid." << std::endl;
123  exit(1);
124  }
125  for(CPPL_INT i=0; i<m; i++){
126  for(CPPL_INT j=0; j<n; j++ ){
127  s >> operator()(i,j);
128  }
129  }
130  if(s.eof()){
131  ERROR_REPORT;
132  std::cerr << "There is something is wrong with the file \"" << filename << "\"." << std::endl
133  << "Most likely, there is not enough data components, or a linefeed code or space code is missing at the end of the last line." << std::endl;
134  exit(1);
135  }
136 
137  s >> id;
138  if(!s.eof()){
139  ERROR_REPORT;
140  std::cerr << "There is something is wrong with the file \"" << filename << "\"." << std::endl
141  << "Most likely, there are extra data components." << std::endl;
142  exit(1);
143  }
144 
145  s.close();
146 }
_dgematrix i(const _dgbmatrix &mat)
comple & operator()(const CPPL_INT &i, const CPPL_INT &j)
template<CPPL_INT m, CPPL_INT n>
void zgematrix_small< m, n >::write ( const char *  filename) const
inline

write to file

Definition at line 80 of file zgematrix_small-functions.hpp.

References i().

81 {CPPL_VERBOSE_REPORT;
82  std::ofstream ofs(filename, std::ios::trunc);
83  ofs.setf(std::cout.flags());
84  ofs.precision(std::cout.precision());
85  ofs.width(std::cout.width());
86  ofs.fill(std::cout.fill());
87  ofs << "#zgematrix" << " " << m << " " << n << std::endl;
88  for(CPPL_INT i=0; i<m; i++){
89  for(CPPL_INT j=0; j<n; j++){
90  ofs << (*this)(i,j) << " ";
91  }
92  ofs << std::endl;
93  }
94  ofs.close();
95 }
_dgematrix i(const _dgbmatrix &mat)
template<CPPL_INT m, CPPL_INT n>
zgematrix_small< m, n > & zgematrix_small< m, n >::zero ( )
inline

zero

Definition at line 191 of file zgematrix_small-functions.hpp.

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

192 {CPPL_VERBOSE_REPORT;
193  for(CPPL_INT k=0; k<m*n; k++){
194  array[k] =comple(0.,0.);
195  }
196 
197  return *this;
198 }
comple array[m *n]
template<CPPL_INT m, CPPL_INT n>
zgematrix_small< m, n > & zgematrix_small< m, n >::identity ( )
inline

identity

Definition at line 203 of file zgematrix_small-functions.hpp.

204 {CPPL_VERBOSE_REPORT;
205  zero();
206 
207  const CPPL_INT kmax =std::min(m,n);
208  for(CPPL_INT k=0; k<kmax; k++){
209  (*this)(k,k) =1.;
210  }
211 
212  return *this;
213 }
zgematrix_small< m, n > & zero()
template<CPPL_INT m, CPPL_INT n>
zcovector_small< m > zgematrix_small< m, n >::col ( const CPPL_INT &  j) const
inline

return the j-th column vector

Definition at line 218 of file zgematrix_small-functions.hpp.

References i().

219 {CPPL_VERBOSE_REPORT;
220  zcovector_small<m> vec;
221  for(CPPL_INT i=0; i<m; i++){
222  vec(i) =(*this)(i,j);
223  }
224  return vec;
225 }
_dgematrix i(const _dgbmatrix &mat)
Samll Complex Double-precision Column Vector Class.
template<CPPL_INT m, CPPL_INT n>
zrovector_small< n > zgematrix_small< m, n >::row ( const CPPL_INT &  i) const
inline

return the i-th row vector

Definition at line 230 of file zgematrix_small-functions.hpp.

References i().

231 {CPPL_VERBOSE_REPORT;
232  zrovector_small<n> vec;
233  for(CPPL_INT j=0; j<n; j++){
234  vec(j)=(*this)(i,j);
235  }
236  return vec;
237 }
_dgematrix i(const _dgbmatrix &mat)
Samll Complex Double-precision Row Vector Class.
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
zgematrix_small<M,N>& zgematrix_small< m, n >::operator= ( const zgematrix_small< M, N > &  )
inline

Friends And Related Function Documentation

template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT _m, CPPL_INT _n>
std::ostream& operator<< ( std::ostream &  ,
const zgematrix_small< _m, _n > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT _m, CPPL_INT _n>
zgematrix_small<n,m> t ( const zgematrix_small< m, n > &  A)
friend

return transposed zgematrix_small

Definition at line 158 of file zgematrix_small-functions.hpp.

159 {CPPL_VERBOSE_REPORT;
161  for(CPPL_INT i=0; i<m; i++){
162  for(CPPL_INT j=0; j<n; j++){
163  X(j,i) =A(i,j);
164  }
165  }
166  return X;
167 }
_dgematrix i(const _dgbmatrix &mat)
Samll Complex Double-precision General Dence Matrix Class.
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
zgematrix_small<M,N>& operator+= ( zgematrix_small< M, N > &  ,
const zgematrix_small< M, N > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
zgematrix_small<M,N>& operator-= ( zgematrix_small< M, N > &  ,
const zgematrix_small< M, N > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT L, CPPL_INT N>
zgematrix_small<M,N>& operator*= ( zgematrix_small< M, L > &  ,
const zgematrix_small< L, N > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
zgematrix_small<M,N>& operator*= ( zgematrix_small< M, N > &  ,
const double &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
zgematrix_small<M,N>& operator*= ( zgematrix_small< M, N > &  ,
const comple &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
zgematrix_small<M,N>& operator/= ( zgematrix_small< M, N > &  ,
const double &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
zgematrix_small<M,N>& operator/= ( zgematrix_small< M, N > &  ,
const comple &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
const zgematrix_small<M,N>& operator+ ( const zgematrix_small< M, N > &  )
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
zgematrix_small<M,N> operator- ( const zgematrix_small< M, N > &  )
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
zgematrix_small<M,N> operator+ ( const zgematrix_small< M, N > &  ,
const zgematrix_small< M, N > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
zgematrix_small<M,N> operator+ ( const zgematrix_small< M, N > &  ,
const zhematrix_small< N > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
zgematrix_small<M,N> operator- ( const zgematrix_small< M, N > &  ,
const zgematrix_small< M, N > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
zgematrix_small<M,N> operator- ( const zgematrix_small< M, N > &  ,
const zhematrix_small< N > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
zcovector_small< M > operator* ( const zgematrix_small< M, N > &  ,
const zcovector_small< N > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT L, CPPL_INT N>
zgematrix_small<M,N> operator* ( const zgematrix_small< M, L > &  ,
const zgematrix_small< L, N > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
zgematrix_small<M,N> operator* ( const zgematrix_small< M, N > &  ,
const zhematrix_small< N > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
zgematrix_small<M,N> operator* ( const zgematrix_small< M, N > &  ,
const double &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
zgematrix_small<M,N> operator* ( const zgematrix_small< M, N > &  ,
const comple &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
zgematrix_small<M,N> operator/ ( const zgematrix_small< M, N > &  ,
const double &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
zgematrix_small<M,N> operator/ ( const zgematrix_small< M, N > &  ,
const comple &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
zgematrix_small<M,N> operator* ( const double &  ,
const zgematrix_small< M, N > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
zgematrix_small<M,N> operator* ( const comple &  ,
const zgematrix_small< M, N > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
zgematrix_small<M,N> hadamerd ( const zgematrix_small< M, N > &  ,
const zgematrix_small< M, N > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT N>
zgematrix_small<N,N> hadamerd ( const zgematrix_small< N, N > &  ,
const zhematrix_small< N > &   
)
friend

Member Data Documentation

template<CPPL_INT m, CPPL_INT n>
comple zgematrix_small< m, n >::array[m *n]

Definition at line 9 of file zgematrix_small.hpp.

Referenced by operator*=(), operator+=(), operator-=(), and operator/=().


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