CPPLapack
 All Classes Files Functions Variables Friends
_dgematrix-_dgematrix.hpp
Go to the documentation of this file.
00001 //=============================================================================
00002 /*! _dgematrix+_dgematrix operator */
00003 inline _dgematrix operator+(const _dgematrix& matA, const _dgematrix& matB)
00004 {VERBOSE_REPORT;
00005 #ifdef  CPPL_DEBUG
00006   if(matA.n!=matB.n || matA.m!=matB.m){
00007     ERROR_REPORT;
00008     std::cerr << "These two matrises can not make a summation." << std::endl
00009               << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
00010     exit(1);
00011   }
00012 #endif//CPPL_DEBUG
00013   
00014   for(long i=0; i<matA.m*matA.n; i++){ matA.array[i]+=matB.array[i]; }
00015 
00016   matB.destroy();
00017   return matA;
00018 }
00019 
00020 //=============================================================================
00021 /*! _dgematrix-_dgematrix operator */
00022 inline _dgematrix operator-(const _dgematrix& matA, const _dgematrix& matB)
00023 {VERBOSE_REPORT;
00024 #ifdef  CPPL_DEBUG
00025   if(matA.n!=matB.n || matA.m!=matB.m){
00026     ERROR_REPORT;
00027     std::cerr << "These two matrises can not make a subtraction." << std::endl
00028               << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.m << "x" << matB.n << ")." << std::endl;
00029     exit(1);
00030   }
00031 #endif//CPPL_DEBUG
00032 
00033   for(long i=0; i<matA.m*matA.n; i++){ matA.array[i]-=matB.array[i]; }
00034   
00035   matB.destroy();
00036   return matA;
00037 }
00038 
00039 //=============================================================================
00040 /*! _dgematrix*_dgematrix operator */
00041 inline _dgematrix operator*(const _dgematrix& matA, const _dgematrix& matB)
00042 {VERBOSE_REPORT;
00043 #ifdef  CPPL_DEBUG
00044   if(matA.n!=matB.m){
00045     ERROR_REPORT;
00046     std::cerr << "These two matrises can not make a product." << std::endl
00047               << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
00048     exit(1);
00049   }
00050 #endif//CPPL_DEBUG
00051   
00052   dgematrix newmat( matA.m, matB.n );
00053   dgemm_( 'n', 'n', matA.m, matB.n, matA.n, 1.0, matA.array, matA.m,
00054           matB.array, matB.m, 0.0, newmat.array, matA.m );
00055   
00056   matA.destroy();
00057   matB.destroy();
00058   return _(newmat);
00059 }
 All Classes Files Functions Variables Friends