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

Samll Real Double-precision Symmetric Matrix Class. More...

#include <dsymatrix_small.hpp>

Public Member Functions

 dsymatrix_small ()
 
 dsymatrix_small (const dsymatrix &)
 
 ~dsymatrix_small ()
 
dgematrix_small< n, n > to_dgematrix_small () const
 
dsymatrix to_dsymatrix () const
 
double & operator() (const CPPL_INT &i, const CPPL_INT &j)
 
double operator() (const CPPL_INT &i, const CPPL_INT &j) const
 
dsymatrix_small< n > & set (const CPPL_INT &, const CPPL_INT &, const double &)
 
void read (const char *filename)
 
void write (const char *filename) const
 
dsymatrix_small< n > & zero ()
 
dsymatrix_small< n > & identity ()
 
template<CPPL_INT N>
dsymatrix_small< N > & operator= (const dsymatrix_small< N > &)
 

Public Attributes

double array [(n *(n+1))/2]
 1D array to store vector data More...
 

Friends

template<CPPL_INT _n>
std::ostream & operator<< (std::ostream &, const dsymatrix_small< _n > &)
 
template<CPPL_INT N>
dsymatrix_small< N > & operator+= (dsymatrix_small< N > &, const dsymatrix_small< N > &)
 
template<CPPL_INT N>
dsymatrix_small< N > & operator-= (dsymatrix_small< N > &, const dsymatrix_small< N > &)
 
template<CPPL_INT N>
dsymatrix_small< N > & operator*= (dsymatrix_small< N > &, const dsymatrix_small< N > &)
 
template<CPPL_INT N>
dsymatrix_small< N > & operator*= (dsymatrix_small< N > &, const double &)
 
template<CPPL_INT N>
dsymatrix_small< N > & operator/= (dsymatrix_small< N > &, const double &)
 
template<CPPL_INT N>
const dsymatrix_small< N > & operator+ (const dsymatrix_small< N > &)
 
template<CPPL_INT N>
dsymatrix_small< N > operator- (const dsymatrix_small< N > &)
 
template<CPPL_INT N>
dgematrix_small< N, N > operator+ (const dsymatrix_small< N > &, const dgematrix_small< N, N > &)
 
template<CPPL_INT N>
dsymatrix_small< N > operator+ (const dsymatrix_small< N > &, const dsymatrix_small< N > &)
 
template<CPPL_INT N>
dgematrix_small< N, N > operator- (const dsymatrix_small< N > &, const dgematrix_small< N, N > &)
 
template<CPPL_INT N>
dsymatrix_small< N > operator- (const dsymatrix_small< N > &, const dsymatrix_small< N > &)
 
template<CPPL_INT N>
dcovector_small< N > operator* (const dsymatrix_small< N > &, const dcovector_small< N > &)
 
template<CPPL_INT M, CPPL_INT N>
dgematrix_small< M, N > operator* (const dsymatrix_small< M > &, const dgematrix_small< M, N > &)
 
template<CPPL_INT N>
dgematrix_small< N, N > operator* (const dsymatrix_small< N > &, const dsymatrix_small< N > &)
 
template<CPPL_INT N>
dsymatrix_small< N > operator* (const dsymatrix_small< N > &, const double &)
 
template<CPPL_INT N>
dsymatrix_small< N > operator/ (const dsymatrix_small< N > &, const double &)
 
template<CPPL_INT N>
dsymatrix_small< N > operator* (const double &, const dsymatrix_small< N > &)
 
template<CPPL_INT N>
dsymatrix_small< N > hadamerd (const dsymatrix_small< N > &, const dgematrix_small< N, N > &)
 
template<CPPL_INT N>
dsymatrix_small< N > hadamerd (const dsymatrix_small< N > &, const dsymatrix_small< N > &)
 

Detailed Description

template<CPPL_INT n>
class dsymatrix_small< n >

Samll Real Double-precision Symmetric Matrix Class.

Definition at line 3 of file dsymatrix_small.hpp.

Constructor & Destructor Documentation

template<CPPL_INT n>
dsymatrix_small< n >::dsymatrix_small ( )
inline

dsymatrix_small constructor

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

5 {CPPL_VERBOSE_REPORT;
6  ;
7 }
template<CPPL_INT n>
dsymatrix_small< n >::dsymatrix_small ( const dsymatrix mat)
inlineexplicit

dsymatrix_small constructor

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

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

13 {CPPL_VERBOSE_REPORT;
14 #ifdef CPPL_DEBUG
15  if( n!=mat.n ){
16  ERROR_REPORT;
17  std::cerr << "Matrix sizes must be the same." << std::endl
18  << "Your input was " << n << "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<(n*(n+1))/2; k++){
24  array[k] =mat.array[k];
25  }
26 }
CPPL_INT const & m
matrix row size
Definition: dsymatrix.hpp:9
CPPL_INT n
matrix column size
Definition: dsymatrix.hpp:10
double * array
1D array to store matrix data
Definition: dsymatrix.hpp:11
double array[(n *(n+1))/2]
1D array to store vector data
template<CPPL_INT n>
dsymatrix_small< n >::~dsymatrix_small ( )
inline

dsymatrix_small destructor

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

36 {CPPL_VERBOSE_REPORT;
37  ;
38 }

Member Function Documentation

template<CPPL_INT n>
dgematrix_small< n, n > dsymatrix_small< n >::to_dgematrix_small ( ) const
inline

convert dsymatrix_small to dgematrix_small

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

References i().

5 {CPPL_VERBOSE_REPORT;
7  for(CPPL_INT i=0; i<n; i++){
8  for(CPPL_INT j=0; j<=i; j++){ newmat(i,j) =(*this)(i,j); }
9  for(CPPL_INT j=i+1; j<n; j++){ newmat(i,j) =(*this)(j,i); }
10  }
11  return newmat;
12 }
Samll Real Double-precision General Dence Matrix Class.
_dgematrix i(const _dgbmatrix &mat)
template<CPPL_INT n>
dsymatrix dsymatrix_small< n >::to_dsymatrix ( ) const
inline

convert dsymatrix_small to dsymatrix

Definition at line 17 of file dsymatrix_small-functions.hpp.

References i().

18 {CPPL_VERBOSE_REPORT;
19  dsymatrix newmat(n);
20  for(CPPL_INT i=0; i<n; i++){
21  for(CPPL_INT j=0; j<=i; j++){
22  newmat(i,j) =(*this)(i,j);
23  }
24  }
25  return newmat;
26 }
_dgematrix i(const _dgbmatrix &mat)
Real Double-precision Symmetric Matrix Class [l-type (UPLO=l) Strage].
Definition: dsymatrix.hpp:3
template<CPPL_INT n>
double & dsymatrix_small< n >::operator() ( const CPPL_INT &  i,
const CPPL_INT &  j 
)
inline

operator()

Definition at line 38 of file dsymatrix_small-functions.hpp.

39 {CPPL_VERBOSE_REPORT;
40 #ifdef CPPL_DEBUG
41  if(i<j){
42  ERROR_REPORT;
43  std::cerr << "i must be greater than or equal to j since dsymatrix_small is L strage. " << std::endl;
44  std::cerr << "Your input was (" << i << ", " << j << ")." << std::endl;
45  exit(1);
46  }
47 #endif//CPPL_DEBUG
48 
49  //const CPPL_INT I(max(i,j)), J(min(i,j)); return array[(I*(I+1))/2 +J];
50  return array[(i*(i+1))/2 +j]; //L storage
51 }
_dgematrix i(const _dgbmatrix &mat)
double array[(n *(n+1))/2]
1D array to store vector data
template<CPPL_INT n>
double dsymatrix_small< n >::operator() ( const CPPL_INT &  i,
const CPPL_INT &  j 
) const
inline

operator() for const

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

57 {CPPL_VERBOSE_REPORT;
58 #ifdef CPPL_DEBUG
59  if(i<j){
60  ERROR_REPORT;
61  std::cerr << "i must be greater than or equal to j since dsymatrix_small is L strage. " << std::endl;
62  std::cerr << "Your input was (" << i << ", " << j << ")." << std::endl;
63  exit(1);
64  }
65 #endif//CPPL_DEBUG
66 
67  //const CPPL_INT I(max(i,j)), J(min(i,j)); return array[(I*(I+1))/2 +J];
68  return array[(i*(i+1))/2 +j];
69 }
_dgematrix i(const _dgbmatrix &mat)
double array[(n *(n+1))/2]
1D array to store vector data
template<CPPL_INT n>
dsymatrix_small< n > & dsymatrix_small< n >::set ( const CPPL_INT &  i,
const CPPL_INT &  j,
const double &  v 
)
inline

set function

Definition at line 74 of file dsymatrix_small-functions.hpp.

References i().

75 {CPPL_VERBOSE_REPORT;
76  (*this)(i,j)=v;
77  return *this;
78 }
_dgematrix i(const _dgbmatrix &mat)
template<CPPL_INT n>
void dsymatrix_small< n >::read ( const char *  filename)
inline

read from file

Definition at line 117 of file dsymatrix_small-functions.hpp.

References i().

118 {CPPL_VERBOSE_REPORT;
119  std::ifstream s(filename);
120  if(!s){
121  ERROR_REPORT;
122  std::cerr << "The file \"" << filename << "\" can not be opened." << std::endl;
123  exit(1);
124  }
125 
126  std::string id;
127  s >> id;
128  if( id != "dsymatrix" && id != "#dsymatrix" ){
129  ERROR_REPORT;
130  std::cerr << "The type name of the file \"" << filename << "\" is not dsymatrix." << std::endl
131  << "Its type name was " << id << " ." << std::endl;
132  exit(1);
133  }
134 
135  CPPL_INT _n;
136  s >> _n;
137  if(n!=_n){
138  ERROR_REPORT;
139  std::cerr << "Matrix size is invalid." << std::endl;
140  exit(1);
141  }
142 
143  for(CPPL_INT i=0; i<n; i++){
144  for(CPPL_INT j=0; j<=i; j++ ){
145  s >> operator()(i,j);
146  }
147  }
148  if(s.eof()){
149  ERROR_REPORT;
150  std::cerr << "There is something is wrong with the file \"" << filename << "\"." << std::endl
151  << "Most likely, there is a lack of data components, or a linefeed code or space code is missing at the end of the last line." << std::endl;
152  exit(1);
153  }
154 
155  s.close();
156 }
_dgematrix i(const _dgbmatrix &mat)
double & operator()(const CPPL_INT &i, const CPPL_INT &j)
template<CPPL_INT n>
void dsymatrix_small< n >::write ( const char *  filename) const
inline

write to file

Definition at line 97 of file dsymatrix_small-functions.hpp.

References i().

98 {CPPL_VERBOSE_REPORT;
99  std::ofstream ofs(filename, std::ios::trunc);
100  ofs.setf(std::cout.flags());
101  ofs.precision(std::cout.precision());
102  ofs.width(std::cout.width());
103  ofs.fill(std::cout.fill());
104  ofs << "#dsymatrix" << " " << n << std::endl;
105  for(CPPL_INT i=0; i<n; i++){
106  for(CPPL_INT j=0; j<=i; j++){
107  ofs << (*this)(i,j) << " ";
108  }
109  ofs << std::endl;
110  }
111  ofs.close();
112 }
_dgematrix i(const _dgbmatrix &mat)
template<CPPL_INT n>
dsymatrix_small< n > & dsymatrix_small< n >::zero ( )
inline

zero

Definition at line 168 of file dsymatrix_small-functions.hpp.

References i().

169 {CPPL_VERBOSE_REPORT;
170  for(CPPL_INT i=0; i<n; i++){
171  for(CPPL_INT j=0; j<=i; j++){
172  (*this)(i,j) =0.;
173  }
174  }
175  return *this;
176 }
_dgematrix i(const _dgbmatrix &mat)
template<CPPL_INT n>
dsymatrix_small< n > & dsymatrix_small< n >::identity ( )
inline

identity

Definition at line 181 of file dsymatrix_small-functions.hpp.

182 {CPPL_VERBOSE_REPORT;
183  zero();
184  for(CPPL_INT k=0; k<n; k++){
185  (*this)(k,k) =1.;
186  }
187  return *this;
188 }
dsymatrix_small< n > & zero()
template<CPPL_INT n>
template<CPPL_INT N>
dsymatrix_small<N>& dsymatrix_small< n >::operator= ( const dsymatrix_small< N > &  )
inline

Friends And Related Function Documentation

template<CPPL_INT n>
template<CPPL_INT _n>
std::ostream& operator<< ( std::ostream &  ,
const dsymatrix_small< _n > &   
)
friend
template<CPPL_INT n>
template<CPPL_INT N>
dsymatrix_small<N>& operator+= ( dsymatrix_small< N > &  ,
const dsymatrix_small< N > &   
)
friend
template<CPPL_INT n>
template<CPPL_INT N>
dsymatrix_small<N>& operator-= ( dsymatrix_small< N > &  ,
const dsymatrix_small< N > &   
)
friend
template<CPPL_INT n>
template<CPPL_INT N>
dsymatrix_small<N>& operator*= ( dsymatrix_small< N > &  ,
const dsymatrix_small< N > &   
)
friend
template<CPPL_INT n>
template<CPPL_INT N>
dsymatrix_small<N>& operator*= ( dsymatrix_small< N > &  ,
const double &   
)
friend
template<CPPL_INT n>
template<CPPL_INT N>
dsymatrix_small<N>& operator/= ( dsymatrix_small< N > &  ,
const double &   
)
friend
template<CPPL_INT n>
template<CPPL_INT N>
const dsymatrix_small<N>& operator+ ( const dsymatrix_small< N > &  )
friend
template<CPPL_INT n>
template<CPPL_INT N>
dsymatrix_small< N > operator- ( const dsymatrix_small< N > &  )
friend
template<CPPL_INT n>
template<CPPL_INT N>
dgematrix_small<N,N> operator+ ( const dsymatrix_small< N > &  ,
const dgematrix_small< N, N > &   
)
friend
template<CPPL_INT n>
template<CPPL_INT N>
dsymatrix_small< N > operator+ ( const dsymatrix_small< N > &  ,
const dsymatrix_small< N > &   
)
friend
template<CPPL_INT n>
template<CPPL_INT N>
dgematrix_small<N,N> operator- ( const dsymatrix_small< N > &  ,
const dgematrix_small< N, N > &   
)
friend
template<CPPL_INT n>
template<CPPL_INT N>
dsymatrix_small< N > operator- ( const dsymatrix_small< N > &  ,
const dsymatrix_small< N > &   
)
friend
template<CPPL_INT n>
template<CPPL_INT N>
dcovector_small< N > operator* ( const dsymatrix_small< N > &  ,
const dcovector_small< N > &   
)
friend
template<CPPL_INT n>
template<CPPL_INT M, CPPL_INT N>
dgematrix_small<M,N> operator* ( const dsymatrix_small< M > &  ,
const dgematrix_small< M, N > &   
)
friend
template<CPPL_INT n>
template<CPPL_INT N>
dgematrix_small<N,N> operator* ( const dsymatrix_small< N > &  ,
const dsymatrix_small< N > &   
)
friend
template<CPPL_INT n>
template<CPPL_INT N>
dsymatrix_small< N > operator* ( const dsymatrix_small< N > &  ,
const double &   
)
friend
template<CPPL_INT n>
template<CPPL_INT N>
dsymatrix_small< N > operator/ ( const dsymatrix_small< N > &  ,
const double &   
)
friend
template<CPPL_INT n>
template<CPPL_INT N>
dsymatrix_small< N > operator* ( const double &  ,
const dsymatrix_small< N > &   
)
friend
template<CPPL_INT n>
template<CPPL_INT N>
dsymatrix_small< N > hadamerd ( const dsymatrix_small< N > &  ,
const dgematrix_small< N, N > &   
)
friend
template<CPPL_INT n>
template<CPPL_INT N>
dsymatrix_small< N > hadamerd ( const dsymatrix_small< N > &  ,
const dsymatrix_small< N > &   
)
friend

Member Data Documentation

template<CPPL_INT n>
double dsymatrix_small< n >::array[(n *(n+1))/2]

1D array to store vector data

Definition at line 9 of file dsymatrix_small.hpp.

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


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