Main Page | Class List | File List | Class Members | File Members | Related Pages

drovector-misc.hpp

Go to the documentation of this file.
00001 //=============================================================================
00002 /*! clear vector */
00003 inline void drovector::clear()
00004 {
00005 #ifdef  CPPSL_DEBUG
00006   std::cerr << "# [NOTE] drovector::clear() "
00007        << "An array at " << array << " is going to be cleared." << std::endl;
00008 #endif//CPPSL_DEBUG
00009   
00010   L =0;
00011   Ll =0;
00012   Desc[0]=1; Desc[1]=icontxt; Desc[2]=0; Desc[3]=0; Desc[4]=mb; Desc[5]=nb;
00013   Desc[6]=0; Desc[7]=0; Desc[8]=1;
00014   delete [] Array;
00015   Array =new double[0];
00016 }
00017 
00018 //=============================================================================
00019 /*! make vector into zero vector */
00020 inline void drovector::zero()
00021 {
00022   for(long i=0; i<Ll; i++){ Array[i] =0.0; }
00023 }
00024 
00025 //=============================================================================
00026 /*! change sign(+/-) of the vector */
00027 inline void drovector::chsign()
00028 {
00029   for(long i=0; i<Ll; i++){ Array[i] =-Array[i]; }
00030 }
00031 
00032 //=============================================================================
00033 /*! make a deep copy of the drovector */
00034 inline void drovector::copy(const drovector& vec)
00035 {
00036 #ifdef  CPPSL_DEBUG
00037   std::cerr << "# [NOTE] drovector::copy(const drovector&) "
00038             << "A drovector at " << Array << " is going to be deleted. ";
00039 #endif//CPPSL_DEBUG
00040   
00041   delete [] Array;
00042   L =vec.L;
00043   Ll =vec.Ll;
00044   for(int i=0; i<9; i++){ Desc[i] =vec.Desc[i]; }
00045   Array =new double[Ll];
00046   dcopy_(Ll, vec.Array, 1, Array, 1);
00047   
00048 #ifdef  CPPSL_DEBUG
00049   std::cerr << "Then, a COPY of a drovector has been cleated at "
00050             << Array << "." << std::endl;
00051 #endif//CPPSL_DEBUG
00052 }
00053 
00054 //=============================================================================
00055 /*! make a shaLlow copy of the vector */
00056 inline void drovector::shallow_copy(const _drovector& vec)
00057 {
00058 #ifdef  CPPSL_DEBUG
00059   std::cerr << "# [NOTE] drovector::shaLlow_copy(const _drovector&) "
00060             << "A drovector at " << Array << " is going to be deleted "
00061             << "and point to " << vec.Array << " instead." << std::endl;
00062 #endif//CPPSL_DEBUG
00063   
00064   delete [] Array;
00065   L =vec.L;
00066   Ll =vec.Ll;
00067   for(int i=0; i<9; i++){ Desc[i] =vec.Desc[i]; }
00068   Array =vec.Array;
00069 }
00070 
00071 //=============================================================================
00072 /*! resize vector */
00073 inline void drovector::resize(const long& _l)
00074 {
00075 #ifdef  CPPSL_DEBUG
00076   if( _l<0 ){
00077     std::cerr << "[ERROR] drovector::resize(const long&)" << std::endl
00078               << "Vector size must be positive integers." << std::endl
00079               << "Your input was (" << _l << ")." << std::endl;
00080     exit(1);
00081   }
00082 #endif//CPPSL_DEBUG
00083   
00084   L =_l;
00085   long nl(numroc_(L, nb, mycol, 0, npcol));
00086   if(myrow==0){ Ll=nl; } else{ Ll=0; }
00087   Desc[0]=1; Desc[1]=icontxt; Desc[2]=L; Desc[3]=1; Desc[4]=mb; Desc[5]=nb;
00088   Desc[6]=0; Desc[7]=0; Desc[8]=1;
00089   delete [] Array;
00090   Array =new double[Ll];
00091 }
00092 
00093 //=============================================================================
00094 /*! swap two vectors */
00095 inline void swap(drovector& u, drovector& v)
00096 {
00097   long u_L(u.L), u_Ll(u.Ll), u_Desc[9];
00098   double* u_Array(u.Array);
00099   u.L=v.L; u.Ll=v.Ll;  u.Array=v.Array;
00100   v.L=u_L; v.Ll=u_Ll;  v.Array=u_Array;
00101   for(int i=0; i<9; i++){
00102     u_Desc[i] =u.Desc[i];
00103     u.Desc[i] =v.Desc[i];
00104     v.Desc[i] =u_Desc[i];
00105   }
00106 }

Generated on Sat Jan 31 19:25:44 2004 for CPPScaLapack by doxygen 1.3.5