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

dcovector-dcovector.hpp

Go to the documentation of this file.
00001 //=============================================================================
00002 /*! dcovector=dcovector operator */
00003 inline dcovector& dcovector::operator=(const dcovector& vec)
00004 {
00005 #ifdef  CPPSL_DEBUG
00006   std::cerr << "# [NOTE] dcovector::operator=(const dcovector&) was called."
00007             << std::endl;
00008 #endif//CPPSL_DEBUG
00009   
00010   if(Array!=vec.Array){ // if it is NOT self substitution
00011     copy(vec);
00012   }
00013   return *this;
00014 }
00015 
00016 ///////////////////////////////////////////////////////////////////////////////
00017 ///////////////////////////////////////////////////////////////////////////////
00018 ///////////////////////////////////////////////////////////////////////////////
00019 
00020 //=============================================================================
00021 /*! dcovector+=dcovector operator */
00022 inline dcovector& dcovector::operator+=(const dcovector& vec)
00023 {
00024 #ifdef  CPPSL_DEBUG
00025   if( L!=vec.L ){
00026     std::cerr << "[ERROR] dcovector::operator+=(const dcovector&)" << std::endl
00027               << "These two vectors can not make a sumation." << std::endl
00028               << "Your input was (" << L << ") += (" << vec.L << ")."
00029               << std::endl;
00030     exit(1);
00031   }
00032 #endif//CPPSL_DEBUG
00033   
00034   for(int i=0; i<Ll; i++){ Array[i] +=vec.Array[i]; }
00035   
00036   return *this;
00037 }
00038 
00039 //=============================================================================
00040 /*! dcovector operator-= */
00041 inline dcovector& dcovector::operator-=(const dcovector& vec)
00042 {
00043 #ifdef  CPPSL_DEBUG
00044   if( L!=vec.L ){
00045     std::cerr << "[ERROR] dcovector::operator-=(const dcovector&)" << std::endl
00046               << "These two vectors can not make a subtraction." << std::endl
00047               << "Your input was (" << L << ") -= (" << vec.L << ")."
00048               << std::endl;
00049     exit(1);
00050   }
00051 #endif//CPPSL_DEBUG
00052   
00053   for(int i=0; i<Ll; i++){ Array[i] -=vec.Array[i]; }
00054   
00055   return *this;
00056 }
00057 
00058 ///////////////////////////////////////////////////////////////////////////////
00059 ///////////////////////////////////////////////////////////////////////////////
00060 ///////////////////////////////////////////////////////////////////////////////
00061 
00062 //=============================================================================
00063 /*! dcovector+dcovector operator */
00064 inline _dcovector operator+(const dcovector& vecA, const dcovector& vecB)
00065 {
00066 #ifdef  CPPSL_DEBUG
00067   if(vecA.L!=vecB.L){
00068     std::cerr
00069       << "[ERROR] operator+(const dcovector&, const dcovector&)" << std::endl
00070       << "These two vectors can not make a sumation." << std::endl
00071       << "Your input was (" << vecA.L << ") + (" << vecB.L << ")."
00072       << std::endl;
00073     exit(1);
00074   }
00075   
00076 #endif//CPPSL_DEBUG
00077 
00078   _dcovector newvec(vecA.L);
00079   for(int i=0; i<newvec.Ll; i++){
00080     newvec.Array[i] =vecA.Array[i]+vecB.Array[i];
00081   }
00082   
00083   return newvec;
00084 }
00085 
00086 //=============================================================================
00087 /*! dcovector-dcovector operator */
00088 inline _dcovector operator-(const dcovector& vecA, const dcovector& vecB)
00089 {
00090 #ifdef  CPPSL_DEBUG
00091   if(vecA.L!=vecB.L){
00092     std::cerr
00093       << "[ERROR] operator-(const dcovector&, const dcovector&)" << std::endl
00094       << "These two vectors can not make a subtraction." << std::endl
00095       << "Your input was (" << vecA.L << ") - (" << vecB.L << ")."
00096       << std::endl;
00097     exit(1);
00098   }
00099 #endif//CPPSL_DEBUG
00100   
00101   _dcovector newvec(vecA.L);
00102   for(int i=0; i<newvec.Ll; i++){
00103     newvec.Array[i] =vecA.Array[i]-vecB.Array[i];
00104   }
00105   
00106   return newvec;
00107 }
00108 
00109 //=============================================================================
00110 /*! dcovector^T*dcovector operator (inner product) */
00111 inline double operator%(const dcovector& vecA, const dcovector& vecB)
00112 {
00113 #ifdef  CPPSL_DEBUG
00114   if(vecA.L!=vecB.L){
00115     std::cerr
00116       << "[ERROR] operator%(const dcovector&, const dcovector&)" << std::endl
00117       << "These two vectors can not make a dot product." << std::endl
00118       << "Your input was (" << vecA.L << ") % (" << vecB.L << ")."
00119       << std::endl;
00120     exit(1);
00121   }
00122 #endif//CPPSL_DEBUG
00123   
00124   double val;
00125   pddot_( vecA.L, val,
00126           vecA.Array, 1, 1, vecA.Desc, 1, vecB.Array, 1, 1, vecB.Desc, 1 );
00127   
00128   return val;
00129 }

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