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