00001 00002 class LocalOSSContribution { 00003 private: 00004 double * const gmat; 00005 double * const gmata; 00006 double * const gmatb; 00007 00008 double * const pmat; 00009 double * const pmata; 00010 double * const pmatb; 00011 public: 00012 LocalOSSContribution(double *g, double *p, double *ga, double *pa, 00013 double *gb, double *pb) : 00014 gmat(g), gmata(ga), gmatb(gb), pmat(p), pmata(pa), pmatb(pb) {} 00015 ~LocalOSSContribution() {} 00016 00017 void set_bound(double,double) {} 00018 00019 inline void cont1(int ij, int kl, double val) { 00020 gmat[ij] += val*pmat[kl]; 00021 gmat[kl] += val*pmat[ij]; 00022 } 00023 00024 inline void cont2(int ij, int kl, double val) { 00025 val *= 0.25; 00026 gmat[ij] -= val*pmat[kl]; 00027 gmat[kl] -= val*pmat[ij]; 00028 00029 gmata[ij] += val*pmata[kl]; 00030 gmata[kl] += val*pmata[ij]; 00031 00032 gmatb[ij] += val*pmatb[kl]; 00033 gmatb[kl] += val*pmatb[ij]; 00034 00035 val *= -3.0; 00036 gmatb[ij] += val*pmata[kl]; 00037 gmatb[kl] += val*pmata[ij]; 00038 00039 gmata[ij] += val*pmatb[kl]; 00040 gmata[kl] += val*pmatb[ij]; 00041 } 00042 00043 inline void cont3(int ij, int kl, double val) { 00044 val *= 0.5; 00045 gmat[ij] -= val*pmat[kl]; 00046 gmat[kl] -= val*pmat[ij]; 00047 00048 gmata[ij] += val*pmata[kl]; 00049 gmata[kl] += val*pmata[ij]; 00050 00051 gmatb[ij] += val*pmatb[kl]; 00052 gmatb[kl] += val*pmatb[ij]; 00053 00054 val *= -3.0; 00055 gmata[ij] += val*pmatb[kl]; 00056 gmata[kl] += val*pmatb[ij]; 00057 00058 gmatb[ij] += val*pmata[kl]; 00059 gmatb[kl] += val*pmata[ij]; 00060 } 00061 00062 inline void cont4(int ij, int kl, double val) { 00063 gmat[ij] += 0.75*val*pmat[kl]; 00064 gmat[kl] += 0.75*val*pmat[ij]; 00065 00066 gmata[ij] += 0.25*val*pmata[kl]; 00067 gmata[kl] += 0.25*val*pmata[ij]; 00068 00069 gmatb[ij] += 0.25*val*pmatb[kl]; 00070 gmatb[kl] += 0.25*val*pmatb[ij]; 00071 00072 gmata[ij] -= 0.75*val*pmatb[kl]; 00073 gmata[kl] -= 0.75*val*pmatb[ij]; 00074 00075 gmatb[ij] -= 0.75*val*pmata[kl]; 00076 gmatb[kl] -= 0.75*val*pmata[ij]; 00077 } 00078 00079 inline void cont5(int ij, int kl, double val) { 00080 val *= 0.5; 00081 gmat[ij] += val*pmat[kl]; 00082 gmat[kl] += val*pmat[ij]; 00083 00084 gmata[ij] += val*pmata[kl]; 00085 gmata[kl] += val*pmata[ij]; 00086 00087 gmatb[ij] += val*pmatb[kl]; 00088 gmatb[kl] += val*pmatb[ij]; 00089 00090 val *= -3.0; 00091 gmata[ij] += val*pmatb[kl]; 00092 gmata[kl] += val*pmatb[ij]; 00093 00094 gmatb[ij] += val*pmata[kl]; 00095 gmatb[kl] += val*pmata[ij]; 00096 } 00097 }; 00098 00099 class LocalOSSEnergyContribution { 00100 private: 00101 double * const pmat; 00102 double * const pmata; 00103 double * const pmatb; 00104 00105 public: 00106 double ec; 00107 double ex; 00108 00109 void set_bound(double,double) {}; 00110 00111 LocalOSSEnergyContribution(double *p, double *pa, double *pb) : 00112 pmat(p), pmata(pa), pmatb(pb) { 00113 ec=ex=0; 00114 } 00115 ~LocalOSSEnergyContribution() {} 00116 00117 inline void cont1(int ij, int kl, double val) { 00118 ec += val*pmat[ij]*pmat[kl]; 00119 } 00120 00121 inline void cont2(int ij, int kl, double val) { 00122 ex -= 0.25*val*(pmat[ij]*pmat[kl] + pmata[ij]*pmata[kl] + 00123 pmatb[ij]*pmatb[kl]); 00124 ex += 0.75*val*(pmata[ij]*pmatb[kl] + pmatb[ij]*pmata[kl]); 00125 } 00126 00127 inline void cont3(int ij, int kl, double val) { 00128 ex -= 0.5*val*(pmat[ij]*pmat[kl] + pmata[ij]*pmata[kl] + 00129 pmatb[ij]*pmatb[kl]); 00130 ex += 1.5*val*(pmata[ij]*pmatb[kl] + pmatb[ij]*pmata[kl]); 00131 } 00132 00133 inline void cont4(int ij, int kl, double val) { 00134 ec += val*pmat[ij]*pmat[kl]; 00135 ex -= 0.25*val*(pmat[ij]*pmat[kl] + pmata[ij]*pmata[kl] + 00136 pmatb[ij]*pmatb[kl]); 00137 ex += 0.75*val*(pmata[ij]*pmatb[kl] + pmatb[ij]*pmata[kl]); 00138 } 00139 00140 inline void cont5(int ij, int kl, double val) { 00141 ec += val*pmat[ij]*pmat[kl]; 00142 ex -= 0.5*val*(pmat[ij]*pmat[kl] + pmata[ij]*pmata[kl] + 00143 pmatb[ij]*pmatb[kl]); 00144 ex += 1.5*val*(pmata[ij]*pmatb[kl] + pmatb[ij]*pmata[kl]); 00145 } 00146 }; 00147 00148 class LocalOSSGradContribution { 00149 private: 00150 double * const pmat; 00151 double * const pmata; 00152 double * const pmatb; 00153 00154 public: 00155 LocalOSSGradContribution(double *p, double *pa, double *pb) : 00156 pmat(p), pmata(pa), pmatb(pb) {} 00157 ~LocalOSSGradContribution() {} 00158 00159 inline double cont1(int ij, int kl) { 00160 return pmat[ij]*pmat[kl] + 00161 0.5*(pmata[ij]*pmat[kl] + pmat[ij]*pmata[kl] + 00162 pmatb[ij]*pmat[kl] + pmat[ij]*pmatb[kl]) + 00163 0.25*(pmata[ij]*pmata[kl] + pmatb[ij]*pmatb[kl] + 00164 pmata[ij]*pmatb[kl] + pmatb[ij]*pmata[kl]); 00165 } 00166 00167 inline double cont2(int ij, int kl) { 00168 return pmat[ij]*pmat[kl] + 00169 0.5*(pmata[ij]*pmat[kl] + pmat[ij]*pmata[kl] + 00170 pmatb[ij]*pmat[kl] + pmat[ij]*pmatb[kl] + 00171 pmata[ij]*pmata[kl] + pmatb[ij]*pmatb[kl] - 00172 pmata[ij]*pmatb[kl] - pmatb[ij]*pmata[kl]); 00173 } 00174 };