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   if(array!=mat.array){ // if it is NOT self substitution
00006     copy(mat);
00007   }
00008   return *this;
00009 }
00010 
00011 ///////////////////////////////////////////////////////////////////////////////
00012 ///////////////////////////////////////////////////////////////////////////////
00013 ///////////////////////////////////////////////////////////////////////////////
00014 
00015 //=============================================================================
00016 /*! dsymatrix+=dsymatrix operator */
00017 inline dsymatrix& dsymatrix::operator+=(const dsymatrix& mat)
00018 {VERBOSE_REPORT;
00019 #ifdef  CPPL_DEBUG
00020   if(n!=mat.n){
00021     ERROR_REPORT;
00022     std::cerr << "These two matrises can not make a summation." << std::endl
00023               << "Your input was (" << n << "x" << n << ") += (" << mat.n << "x" << mat.n << ")." << std::endl;
00024     exit(1);
00025   }
00026 #endif//CPPL_DEBUG
00027   
00028   for(long i=0; i<n; i++){
00029     for(long j=0; j<=i; j++){
00030       darray[j][i] +=mat.darray[j][i];
00031     }
00032   }
00033   
00034   return *this;
00035 }
00036 
00037 //=============================================================================
00038 /*! dsymatrix operator-= */
00039 inline dsymatrix& dsymatrix::operator-=(const dsymatrix& mat)
00040 {VERBOSE_REPORT;
00041 #ifdef  CPPL_DEBUG
00042   if(n!=mat.n){
00043     ERROR_REPORT;
00044     std::cerr << "These two matrises can not make a sutraction." << std::endl
00045               << "Your input was (" << n << "x" << n << ") -= (" << mat.n << "x" << mat.n << ")." << std::endl;
00046     exit(1);
00047   }
00048 #endif//CPPL_DEBUG
00049   
00050   for(long i=0; i<n; i++){
00051     for(long j=0; j<=i; j++){
00052       darray[j][i] -=mat.darray[j][i];
00053     }
00054   }
00055   
00056   return *this;
00057 }
00058 
00059 //=============================================================================
00060 /*! dsymatrix+dsymatrix operator */
00061 inline _dsymatrix operator+(const dsymatrix& matA, const dsymatrix& 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   long n = matA.n;
00073   dsymatrix newmat(n);
00074   for(long i=0; i<n; i++){
00075     for(long j=0; j<=i; j++){
00076       newmat.darray[j][i] =matA.darray[j][i] +matB.darray[j][i];
00077     }
00078   }
00079   
00080   return _(newmat);
00081 }
00082 
00083 //=============================================================================
00084 /*! dsymatrix-dsymatrix operator */
00085 inline _dsymatrix operator-(const dsymatrix& matA, const dsymatrix& matB)
00086 {VERBOSE_REPORT;
00087 #ifdef  CPPL_DEBUG
00088   if(matA.n!=matB.n){
00089     ERROR_REPORT;
00090     std::cerr << "These two matrises can not make a subtraction." << std::endl
00091               << "Your input was (" << matA.n << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
00092     exit(1);
00093   }
00094 #endif//CPPL_DEBUG
00095 
00096   long n = matA.n;
00097   dsymatrix newmat(n);
00098   for(long i=0; i<n; i++){
00099     for(long j=0; j<=i; j++){
00100       newmat.darray[j][i] =matA.darray[j][i] -matB.darray[j][i];
00101     }
00102   }
00103 
00104   return _(newmat);
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   return _(newmat);
00128 }
 All Classes Files Functions Variables Friends