Go to the documentation of this file.00001
00002
00003 inline void drovector::clear()
00004 {VERBOSE_REPORT;
00005 l =0;
00006 cap =0;
00007 delete [] array;
00008 array =NULL;
00009 }
00010
00011
00012
00013 inline drovector& drovector::zero()
00014 {VERBOSE_REPORT;
00015 for(long i=0; i<l; i++){ array[i] =0.0; }
00016 return *this;
00017 }
00018
00019
00020
00021 inline void drovector::chsign()
00022 {VERBOSE_REPORT;
00023 for(long i=0; i<l; i++){ array[i] =-array[i]; }
00024 }
00025
00026
00027
00028 inline void drovector::copy(const drovector& vec)
00029 {VERBOSE_REPORT;
00030 l =vec.l;
00031 cap =vec.cap;
00032 delete [] array;
00033 array =new double[vec.cap];
00034 dcopy_(vec.l, vec.array, 1, array, 1);
00035 }
00036
00037
00038
00039
00040 inline void drovector::shallow_copy(const _drovector& vec)
00041 {VERBOSE_REPORT;
00042 l =vec.l;
00043 cap =vec.cap;
00044 delete [] array;
00045 array =vec.array;
00046
00047 vec.nullify();
00048 }
00049
00050
00051
00052
00053 inline void drovector::alias(const drovector& vec)
00054 {VERBOSE_REPORT;
00055 l =vec.l;
00056 cap =vec.cap;
00057 delete [] array;
00058 array =vec.array;
00059 }
00060
00061
00062
00063 inline void drovector::unalias()
00064 {VERBOSE_REPORT;
00065 l =0;
00066 cap =0;
00067 array =NULL;
00068 }
00069
00070
00071
00072 inline drovector& drovector::resize(const long& _l, const long margin)
00073 {VERBOSE_REPORT;
00074 #ifdef CPPL_DEBUG
00075 if( _l<0 || margin<0 ){
00076 ERROR_REPORT;
00077 std::cerr << "Vector size must be positive integers." << std::endl
00078 << "Your input was (" << _l << ", " << margin << ")." << std::endl;
00079 exit(1);
00080 }
00081 #endif//CPPL_DEBUG
00082
00083 l =_l;
00084 cap =l+margin;
00085 delete [] array;
00086 array =new double[cap];
00087
00088 return *this;
00089 }
00090
00091
00092
00093 inline void drovector::stretch(const long& dl)
00094 {VERBOSE_REPORT;
00095 #ifdef CPPL_DEBUG
00096 if( l+dl<0 ){
00097 ERROR_REPORT;
00098 std::cerr << "Vector size must be positive integers." << std::endl
00099 << "Your input was (" << dl << ")." << std::endl;
00100 exit(1);
00101 }
00102 #endif//CPPL_DEBUG
00103
00104
00105 if(dl==0){ return; }
00106
00107
00108 l +=dl;
00109
00110 if(l>cap){
00111 while(l>cap){
00112 cap++;
00113 cap*=2;
00114 }
00115 double* newArray(new double[cap]);
00116 dcopy_(l-dl, array, 1, newArray, 1);
00117 delete [] array;
00118 array =newArray;
00119 }
00120 }
00121
00122
00123
00124 inline void swap(drovector& u, drovector& v)
00125 {VERBOSE_REPORT;
00126 long u_cap(u.cap), u_l(u.l);
00127 double* u_array(u.array);
00128 u.l=v.l; u.cap=v.cap; u.array=v.array;
00129 v.l=u_l; v.cap=u_cap; v.array=u_array;
00130 }
00131
00132
00133
00134 inline _drovector _(drovector& vec)
00135 {VERBOSE_REPORT;
00136 _drovector newvec;
00137
00138
00139 newvec.l =vec.l;
00140 newvec.cap =vec.cap;
00141 newvec.array =vec.array;
00142
00143
00144 vec.l =0;
00145 vec.cap =0;
00146 vec.array =NULL;
00147
00148 return newvec;
00149 }