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