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

dgematrix-dgematrix.hpp

Go to the documentation of this file.
00001 //=============================================================================
00002 /*! dgematrix=dgematrix operator */
00003 inline dgematrix& dgematrix::operator=(const dgematrix& mat)
00004 {
00005 #ifdef  CPPL_DEBUG
00006   std::cerr << "# [NOTE] dgematrix::operator=(const dgematrix&) was called."
00007             << std::endl;
00008 #endif//CPPL_DEBUG
00009   
00010   if(Array!=mat.Array){ // if it is NOT self substitution
00011     copy(mat);
00012   }
00013   return *this;
00014 }
00015 
00016 ///////////////////////////////////////////////////////////////////////////////
00017 ///////////////////////////////////////////////////////////////////////////////
00018 ///////////////////////////////////////////////////////////////////////////////
00019 
00020 //=============================================================================
00021 /*! dgematrix+=dgematrix operator */
00022 inline dgematrix& dgematrix::operator+=(const dgematrix& mat)
00023 {
00024 #ifdef  CPPSL_DEBUG
00025   if(N!=mat.N || M!=mat.M){
00026     std::cerr << "[ERROR] dgematrix::operator+=(const dgematrix&)" << std::endl
00027               << "These two matrises can not make a summation." << std::endl
00028               << "Your input was (" << M << "x" << N << ") += ("
00029               << mat.M << "x" << mat.N << ")." << std::endl;
00030     exit(1);
00031   }
00032 #endif//CPPSL_DEBUG
00033   
00034   for(long i=0; i<Ml*Nl; i++){ Array[i]+=mat.Array[i]; }
00035   return *this;
00036 }
00037 
00038 //=============================================================================
00039 /*! dgematrix operator-= */
00040 inline dgematrix& dgematrix::operator-=(const dgematrix& mat)
00041 {
00042 #ifdef  CPPSL_DEBUG
00043   if(N!=mat.N || M!=mat.M){
00044     std::cerr << "[ERROR] dgematrix::operator-=(const dgematrix&)" << std::endl
00045               << "These two matrises can not make a sutraction." << std::endl
00046               << "Your input was (" << M << "x" << N << ") -= ("
00047               << mat.M << "x" << mat.N << ")." << std::endl;
00048     exit(1);
00049   }
00050 #endif//CPPSL_DEBUG
00051   
00052   for(long i=0; i<Ml*Nl; i++){ Array[i]-=mat.Array[i]; }
00053   return *this;
00054 }
00055 
00056 //=============================================================================
00057 /*! dgematrix operator*= */
00058 inline dgematrix& dgematrix::operator*=(const dgematrix& mat)
00059 {
00060 #ifdef  CPPSL_DEBUG
00061   if(N!=mat.M){
00062     std::cerr << "[ERROR] dgematrix::operator*=(const dgematrix&)" << std::endl
00063               << "These two matrises can not make a product." << std::endl
00064               << "Your input was (" << M << "x" << N << ") *= ("
00065               << mat.M << "x" << mat.N << ")." << std::endl;
00066     exit(1);
00067   }
00068 #endif//CPPSL_DEBUG
00069   
00070   _dgematrix newmat( M, mat.N );
00071   pdgemm_( 'N', 'N', M, mat.N, N, 1.0, Array, 1, 1, Desc,
00072            mat.Array, 1, 1, mat.Desc, 0.0, newmat.Array, 1, 1, newmat.Desc );
00073   shallow_copy(newmat);
00074   
00075   return *this;
00076 }
00077 
00078 ///////////////////////////////////////////////////////////////////////////////
00079 ///////////////////////////////////////////////////////////////////////////////
00080 ///////////////////////////////////////////////////////////////////////////////
00081 
00082 //=============================================================================
00083 /*! dgematrix+dgematrix operator */
00084 inline _dgematrix operator+(const dgematrix& matA, const dgematrix& matB)
00085 {
00086 #ifdef  CPPSL_DEBUG
00087   if(matA.N!=matB.N || matA.M!=matB.M){
00088     std::cerr << "[ERROR] operator+(const dgematrix&, const dgematrix&)"
00089               << std::endl
00090               << "These two matrises can not make a summation." << std::endl
00091               << "Your input was (" << matA.M << "x" << matA.N << ") + ("
00092               << matB.M << "x" << matB.N << ")." << std::endl;
00093     exit(1);
00094   }
00095 #endif//CPPSL_DEBUG
00096 
00097   _dgematrix newmat(matA.M,matA.N);
00098   for(long i=0; i<newmat.Ml*newmat.Nl; i++){
00099     newmat.Array[i] =matA.Array[i]+matB.Array[i];
00100   }
00101   
00102   return newmat;
00103 }
00104 
00105 //=============================================================================
00106 /*! dgematrix-dgematrix operator */
00107 inline _dgematrix operator-(const dgematrix& matA, const dgematrix& matB)
00108 {
00109 #ifdef  CPPSL_DEBUG
00110   if(matA.N!=matB.N || matA.M!=matB.M){
00111     std::cerr << "[ERROR] operator-(const dgematrix&, const dgematrix&)"
00112               << std::endl
00113               << "These two matrises can not make a subtraction." << std::endl
00114               << "Your input was (" << matA.M << "x" << matA.N << ") - ("
00115               << matB.M << "x" << matB.N << ")." << std::endl;
00116     exit(1);
00117   }
00118 #endif//CPPSL_DEBUG
00119   
00120   _dgematrix newmat(matA.M,matA.N);
00121   for(long i=0; i<newmat.Ml*newmat.Nl; i++){
00122     newmat.Array[i] =matA.Array[i]-matB.Array[i];
00123   }
00124   
00125   return newmat;
00126 }
00127 
00128 //=============================================================================
00129 /*! dgematrix*dgematrix operator */
00130 inline _dgematrix operator*(const dgematrix& matA, const dgematrix& matB)
00131 {
00132 #ifdef  CPPSL_DEBUG
00133   if(matA.N!=matB.M){
00134     std::cerr << "[ERROR] operator*(const dgematrix&, const dgematrix&)"
00135               << std::endl
00136               << "These two matrises can not make a product." << std::endl
00137               << "Your input was (" << matA.M << "x" << matA.N << ") * ("
00138               << matB.M << "x" << matB.N << ")." << std::endl;
00139     exit(1);
00140   }
00141 #endif//CPPSL_DEBUG
00142   
00143   _dgematrix newmat( matA.M, matB.N );
00144   pdgemm_( 'N', 'N', matA.M, matB.N, matA.N, 1.0,
00145            matA.Array, 1, 1, matA.Desc,
00146            matB.Array, 1, 1, matB.Desc, 0.0,
00147            newmat.Array, 1, 1, newmat.Desc );
00148   
00149   return newmat;
00150 }

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