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