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