CPPLapack
 All Classes Files Functions Variables Friends
_zgematrix-zssmatrix.hpp
Go to the documentation of this file.
00001 //=============================================================================
00002 /*! _zgematrix+zhematrix operator */
00003 inline _zgematrix operator+(const _zgematrix& matA, const zhematrix& matB)
00004 {VERBOSE_REPORT;
00005 #ifdef  CPPL_DEBUG
00006   if(matA.m!=matB.m || matA.n!=matB.n){
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 c=0; c<matB.vol; c++){
00015     matA(matB.indx[c],matB.jndx[c]) += matB.array[c];
00016   }
00017   
00018   return matA;
00019 }
00020 
00021 //=============================================================================
00022 /*! _zgematrix-zhematrix operator */
00023 inline _zgematrix operator-(const _zgematrix& matA, const zhematrix& matB)
00024 {VERBOSE_REPORT;
00025 #ifdef  CPPL_DEBUG
00026   if(matA.m!=matB.m || matA.n!=matB.n){
00027     ERROR_REPORT;
00028     std::cerr << "These two matrises can not make a subtraction." << std::endl
00029               << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
00030     exit(1);
00031   }
00032 #endif//CPPL_DEBUG
00033   
00034   //// change sign ////
00035   for(long i=0; i<matA.m*matA.n; i++){
00036     matA.array[i]=-matA.array[i];
00037   }
00038   
00039   //// add ////
00040   for(long c=0; c<matB.vol; c++){
00041     matA(matB.indx[c],matB.jndx[c]) += matB.array[c];
00042   }
00043   
00044   return matA;
00045 }
00046 
00047 //=============================================================================
00048 /*! _zgematrix*zhematrix operator */
00049 inline _zgematrix operator*(const _zgematrix& matA, const zhematrix& matB)
00050 {VERBOSE_REPORT;
00051 #ifdef  CPPL_DEBUG
00052   if(matA.n!=matB.m){
00053     ERROR_REPORT;
00054     std::cerr << "These two matrises can not make a product." << std::endl
00055               << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl;
00056     exit(1);
00057   }
00058 #endif//CPPL_DEBUG
00059   
00060   zgematrix newmat(matA.m, matB.n);
00061   newmat.zero();
00062   
00063   for(long c=0; c<matB.vol; c++){
00064     for(long i=0; i<matA.m; i++){
00065       newmat(i,matB.jndx[c]) += matA(i,matB.indx[c])*matB.array[c];
00066     }
00067   }
00068   
00069   matA.destroy();
00070   return _(newmat);
00071 }
 All Classes Files Functions Variables Friends