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   shallow_copy(mat);
00006   return *this;
00007 }
00008 
00009 ///////////////////////////////////////////////////////////////////////////////
00010 ///////////////////////////////////////////////////////////////////////////////
00011 ///////////////////////////////////////////////////////////////////////////////
00012 
00013 //=============================================================================
00014 /*! zgematrix+=_zgematrix operator */
00015 inline zgematrix& zgematrix::operator+=(const _zgematrix& mat)
00016 {VERBOSE_REPORT;
00017 #ifdef  CPPL_DEBUG
00018   if(n!=mat.n || m!=mat.m){
00019     ERROR_REPORT;
00020     std::cerr << "These two matrises can not make a summation." << std::endl
00021               << "Your input was (" << m << "x" << n << ") += (" << mat.m << "x" << mat.n << ")." << std::endl;
00022     exit(1);
00023   }
00024 #endif//CPPL_DEBUG
00025   
00026   for(long i=0; i<m*n; i++){ array[i]+=mat.array[i]; }
00027   
00028   mat.destroy();
00029   return *this;
00030 }
00031 
00032 //=============================================================================
00033 /*! zgematrix-=_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 
00047   mat.destroy();
00048   return *this;
00049 }
00050 
00051 //=============================================================================
00052 /*! zgematrix*=_zgematrix operator */
00053 inline zgematrix& zgematrix::operator*=(const _zgematrix& mat)
00054 {VERBOSE_REPORT;
00055 #ifdef  CPPL_DEBUG
00056   if(n!=mat.m){
00057     ERROR_REPORT;
00058     std::cerr << "These two matrises can not make a product." << std::endl
00059               << "Your input was (" << m << "x" << n << ") *= (" << mat.m << "x" << mat.n << ")." << std::endl;
00060     exit(1);
00061   }
00062 #endif//CPPL_DEBUG
00063   
00064   zgematrix newmat( m, mat.n );
00065   zgemm_( 'n', 'n', m, mat.n, n, comple(1.0,0.0), array, m,
00066           mat.array, mat.m, comple(0.0,0.0), newmat.array, m );
00067   
00068   swap(*this,newmat);
00069   mat.destroy();
00070   return *this;
00071 }
00072 
00073 ///////////////////////////////////////////////////////////////////////////////
00074 ///////////////////////////////////////////////////////////////////////////////
00075 ///////////////////////////////////////////////////////////////////////////////
00076 
00077 //=============================================================================
00078 /*! zgematrix+_zgematrix operator */
00079 inline _zgematrix operator+(const zgematrix& matA, const _zgematrix& matB)
00080 {VERBOSE_REPORT;
00081 #ifdef  CPPL_DEBUG
00082   if(matA.n!=matB.n || matA.m!=matB.m){
00083     ERROR_REPORT;
00084     std::cerr << "These two matrises can not make a summation." << std::endl
00085               << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
00086     exit(1);
00087   }
00088 #endif//CPPL_DEBUG
00089 
00090   for(long i=0; i<matA.m*matA.n; i++){ matB.array[i] +=matA.array[i]; }
00091   
00092   return matB;
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   for(long i=0; i<matA.m*matA.n; i++){
00109     matB.array[i] =matA.array[i]-matB.array[i];
00110   }
00111   
00112   return matB;
00113 }
00114 
00115 //=============================================================================
00116 /*! zgematrix*_zgematrix operator */
00117 inline _zgematrix operator*(const zgematrix& matA, const _zgematrix& matB)
00118 {VERBOSE_REPORT;
00119 #ifdef  CPPL_DEBUG
00120   if(matA.n!=matB.m){
00121     ERROR_REPORT;
00122     std::cerr << "These two matrises can not make a product." << std::endl
00123               << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
00124     exit(1);
00125   }
00126 #endif//CPPL_DEBUG
00127   
00128   zgematrix newmat( matA.m, matB.n );
00129   zgemm_( 'n', 'n', matA.m, matB.n, matA.n, comple(1.0,0.0),
00130           matA.array, matA.m, matB.array, matB.m,
00131           comple(0.0,0.0), newmat.array, matA.m );
00132   
00133   matB.destroy();
00134   return _(newmat);
00135 }
 All Classes Files Functions Variables Friends