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

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

#include <dcovector_small.hpp>

Public Member Functions

 dcovector_small ()
 
 dcovector_small (const dcovector &)
 
 dcovector_small (const double &, const double &)
 
 dcovector_small (const double &, const double &, const double &)
 
 dcovector_small (const double &, const double &, const double &, const double &)
 
 ~dcovector_small ()
 
_dcovector to_dcovector () const
 
double & operator() (const CPPL_INT &)
 
double operator() (const CPPL_INT &) const
 
dcovector_small< l > & set (const CPPL_INT &, const double &)
 
void read (const char *filename)
 
void write (const char *filename) const
 
dcovector_small< l > & zero ()
 
template<CPPL_INT L>
dcovector_small< L > & operator= (const dcovector_small< L > &)
 

Public Attributes

double array [l]
 

Friends

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

Detailed Description

template<CPPL_INT l>
class dcovector_small< l >

Samll Real Double-precision Column Vector Class.

Definition at line 3 of file dcovector_small.hpp.

Constructor & Destructor Documentation

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

dcovector_small constructor

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

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

dcovector_small constructor

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

References dcovector::array, and dcovector::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 }
CPPL_INT l
vector size
Definition: dcovector.hpp:9
double * array
1D array to store vector data
Definition: dcovector.hpp:11
template<CPPL_INT l>
dcovector_small< l >::dcovector_small ( const double &  x,
const double &  y 
)
inline

dcovector_small constructor

Definition at line 31 of file dcovector_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 }
template<CPPL_INT l>
dcovector_small< l >::dcovector_small ( const double &  x,
const double &  y,
const double &  z 
)
inline

dcovector_small constructor

Definition at line 49 of file dcovector_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 }
template<CPPL_INT l>
dcovector_small< l >::dcovector_small ( const double &  x,
const double &  y,
const double &  z,
const double &  r 
)
inline

dcovector_small constructor

Definition at line 68 of file dcovector_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 }
template<CPPL_INT l>
dcovector_small< l >::~dcovector_small ( )
inline

dcovector_small destructor

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

93 {CPPL_VERBOSE_REPORT;
94  ;
95 }

Member Function Documentation

template<CPPL_INT l>
_dcovector dcovector_small< l >::to_dcovector ( ) const
inline

convert dcovector_small to dcovector

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

References _().

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

operator()

Definition at line 20 of file dcovector_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 }
template<CPPL_INT l>
double dcovector_small< l >::operator() ( const CPPL_INT &  k) const
inline

operator() for const

Definition at line 37 of file dcovector_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 }
template<CPPL_INT l>
dcovector_small< l > & dcovector_small< l >::set ( const CPPL_INT &  k,
const double &  v 
)
inline

set

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

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

read from file

Definition at line 93 of file dcovector_small-functions.hpp.

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

write to file

Definition at line 75 of file dcovector_small-functions.hpp.

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

zero

Definition at line 202 of file dcovector_small-functions.hpp.

Referenced by operator*().

203 {CPPL_VERBOSE_REPORT;
204  for(CPPL_INT k=0; k<l; k++){
205  array[k] =0.;
206  }
207  return *this;
208 }
template<CPPL_INT l>
template<CPPL_INT L>
dcovector_small<L>& dcovector_small< l >::operator= ( const dcovector_small< L > &  )
inline

Friends And Related Function Documentation

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

Member Data Documentation

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

Definition at line 9 of file dcovector_small.hpp.


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