CPPLapack
 All Classes Files Functions Variables Friends Pages
dcovector-constructor.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! dcovector constructor */
4 {CPPL_VERBOSE_REPORT;
5  //////// initialize ////////
6  l =0;
7  cap =0;
8  array =NULL;
9 }
10 
11 //=============================================================================
12 /*! dcovector copy constructor */
13 inline dcovector::dcovector(const dcovector& vec)
14 {CPPL_VERBOSE_REPORT;
15  //////// initialize ////////
16  l =vec.l;
17  cap =vec.cap;
18  array =new double[cap];
19 
20  //////// copy ////////
21  CPPL_INT inc =1;
22  dcopy_(&l, vec.array, &inc, array, &inc);
23 }
24 
25 //=============================================================================
26 /*! dcovector constructor to cast _dcovector */
27 inline dcovector::dcovector(const _dcovector& vec)
28 {CPPL_VERBOSE_REPORT;
29  //////// initialize ////////
30  l =vec.l;
31  cap =vec.cap;
32  array =vec.array;
33 
34  vec.nullify();
35 }
36 
37 //=============================================================================
38 /*! dcovector constructor with size specification */
39 inline dcovector::dcovector(const CPPL_INT& _l, const CPPL_INT margin)
40 {CPPL_VERBOSE_REPORT;
41 #ifdef CPPL_DEBUG
42  if( _l<0 ){
43  ERROR_REPORT;
44  std::cerr << "Vector size must be positive integers. " << std::endl
45  << "Your input was (" << _l << ")." << std::endl;
46  exit(1);
47  }
48  if( margin<0 ){
49  ERROR_REPORT;
50  std::cerr << "Vector margin must be zero or above. " << std::endl
51  << "Your input was (" << _l << ", " << margin << ")." << std::endl;
52  exit(1);
53  }
54 #endif//CPPL_DEBUG
55 
56  //////// initialize ////////
57  l =_l;
58  cap =l+margin;
59  array =new double[cap];
60 }
61 
62 //=============================================================================
63 /*! dcovector constructor with filename */
64 inline dcovector::dcovector(const char* filename)
65 {CPPL_VERBOSE_REPORT;
66  array =NULL;
67  read(filename);
68 }
69 
70 ///////////////////////////////////////////////////////////////////////////////
71 ///////////////////////////////////////////////////////////////////////////////
72 ///////////////////////////////////////////////////////////////////////////////
73 
74 //=============================================================================
75 /*! dcovector destructor */
77 {CPPL_VERBOSE_REPORT;
78  //////// delete array ////////
79  delete [] array;
80 }
CPPL_INT l
vector size
Definition: _dcovector.hpp:9
CPPL_INT l
vector size
Definition: dcovector.hpp:9
CPPL_INT cap
vector capacity
Definition: _dcovector.hpp:10
double * array
1D array to store vector data
Definition: dcovector.hpp:11
void read(const char *)
Real Double-precision Column Vector Class.
Definition: dcovector.hpp:3
(DO NOT USE) Smart-temporary Real Double-precision Column Vector Class
Definition: _dcovector.hpp:3
double * array
1D array to store vector data
Definition: _dcovector.hpp:11
void nullify() const
CPPL_INT cap
vector capacity
Definition: dcovector.hpp:10