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

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

#include <dgematrix_small.hpp>

Public Member Functions

 dgematrix_small ()
 
 dgematrix_small (const dgematrix &)
 
 ~dgematrix_small ()
 
_dgematrix to_dgematrix () const
 
double & operator() (const CPPL_INT &i, const CPPL_INT &j)
 
double operator() (const CPPL_INT &i, const CPPL_INT &j) const
 
dgematrix_small< m, n > & set (const CPPL_INT &i, const CPPL_INT &j, const double &v)
 
void read (const char *filename)
 
void write (const char *filename) const
 
dgematrix_small< m, n > & zero ()
 
dgematrix_small< m, n > & identity ()
 
dcovector_small< m > col (const CPPL_INT &j) const
 
drovector_small< n > row (const CPPL_INT &i) const
 
template<CPPL_INT M, CPPL_INT N>
dgematrix_small< M, N > & operator= (const dgematrix_small< M, N > &)
 

Public Attributes

double array [m *n]
 1D array to store vector data More...
 

Friends

template<CPPL_INT _m, CPPL_INT _n>
std::ostream & operator<< (std::ostream &, const dgematrix_small< _m, _n > &)
 
template<CPPL_INT _m, CPPL_INT _n>
dgematrix_small< n, m > t (const dgematrix_small< m, n > &)
 
template<CPPL_INT _m, CPPL_INT _n>
void idamax (CPPL_INT &, CPPL_INT &, const dgematrix_small &)
 
template<CPPL_INT _m, CPPL_INT _n>
double damax (const dgematrix_small &)
 
template<CPPL_INT M, CPPL_INT N>
dgematrix_small< M, N > & operator+= (dgematrix_small< M, N > &, const dgematrix_small< M, N > &)
 
template<CPPL_INT M, CPPL_INT N>
dgematrix_small< M, N > & operator-= (dgematrix_small< M, N > &, const dgematrix_small< M, N > &)
 
template<CPPL_INT M, CPPL_INT L, CPPL_INT N>
dgematrix_small< M, N > & operator*= (dgematrix_small< M, L > &, const dgematrix_small< L, N > &)
 
template<CPPL_INT M, CPPL_INT N>
dgematrix_small< M, N > & operator*= (dgematrix_small< M, N > &, const double &)
 
template<CPPL_INT M, CPPL_INT N>
dgematrix_small< M, N > & operator/= (dgematrix_small< M, N > &, const double &)
 
template<CPPL_INT M, CPPL_INT N>
const dgematrix_small< M, N > & operator+ (const dgematrix_small< M, N > &)
 
template<CPPL_INT M, CPPL_INT N>
dgematrix_small< M, N > operator- (const dgematrix_small< M, N > &)
 
template<CPPL_INT M, CPPL_INT N>
dgematrix_small< M, N > operator+ (const dgematrix_small< M, N > &, const dgematrix_small< M, N > &)
 
template<CPPL_INT M, CPPL_INT N>
dgematrix_small< M, N > operator+ (const dgematrix_small< M, N > &, const dsymatrix_small< N > &)
 
template<CPPL_INT M, CPPL_INT N>
dgematrix_small< M, N > operator- (const dgematrix_small< M, N > &, const dgematrix_small< M, N > &)
 
template<CPPL_INT M, CPPL_INT N>
dgematrix_small< M, N > operator- (const dgematrix_small< M, N > &, const dsymatrix_small< N > &)
 
template<CPPL_INT M, CPPL_INT N>
dcovector_small< M > operator* (const dgematrix_small< M, N > &, const dcovector_small< N > &)
 
template<CPPL_INT M, CPPL_INT L, CPPL_INT N>
dgematrix_small< M, N > operator* (const dgematrix_small< M, L > &, const dgematrix_small< L, N > &)
 
template<CPPL_INT M, CPPL_INT N>
dgematrix_small< M, N > operator* (const dgematrix_small< M, N > &, const dsymatrix_small< N > &)
 
template<CPPL_INT M, CPPL_INT N>
dgematrix_small< M, N > operator* (const dgematrix_small< M, N > &, const double &)
 
template<CPPL_INT M, CPPL_INT N>
dgematrix_small< M, N > operator/ (const dgematrix_small< M, N > &, const double &)
 
template<CPPL_INT M, CPPL_INT N>
dgematrix_small< M, N > operator* (const double &, const dgematrix_small< M, N > &)
 
template<CPPL_INT M, CPPL_INT N>
dgematrix_small< M, N > hadamerd (const dgematrix_small< M, N > &, const dgematrix_small< M, N > &)
 
template<CPPL_INT N>
dgematrix_small< N, N > hadamerd (const dgematrix_small< N, N > &, const dsymatrix_small< N > &)
 

Detailed Description

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

Samll Real Double-precision General Dence Matrix Class.

Definition at line 3 of file dgematrix_small.hpp.

Constructor & Destructor Documentation

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

dgematrix_small constructor

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

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

dgematrix_small constructor

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

References dgematrix::array, dgematrix::m, and dgematrix::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 }
CPPL_INT m
matrix row size
Definition: dgematrix.hpp:9
double * array
1D array to store matrix data
Definition: dgematrix.hpp:11
CPPL_INT n
matrix column size
Definition: dgematrix.hpp:10
double array[m *n]
1D array to store vector data
template<CPPL_INT m, CPPL_INT n>
dgematrix_small< m, n >::~dgematrix_small ( )
inline

dgematrix_small destructor

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

36 {CPPL_VERBOSE_REPORT;
37  ;
38 }

Member Function Documentation

template<CPPL_INT m, CPPL_INT n>
_dgematrix dgematrix_small< m, n >::to_dgematrix ( ) const
inline

convert dgematrix_small to dgematrix

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

References _(), and i().

5 {CPPL_VERBOSE_REPORT;
6  dgematrix 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)
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
_dcovector _(dcovector &vec)
template<CPPL_INT m, CPPL_INT n>
double & dgematrix_small< m, n >::operator() ( const CPPL_INT &  i,
const CPPL_INT &  j 
)
inline

operator()

Definition at line 22 of file dgematrix_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 }
_dgematrix i(const _dgbmatrix &mat)
double array[m *n]
1D array to store vector data
template<CPPL_INT m, CPPL_INT n>
double dgematrix_small< m, n >::operator() ( const CPPL_INT &  i,
const CPPL_INT &  j 
) const
inline

operator() for const

Definition at line 39 of file dgematrix_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 }
_dgematrix i(const _dgbmatrix &mat)
double array[m *n]
1D array to store vector data
template<CPPL_INT m, CPPL_INT n>
dgematrix_small< m, n > & dgematrix_small< m, n >::set ( const CPPL_INT &  i,
const CPPL_INT &  j,
const double &  v 
)
inline

set function

Definition at line 56 of file dgematrix_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 dgematrix_small< m, n >::read ( const char *  filename)
inline

read from file

Definition at line 100 of file dgematrix_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 != "dgematrix" && id != "#dgematrix" ){
112  ERROR_REPORT;
113  std::cerr << "The type name of the file \"" << filename << "\" is not dgematrix." << 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 }
double & operator()(const CPPL_INT &i, const CPPL_INT &j)
_dgematrix i(const _dgbmatrix &mat)
template<CPPL_INT m, CPPL_INT n>
void dgematrix_small< m, n >::write ( const char *  filename) const
inline

write to file

Definition at line 80 of file dgematrix_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 << "#dgematrix" << " " << 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>
dgematrix_small< m, n > & dgematrix_small< m, n >::zero ( )
inline

zero

Definition at line 219 of file dgematrix_small-functions.hpp.

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

220 {CPPL_VERBOSE_REPORT;
221  for(CPPL_INT k=0; k<m*n; k++){ array[k]=0.; }
222  return *this;
223 }
double array[m *n]
1D array to store vector data
template<CPPL_INT m, CPPL_INT n>
dgematrix_small< m, n > & dgematrix_small< m, n >::identity ( )
inline

identity

Definition at line 228 of file dgematrix_small-functions.hpp.

229 {CPPL_VERBOSE_REPORT;
230  zero();
231 
232  const CPPL_INT kmax =std::min(m,n);
233  for(CPPL_INT k=0; k<kmax; k++){
234  (*this)(k,k)=1.;
235  }
236 
237  return *this;
238 }
dgematrix_small< m, n > & zero()
template<CPPL_INT m, CPPL_INT n>
dcovector_small< m > dgematrix_small< m, n >::col ( const CPPL_INT &  j) const
inline

return the j-th column vector

Definition at line 243 of file dgematrix_small-functions.hpp.

References i().

244 {CPPL_VERBOSE_REPORT;
245  dcovector_small<m> vec;
246  for(CPPL_INT i=0; i<m; i++){ vec(i)=(*this)(i,j); }
247  return vec;
248 }
_dgematrix i(const _dgbmatrix &mat)
Samll Real Double-precision Column Vector Class.
template<CPPL_INT m, CPPL_INT n>
drovector_small< n > dgematrix_small< m, n >::row ( const CPPL_INT &  i) const
inline

return the i-th row vector

Definition at line 253 of file dgematrix_small-functions.hpp.

References i().

254 {CPPL_VERBOSE_REPORT;
255  drovector_small<n> vec;
256  for(CPPL_INT j=0; j<n; j++){ vec(j)=(*this)(i,j); }
257  return vec;
258 }
_dgematrix i(const _dgbmatrix &mat)
Samll Real Double-precision Row Vector Class.
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
dgematrix_small<M,N>& dgematrix_small< m, n >::operator= ( const dgematrix_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 dgematrix_small< _m, _n > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT _m, CPPL_INT _n>
dgematrix_small<n,m> t ( const dgematrix_small< m, n > &  A)
friend

return transposed matrix

Definition at line 158 of file dgematrix_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 }
Samll Real Double-precision General Dence Matrix Class.
_dgematrix i(const _dgbmatrix &mat)
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT _m, CPPL_INT _n>
void idamax ( CPPL_INT &  I,
CPPL_INT &  J,
const dgematrix_small< m, n > &  A 
)
friend

find index of the maximum component

Definition at line 187 of file dgematrix_small-functions.hpp.

188 {CPPL_VERBOSE_REPORT;
189  double max(-1.);
190  for(CPPL_INT i=0; i<m; i++){
191  for(CPPL_INT j=0; j<n; j++){
192  if( max<fabs(A(i,j)) ){
193  I=i;
194  J=j;
195  max =fabs(A(i,j));
196  }
197  }
198  }
199  return;
200 }
_dgematrix i(const _dgbmatrix &mat)
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT _m, CPPL_INT _n>
double damax ( const dgematrix_small< m, n > &  A)
friend

return the maximum component

Definition at line 205 of file dgematrix_small-functions.hpp.

206 {CPPL_VERBOSE_REPORT;
207  CPPL_INT i(0), j(0);
208  idamax(i,j,A);
209  return A(i,j);
210 }
_dgematrix i(const _dgbmatrix &mat)
friend void idamax(CPPL_INT &, CPPL_INT &, const dgematrix_small &)
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
dgematrix_small<M,N>& operator+= ( dgematrix_small< M, N > &  ,
const dgematrix_small< M, N > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
dgematrix_small<M,N>& operator-= ( dgematrix_small< M, N > &  ,
const dgematrix_small< M, N > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT L, CPPL_INT N>
dgematrix_small<M,N>& operator*= ( dgematrix_small< M, L > &  ,
const dgematrix_small< L, N > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
dgematrix_small<M,N>& operator*= ( dgematrix_small< M, N > &  ,
const double &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
dgematrix_small<M,N>& operator/= ( dgematrix_small< M, N > &  ,
const double &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
const dgematrix_small<M,N>& operator+ ( const dgematrix_small< M, N > &  )
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
dgematrix_small<M,N> operator- ( const dgematrix_small< M, N > &  )
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
dgematrix_small<M,N> operator+ ( const dgematrix_small< M, N > &  ,
const dgematrix_small< M, N > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
dgematrix_small<M,N> operator+ ( const dgematrix_small< M, N > &  ,
const dsymatrix_small< N > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
dgematrix_small<M,N> operator- ( const dgematrix_small< M, N > &  ,
const dgematrix_small< M, N > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
dgematrix_small<M,N> operator- ( const dgematrix_small< M, N > &  ,
const dsymatrix_small< N > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
dcovector_small< M > operator* ( const dgematrix_small< M, N > &  ,
const dcovector_small< N > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT L, CPPL_INT N>
dgematrix_small<M,N> operator* ( const dgematrix_small< M, L > &  ,
const dgematrix_small< L, N > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
dgematrix_small<M,N> operator* ( const dgematrix_small< M, N > &  ,
const dsymatrix_small< N > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
dgematrix_small<M,N> operator* ( const dgematrix_small< M, N > &  ,
const double &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
dgematrix_small<M,N> operator/ ( const dgematrix_small< M, N > &  ,
const double &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
dgematrix_small<M,N> operator* ( const double &  ,
const dgematrix_small< M, N > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
dgematrix_small<M,N> hadamerd ( const dgematrix_small< M, N > &  ,
const dgematrix_small< M, N > &   
)
friend
template<CPPL_INT m, CPPL_INT n>
template<CPPL_INT N>
dgematrix_small<N,N> hadamerd ( const dgematrix_small< N, N > &  ,
const dsymatrix_small< N > &   
)
friend

Member Data Documentation

template<CPPL_INT m, CPPL_INT n>
double dgematrix_small< m, n >::array[m *n]

1D array to store vector data

Definition at line 9 of file dgematrix_small.hpp.

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


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