00001
00002
00003 inline _dgematrix operator+(const _dgematrix& matA, const dgematrix& matB)
00004 {
00005 #ifdef CPPSL_DEBUG
00006 if(matA.N!=matB.N || matA.M!=matB.M){
00007 std::cerr << "[ERROR] operator+(const _dgematrix&, const dgematrix&)"
00008 << std::endl
00009 << "These two matrises can not make a summation." << std::endl
00010 << "Your input was (" << matA.M << "x" << matA.N << ") + ("
00011 << matB.M << "x" << matB.N << ")." << std::endl;
00012 exit(1);
00013 }
00014 #endif//CPPSL_DEBUG
00015
00016 for(long i=0; i<matA.Ml*matA.Nl; i++){ matA.Array[i] +=matB.Array[i]; }
00017
00018 return matA;
00019 }
00020
00021
00022
00023 inline _dgematrix operator-(const _dgematrix& matA, const dgematrix& matB)
00024 {
00025 #ifdef CPPSL_DEBUG
00026 if(matA.N!=matB.N || matA.M!=matB.M){
00027 std::cerr << "[ERROR] operator-(const _dgematrix&, const dgematrix&)"
00028 << std::endl
00029 << "These two matrises can not make a subtraction." << std::endl
00030 << "Your input was (" << matA.M << "x" << matA.N << ") - ("
00031 << matB.M << "x" << matB.N << ")." << std::endl;
00032 exit(1);
00033 }
00034 #endif//CPPSL_DEBUG
00035
00036 for(long i=0; i<matA.Ml*matA.Nl; i++){ matA.Array[i] -=matB.Array[i]; }
00037
00038 return matA;
00039 }
00040
00041
00042
00043 inline _dgematrix operator*(const _dgematrix& matA, const dgematrix& matB)
00044 {
00045 #ifdef CPPSL_DEBUG
00046 if(matA.N!=matB.M){
00047 std::cerr << "[ERROR] operator*(const _dgematrix&, const dgematrix&)"
00048 << std::endl
00049 << "These two matrises can not make a product." << std::endl
00050 << "Your input was (" << matA.M << "x" << matA.N << ") * ("
00051 << matB.M << "x" << matB.N << ")." << std::endl;
00052 exit(1);
00053 }
00054 #endif//CPPSL_DEBUG
00055
00056 _dgematrix newmat( matA.M, matB.N );
00057 pdgemm_( 'N', 'N', matA.M, matB.N, matA.N, 1.0,
00058 matA.Array, 1, 1, matA.Desc,
00059 matB.Array, 1, 1, matB.Desc, 0.0,
00060 newmat.Array, 1, 1, newmat.Desc );
00061
00062 matA.destroy();
00063 return newmat;
00064 }