CPPLapack
 All Classes Files Functions Variables Friends
zcovector-misc.hpp
Go to the documentation of this file.
00001 //=============================================================================
00002 /*! clear vector */
00003 inline void zcovector::clear()
00004 {VERBOSE_REPORT;
00005   l =0;
00006   delete [] array;
00007   array =NULL;
00008 }
00009 
00010 //=============================================================================
00011 /*! make vector into zero vector */
00012 inline zcovector& zcovector::zero()
00013 {VERBOSE_REPORT;
00014   for(long i=0; i<l; i++){ array[i] =comple(0.0,0.0); }
00015   return *this;
00016 }
00017 
00018 //=============================================================================
00019 /*! change sign(+/-) of the vector */
00020 inline void zcovector::chsign()
00021 {VERBOSE_REPORT;
00022   for(long i=0; i<l; i++){ array[i] =-array[i]; }
00023 }
00024 
00025 //=============================================================================
00026 /*! make a deep copy of the zcovector */
00027 inline void zcovector::copy(const zcovector& vec)
00028 {VERBOSE_REPORT;
00029   l =vec.l;
00030   delete [] array;
00031   array =new comple[vec.l];
00032   zcopy_(vec.l, vec.array, 1, array, 1);
00033 }
00034 
00035 //=============================================================================
00036 /*! make a shallow copy of the vector\n
00037  This function is not desinged to be used in project codes. */
00038 inline void zcovector::shallow_copy(const _zcovector& vec)
00039 {VERBOSE_REPORT;
00040   l =vec.l;
00041   delete [] array;
00042   array =vec.array;
00043   
00044   vec.nullify();
00045 }
00046 
00047 //=============================================================================
00048 /*! make an alias of the vector\n
00049   Be carefull to use this function not to cause double free. */
00050 inline void zcovector::alias(const zcovector& vec)
00051 {VERBOSE_REPORT;
00052   l =vec.l;
00053   //cap =vec.cap;
00054   delete [] array;
00055   array =vec.array;
00056 }
00057 
00058 //=============================================================================
00059 /*! unalias the vector */
00060 inline void zcovector::unalias()
00061 {VERBOSE_REPORT;
00062   l =0;
00063   //cap =0;
00064   array =NULL;
00065 }
00066 
00067 //=============================================================================
00068 /*! resize vector */
00069 inline void zcovector::resize(const long& _l)
00070 {VERBOSE_REPORT;
00071 #ifdef  CPPL_DEBUG
00072   if( _l<0 ){
00073     ERROR_REPORT;
00074     std::cerr << "Vector size must be positive integers." << std::endl
00075               << "Your input was (" << _l << ")." << std::endl;
00076     exit(1);
00077   }
00078 #endif//CPPL_DEBUG
00079   
00080   l =_l;
00081   delete [] array;
00082   array =new comple[_l];
00083 }
00084 
00085 //=============================================================================
00086 /*! swap two vectors */
00087 inline void swap(zcovector& u, zcovector& v)
00088 {VERBOSE_REPORT;
00089   long u_l(u.l);
00090   comple* u_array(u.array);
00091   u.l=v.l; u.array=v.array;
00092   v.l=u_l; v.array=u_array;
00093 }
00094 
00095 //=============================================================================
00096 /*! convert user object to smart-temporary object */
00097 inline _zcovector _(zcovector& vec)
00098 {VERBOSE_REPORT;
00099   _zcovector newvec;
00100   
00101   //////// shallow copy ////////
00102   newvec.l =vec.l;
00103   newvec.array =vec.array;
00104   
00105   //////// nullify ////////
00106   vec.l =0;
00107   vec.array =NULL;
00108   
00109   return newvec;
00110 }
 All Classes Files Functions Variables Friends