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