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

Samll Real Double-precision Row Vector Class. More...

#include <drovector_small.hpp>

Public Member Functions

 drovector_small ()
 
 drovector_small (const drovector &)
 
 drovector_small (const double &, const double &)
 
 drovector_small (const double &, const double &, const double &)
 
 drovector_small (const double &, const double &, const double &, const double &)
 
 ~drovector_small ()
 
_drovector to_drovector () const
 
double & operator() (const CPPL_INT &)
 
double operator() (const CPPL_INT &) const
 
drovector_small< l > & set (const CPPL_INT &, const double &)
 
void read (const char *filename)
 
void write (const char *filename) const
 
drovector_small< l > & zero ()
 
template<CPPL_INT L>
drovector_small< L > & operator= (const drovector_small< L > &)
 

Public Attributes

double array [l]
 1D array to store vector data More...
 

Friends

template<CPPL_INT _l>
std::ostream & operator<< (std::ostream &, const drovector_small< _l > &)
 
template<CPPL_INT _l>
dcovector_small< _l > t (const drovector_small< _l > &)
 
template<CPPL_INT _l>
double nrm2 (const drovector_small< _l > &)
 
template<CPPL_INT _l>
CPPL_INT idamax (const drovector_small< _l > &)
 
template<CPPL_INT _l>
double damax (const drovector_small< _l > &)
 
template<CPPL_INT L>
drovector_small< L > & operator+= (drovector_small< L > &, const drovector_small< L > &)
 
template<CPPL_INT L>
drovector_small< L > & operator-= (drovector_small< L > &, const drovector_small< L > &)
 
template<CPPL_INT L>
drovector_small< L > & operator*= (drovector_small< L > &, const double &)
 
template<CPPL_INT L>
drovector_small< L > & operator/= (drovector_small< L > &, const double &)
 
template<CPPL_INT L>
const drovector_small< L > & operator+ (const drovector_small< L > &)
 
template<CPPL_INT L>
drovector_small< L > operator- (const drovector_small< L > &)
 
template<CPPL_INT L>
drovector_small< L > operator+ (const drovector_small< L > &, const drovector_small< L > &)
 
template<CPPL_INT L>
drovector_small< L > operator- (const drovector_small< L > &, const drovector_small< L > &)
 
template<CPPL_INT L>
double operator* (const drovector_small< L > &, const dcovector_small< L > &)
 
template<CPPL_INT M, CPPL_INT N>
drovector_small< N > operator* (const drovector_small< M > &, const dgematrix_small< M, N > &)
 
template<CPPL_INT L>
drovector_small< L > operator* (const drovector_small< L > &, const dsymatrix_small< L > &)
 
template<CPPL_INT L>
drovector_small< L > operator* (const drovector_small< L > &, const double &)
 
template<CPPL_INT L>
drovector_small< L > operator/ (const drovector_small< L > &, const double &)
 
template<CPPL_INT L>
drovector_small< L > operator* (const double &, const drovector_small< L > &)
 
template<CPPL_INT L>
drovector_small< L > hadamerd (const drovector_small< L > &, const drovector_small< L > &)
 

Detailed Description

template<CPPL_INT l>
class drovector_small< l >

Samll Real Double-precision Row Vector Class.

Definition at line 3 of file drovector_small.hpp.

Constructor & Destructor Documentation

template<CPPL_INT l>
drovector_small< l >::drovector_small ( )
inline

drovector_small constructor

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

5 {CPPL_VERBOSE_REPORT;
6  ;
7 }
template<CPPL_INT l>
drovector_small< l >::drovector_small ( const drovector vec)
inlineexplicit

drovector_small constructor

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

References drovector::array, and drovector::l.

13 {CPPL_VERBOSE_REPORT;
14 #ifdef CPPL_DEBUG
15  if( l!=vec.l ){
16  ERROR_REPORT;
17  std::cerr << "Vector sizes must be the same." << std::endl
18  << "Your input was " << l << " and " << vec.l << "." << std::endl;
19  exit(1);
20  }
21 #endif//CPPL_DEBUG
22 
23  for(CPPL_INT k=0; k<l; k++){
24  array[k] =vec.array[k];
25  }
26 }
double * array
1D array to store vector data
Definition: drovector.hpp:11
CPPL_INT l
vector size
Definition: drovector.hpp:9
double array[l]
1D array to store vector data
template<CPPL_INT l>
drovector_small< l >::drovector_small ( const double &  x,
const double &  y 
)
inline

drovector_small constructor

Definition at line 31 of file drovector_small-constructors.hpp.

32 {CPPL_VERBOSE_REPORT;
33 #ifdef CPPL_DEBUG
34  if( l!=2 ){
35  ERROR_REPORT;
36  std::cerr << "The vector size must be 2." << std::endl
37  << "The vector size you set was " << l << "." << std::endl;
38  exit(1);
39  }
40 #endif//CPPL_DEBUG]
41 
42  array[0] =x;
43  array[1] =y;
44 }
double array[l]
1D array to store vector data
template<CPPL_INT l>
drovector_small< l >::drovector_small ( const double &  x,
const double &  y,
const double &  z 
)
inline

drovector_small constructor

Definition at line 49 of file drovector_small-constructors.hpp.

50 {CPPL_VERBOSE_REPORT;
51 #ifdef CPPL_DEBUG
52  if( l!=3 ){
53  ERROR_REPORT;
54  std::cerr << "The vector size must be 3." << std::endl
55  << "The vector size you set was " << l << "." << std::endl;
56  exit(1);
57  }
58 #endif//CPPL_DEBUG
59 
60  array[0] =x;
61  array[1] =y;
62  array[2] =z;
63 }
double array[l]
1D array to store vector data
template<CPPL_INT l>
drovector_small< l >::drovector_small ( const double &  x,
const double &  y,
const double &  z,
const double &  r 
)
inline

drovector_small constructor

Definition at line 68 of file drovector_small-constructors.hpp.

69 {CPPL_VERBOSE_REPORT;
70 #ifdef CPPL_DEBUG
71  if( l!=4 ){
72  ERROR_REPORT;
73  std::cerr << "The vector size must be 4." << std::endl
74  << "The vector size you set was " << l << "." << std::endl;
75  exit(1);
76  }
77 #endif//CPPL_DEBUG
78 
79  array[0] =x;
80  array[1] =y;
81  array[2] =z;
82  array[3] =r;
83 }
double array[l]
1D array to store vector data
template<CPPL_INT l>
drovector_small< l >::~drovector_small ( )
inline

drovector_small destructor

Definition at line 92 of file drovector_small-constructors.hpp.

93 {CPPL_VERBOSE_REPORT;
94  ;
95 }

Member Function Documentation

template<CPPL_INT l>
_drovector drovector_small< l >::to_drovector ( ) const
inline

convert drovector_small to drovector

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

References _().

5 {CPPL_VERBOSE_REPORT;
6  drovector vec(l);
7  for(CPPL_INT k=0; k<l; k++){
8  vec(k)=(*this)(k);
9  }
10  return _(vec);
11 }
Real Double-precision Row Vector Class.
Definition: drovector.hpp:3
_dcovector _(dcovector &vec)
template<CPPL_INT l>
double & drovector_small< l >::operator() ( const CPPL_INT &  k)
inline

operator()

Definition at line 20 of file drovector_small-functions.hpp.

21 {CPPL_VERBOSE_REPORT;
22 #ifdef CPPL_DEBUG
23  if( k<0 || l<=k ){
24  ERROR_REPORT;
25  std::cerr << "The required component is out of the vector size." << std::endl
26  << "Your input is (" << k << "), whereas the vector size is " << l << "." << std::endl;
27  exit(1);
28  }
29 #endif//CPPL_DEBUG
30 
31  return array[k];
32 }
double array[l]
1D array to store vector data
template<CPPL_INT l>
double drovector_small< l >::operator() ( const CPPL_INT &  k) const
inline

operator() for const

Definition at line 37 of file drovector_small-functions.hpp.

38 {CPPL_VERBOSE_REPORT;
39 #ifdef CPPL_DEBUG
40  if( k<0 || l<=k ){
41  ERROR_REPORT;
42  std::cerr << "The required component is out of the vector size." << std::endl
43  << "Your input is (" << k << "), whereas the vector size is " << l << "." << std::endl;
44  exit(1);
45  }
46 #endif//CPPL_DEBUG
47 
48  return array[k];
49 }
double array[l]
1D array to store vector data
template<CPPL_INT l>
drovector_small< l > & drovector_small< l >::set ( const CPPL_INT &  k,
const double &  v 
)
inline

set function

Definition at line 54 of file drovector_small-functions.hpp.

55 {CPPL_VERBOSE_REPORT;
56  (*this)(k) =v;
57  return *this;
58 }
template<CPPL_INT l>
void drovector_small< l >::read ( const char *  filename)
inline

read from file

Definition at line 95 of file drovector_small-functions.hpp.

96 {CPPL_VERBOSE_REPORT;
97  std::ifstream s( filename );
98  if(!s){
99  ERROR_REPORT;
100  std::cerr << "The file \"" << filename << "\" can not be opened." << std::endl;
101  exit(1);
102  }
103 
104  std::string id;
105  s >> id;
106  if( id != "drovector" && id != "#drovector" ){
107  ERROR_REPORT;
108  std::cerr << "The type name of the file \"" << filename << "\" is not drovector." << std::endl
109  << "Its type name was " << id << " ." << std::endl;
110  exit(1);
111  }
112 
113  CPPL_INT _l;
114  s >> _l;
115  if(l!=_l){
116  ERROR_REPORT;
117  std::cerr << "Matrix size is invalid." << std::endl;
118  exit(1);
119  }
120  for(CPPL_INT k=0; k<l; k++){
121  s >> (*this)(k);
122  }
123  if(s.eof()){
124  ERROR_REPORT;
125  std::cerr << "There is something is wrong with the file \"" << filename << "\"." << std::endl
126  << "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;
127  exit(1);
128  }
129 
130  s >> id;//tmp
131  if(!s.eof()){
132  ERROR_REPORT;
133  std::cerr << "There is something is wrong with the file \"" << filename << "\"." << std::endl
134  << "Most likely, there are extra data components." << std::endl;
135  exit(1);
136  }
137 
138  s.close();
139 }
template<CPPL_INT l>
void drovector_small< l >::write ( const char *  filename) const
inline

write to file

Definition at line 76 of file drovector_small-functions.hpp.

77 {CPPL_VERBOSE_REPORT;
78  std::ofstream ofs(filename, std::ios::trunc);
79  ofs.setf(std::cout.flags());
80  ofs.precision(std::cout.precision());
81  ofs.width(std::cout.width());
82  ofs.fill(std::cout.fill());
83 
84  ofs << "#drovector" << " " << l << std::endl;
85  for(CPPL_INT k=0; k<l; k++){
86  ofs << (*this)(k) << " ";
87  }
88  ofs << std::endl;
89  ofs.close();
90 }
template<CPPL_INT l>
drovector_small< l > & drovector_small< l >::zero ( )
inline

Definition at line 207 of file drovector_small-functions.hpp.

Referenced by operator*().

208 {CPPL_VERBOSE_REPORT;
209  for(CPPL_INT k=0; k<l; k++){
210  array[k] =0.;
211  }
212  return *this;
213 }
double array[l]
1D array to store vector data
template<CPPL_INT l>
template<CPPL_INT L>
drovector_small<L>& drovector_small< l >::operator= ( const drovector_small< L > &  )
inline

Friends And Related Function Documentation

template<CPPL_INT l>
template<CPPL_INT _l>
std::ostream& operator<< ( std::ostream &  ,
const drovector_small< _l > &   
)
friend
template<CPPL_INT l>
template<CPPL_INT _l>
dcovector_small<_l> t ( const drovector_small< _l > &  )
friend
template<CPPL_INT l>
template<CPPL_INT _l>
double nrm2 ( const drovector_small< _l > &  )
friend
template<CPPL_INT l>
template<CPPL_INT _l>
CPPL_INT idamax ( const drovector_small< _l > &  )
friend
template<CPPL_INT l>
template<CPPL_INT _l>
double damax ( const drovector_small< _l > &  )
friend
template<CPPL_INT l>
template<CPPL_INT L>
drovector_small<L>& operator+= ( drovector_small< L > &  ,
const drovector_small< L > &   
)
friend
template<CPPL_INT l>
template<CPPL_INT L>
drovector_small<L>& operator-= ( drovector_small< L > &  ,
const drovector_small< L > &   
)
friend
template<CPPL_INT l>
template<CPPL_INT L>
drovector_small<L>& operator*= ( drovector_small< L > &  ,
const double &   
)
friend
template<CPPL_INT l>
template<CPPL_INT L>
drovector_small<L>& operator/= ( drovector_small< L > &  ,
const double &   
)
friend
template<CPPL_INT l>
template<CPPL_INT L>
const drovector_small<L>& operator+ ( const drovector_small< L > &  )
friend
template<CPPL_INT l>
template<CPPL_INT L>
drovector_small<L> operator- ( const drovector_small< L > &  )
friend
template<CPPL_INT l>
template<CPPL_INT L>
drovector_small<L> operator+ ( const drovector_small< L > &  ,
const drovector_small< L > &   
)
friend
template<CPPL_INT l>
template<CPPL_INT L>
drovector_small<L> operator- ( const drovector_small< L > &  ,
const drovector_small< L > &   
)
friend
template<CPPL_INT l>
template<CPPL_INT L>
double operator* ( const drovector_small< L > &  ,
const dcovector_small< L > &   
)
friend
template<CPPL_INT l>
template<CPPL_INT M, CPPL_INT N>
drovector_small<N> operator* ( const drovector_small< M > &  ,
const dgematrix_small< M, N > &   
)
friend
template<CPPL_INT l>
template<CPPL_INT L>
drovector_small<L> operator* ( const drovector_small< L > &  ,
const dsymatrix_small< L > &   
)
friend
template<CPPL_INT l>
template<CPPL_INT L>
drovector_small<L> operator* ( const drovector_small< L > &  ,
const double &   
)
friend
template<CPPL_INT l>
template<CPPL_INT L>
drovector_small<L> operator/ ( const drovector_small< L > &  ,
const double &   
)
friend
template<CPPL_INT l>
template<CPPL_INT L>
drovector_small<L> operator* ( const double &  ,
const drovector_small< L > &   
)
friend
template<CPPL_INT l>
template<CPPL_INT L>
drovector_small<L> hadamerd ( const drovector_small< L > &  ,
const drovector_small< L > &   
)
friend

Member Data Documentation

template<CPPL_INT l>
double drovector_small< l >::array[l]

1D array to store vector data

Definition at line 9 of file drovector_small.hpp.


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