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