CPPLapack
 All Classes Files Functions Variables Friends Pages
zrovector-misc.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! clear vector */
3 inline void zrovector::clear()
4 {CPPL_VERBOSE_REPORT;
5  l =0;
6  delete [] array;
7  array =NULL;
8 }
9 
10 //=============================================================================
11 /*! make vector into zero vector */
13 {CPPL_VERBOSE_REPORT;
14  for(CPPL_INT i=0; i<l; i++){
15  array[i] =comple(0.,0.);
16  }
17  return *this;
18 }
19 
20 //=============================================================================
21 /*! change sign(+/-) of the vector */
22 inline void zrovector::chsign()
23 {CPPL_VERBOSE_REPORT;
24  for(CPPL_INT i=0; i<l; i++){
25  array[i] =-array[i];
26  }
27 }
28 
29 //=============================================================================
30 /*! make a deep copy of the zrovector */
31 inline void zrovector::copy(const zrovector& vec)
32 {CPPL_VERBOSE_REPORT;
33  delete [] array;
34  l =vec.l;
35  array =new comple[vec.l];
36  CPPL_INT inc =1;
37 
38  zcopy_(&vec.l, vec.array, &inc, array, &inc);
39 }
40 
41 //=============================================================================
42 /*! make a shallow copy of the vector\n
43  This function is not desinged to be used in project codes. */
44 inline void zrovector::shallow_copy(const _zrovector& vec)
45 {CPPL_VERBOSE_REPORT;
46  l =vec.l;
47  delete [] array;
48  array =vec.array;
49 
50  vec.nullify();
51 }
52 
53 //=============================================================================
54 /*! make an alias of the vector\n
55  Be carefull to use this function not to cause double free. */
56 inline void zrovector::alias(const zrovector& vec)
57 {CPPL_VERBOSE_REPORT;
58  l =vec.l;
59  //cap =vec.cap;
60  delete [] array;
61  array =vec.array;
62 }
63 
64 //=============================================================================
65 /*! unalias the vector */
66 inline void zrovector::unalias()
67 {CPPL_VERBOSE_REPORT;
68  l =0;
69  //cap =0;
70  array =NULL;
71 }
72 
73 //=============================================================================
74 /*! resize vector */
75 inline void zrovector::resize(const CPPL_INT& _l)
76 {CPPL_VERBOSE_REPORT;
77 #ifdef CPPL_DEBUG
78  if( _l<0 ){
79  ERROR_REPORT;
80  std::cerr << "Vector size must be positive integers." << std::endl
81  << "Your input was (" << _l << ")." << std::endl;
82  exit(1);
83  }
84 #endif//CPPL_DEBUG
85 
86  l =_l;
87  delete [] array;
88  array =new comple[_l];
89 }
90 
91 //=============================================================================
92 /*! swap two vectors */
93 inline void swap(zrovector& u, zrovector& v)
94 {CPPL_VERBOSE_REPORT;
95  CPPL_INT u_L =u.l;
96  comple* u_Array =u.array;
97  u.l=v.l; u.array=v.array;
98  v.l=u_L; v.array=u_Array;
99 }
100 
101 //=============================================================================
102 /*! convert user object to smart-temporary object */
103 inline _zrovector _(zrovector& vec)
104 {CPPL_VERBOSE_REPORT;
105  _zrovector newvec;
106 
107  //////// shallow copy ////////
108  newvec.l =vec.l;
109  newvec.array =vec.array;
110 
111  //////// nullify ////////
112  vec.l =0;
113  vec.array =NULL;
114 
115  return newvec;
116 }
void shallow_copy(const _zrovector &)
_zrovector _(zrovector &vec)
void swap(zrovector &u, zrovector &v)
CPPL_INT l
vector size
Definition: zrovector.hpp:9
void alias(const zrovector &)
void resize(const CPPL_INT &)
_dgematrix i(const _dgbmatrix &mat)
CPPL_INT l
vector size
Definition: _zrovector.hpp:9
void clear()
Complex Double-precision Row Vector Class.
Definition: zrovector.hpp:3
(DO NOT USE) Smart-temporary Complex Double-precision Row Vector Class
Definition: _zrovector.hpp:3
comple * array
1D array to store vector data
Definition: _zrovector.hpp:10
void nullify() const
void unalias()
comple * array
1D array to store vector data
Definition: zrovector.hpp:10
void copy(const zrovector &)
zrovector & zero()