00001
00002
00003 inline dgematrix& dgematrix::operator=(const _dgematrix& mat)
00004 {
00005 #ifdef CPPL_DEBUG
00006 std::cerr << "# [NOTE] dgematrix::operator=(const _dgematrix&) was called."
00007 << std::endl;
00008 #endif//CPPL_DEBUG
00009
00010 shallow_copy(mat);
00011 return *this;
00012 }
00013
00014
00015
00016
00017
00018
00019
00020 inline dgematrix& dgematrix::operator+=(const _dgematrix& mat)
00021 {
00022 #ifdef CPPSL_DEBUG
00023 if(N!=mat.N || M!=mat.M){
00024 std::cerr << "[ERROR] dgematrix::operator+=(const _dgematrix&)" << std::endl
00025 << "These two matrises can not make a summation." << std::endl
00026 << "Your input was (" << M << "x" << N << ") += ("
00027 << mat.M << "x" << mat.N << ")." << std::endl;
00028 exit(1);
00029 }
00030 #endif//CPPSL_DEBUG
00031
00032 for(long i=0; i<Ml*Nl; i++){ Array[i]+=mat.Array[i]; }
00033
00034 mat.destroy();
00035 return *this;
00036 }
00037
00038
00039
00040 inline dgematrix& dgematrix::operator-=(const _dgematrix& mat)
00041 {
00042 #ifdef CPPSL_DEBUG
00043 if(N!=mat.N || M!=mat.M){
00044 std::cerr << "[ERROR] dgematrix::operator-=(const _dgematrix&)" << std::endl
00045 << "These two matrises can not make a sutraction." << std::endl
00046 << "Your input was (" << M << "x" << N << ") -= ("
00047 << mat.M << "x" << mat.N << ")." << std::endl;
00048 exit(1);
00049 }
00050 #endif//CPPSL_DEBUG
00051
00052 for(long i=0; i<Ml*Nl; i++){ Array[i]-=mat.Array[i]; }
00053
00054 mat.destroy();
00055 return *this;
00056 }
00057
00058
00059
00060 inline dgematrix& dgematrix::operator*=(const _dgematrix& mat)
00061 {
00062 #ifdef CPPSL_DEBUG
00063 if(N!=mat.M){
00064 std::cerr << "[ERROR] dgematrix::operator*=(const _dgematrix&)" << std::endl
00065 << "These two matrises can not make a product." << std::endl
00066 << "Your input was (" << M << "x" << N << ") *= ("
00067 << mat.M << "x" << mat.N << ")." << std::endl;
00068 exit(1);
00069 }
00070 #endif//CPPSL_DEBUG
00071
00072 _dgematrix newmat( M, mat.N );
00073 pdgemm_( 'N', 'N', M, mat.N, N, 1.0, Array, 1, 1, Desc,
00074 mat.Array, 1, 1, mat.Desc, 0.0, newmat.Array, 1, 1, newmat.Desc );
00075 shallow_copy(newmat);
00076
00077 return *this;
00078 }
00079
00080
00081
00082
00083
00084
00085
00086 inline _dgematrix operator+(const dgematrix& matA, const _dgematrix& matB)
00087 {
00088 #ifdef CPPSL_DEBUG
00089 if(matA.N!=matB.N || matA.M!=matB.M){
00090 std::cerr << "[ERROR] operator+(const dgematrix&, const _dgematrix&)"
00091 << std::endl
00092 << "These two matrises can not make a summation." << std::endl
00093 << "Your input was (" << matA.M << "x" << matA.N << ") + ("
00094 << matB.M << "x" << matB.N << ")." << std::endl;
00095 exit(1);
00096 }
00097 #endif//CPPSL_DEBUG
00098
00099 for(long i=0; i<matA.Ml*matA.Nl; i++){ matB.Array[i] +=matA.Array[i]; }
00100
00101 return matB;
00102 }
00103
00104
00105
00106 inline _dgematrix operator-(const dgematrix& matA, const _dgematrix& matB)
00107 {
00108 #ifdef CPPSL_DEBUG
00109 if(matA.N!=matB.N || matA.M!=matB.M){
00110 std::cerr << "[ERROR] operator-(const dgematrix&, const _dgematrix&)"
00111 << std::endl
00112 << "These two matrises can not make a subtraction." << std::endl
00113 << "Your input was (" << matA.M << "x" << matA.N << ") - ("
00114 << matB.M << "x" << matB.N << ")." << std::endl;
00115 exit(1);
00116 }
00117 #endif//CPPSL_DEBUG
00118
00119 for(long i=0; i<matA.Ml*matA.Nl; i++){
00120 matB.Array[i] =matA.Array[i]-matB.Array[i];
00121 }
00122
00123 return matB;
00124 }
00125
00126
00127
00128 inline _dgematrix operator*(const dgematrix& matA, const _dgematrix& matB)
00129 {
00130 #ifdef CPPSL_DEBUG
00131 if(matA.N!=matB.M){
00132 std::cerr << "[ERROR] operator*(const dgematrix&, const _dgematrix&)"
00133 << std::endl
00134 << "These two matrises can not make a product." << std::endl
00135 << "Your input was (" << matA.M << "x" << matA.N << ") * ("
00136 << matB.M << "x" << matB.N << ")." << std::endl;
00137 exit(1);
00138 }
00139 #endif//CPPSL_DEBUG
00140
00141 _dgematrix newmat( matA.M, matB.N );
00142 pdgemm_( 'N', 'N', matA.M, matB.N, matA.N, 1.0,
00143 matA.Array, 1, 1, matA.Desc,
00144 matB.Array, 1, 1, matB.Desc, 0.0,
00145 newmat.Array, 1, 1, newmat.Desc );
00146
00147 matB.destroy();
00148 return newmat;
00149 }