| File: | generators/phokhara/phokhara/eemmg-lib/src/cache.cpp |
| Warning: | line 545, column 1 Use of memory after it is freed |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* | |||
| 2 | * cache.h - cache classes | |||
| 3 | * | |||
| 4 | * this file is part of PJFry library | |||
| 5 | * Copyright 2011 Valery Yundin | |||
| 6 | */ | |||
| 7 | ||||
| 8 | #include "cache.h" | |||
| 9 | #include "integral.h" | |||
| 10 | ||||
| 11 | /* ------------------------------------------------------------ | |||
| 12 | * ------------------------------------------------------------ | |||
| 13 | * ICache section | |||
| 14 | * ------------------------------------------------------------ | |||
| 15 | * ------------------------------------------------------------ | |||
| 16 | */ | |||
| 17 | ||||
| 18 | double ICache::mu2=1; | |||
| 19 | ||||
| 20 | double ICache::getMu2() | |||
| 21 | { | |||
| 22 | return mu2; | |||
| 23 | } | |||
| 24 | ||||
| 25 | double ICache::setMu2(const double newmu2) | |||
| 26 | { | |||
| 27 | if (newmu2 > 0 && newmu2 != mu2) { | |||
| 28 | MinorBase::Rescale(newmu2/mu2); | |||
| 29 | mu2=newmu2; | |||
| 30 | #ifdef USE_ONELOOP | |||
| 31 | double mu=sqrt(mu2); | |||
| 32 | F77_FUNC_(avh_olo_mu_set,AVH_OLO_MU_SET)avh_olo_mu_set_(&mu); | |||
| 33 | #endif | |||
| 34 | ICache::Clear(); | |||
| 35 | MCache::Clear(); | |||
| 36 | } | |||
| 37 | return mu2; | |||
| 38 | } | |||
| 39 | ||||
| 40 | void ICache::Clear() | |||
| 41 | { | |||
| 42 | ClearCC(); | |||
| 43 | ClearIC(); | |||
| 44 | } | |||
| 45 | ||||
| 46 | /* clear coefficient cache */ | |||
| 47 | void ICache::ClearCC() | |||
| 48 | { | |||
| 49 | ic5[0].reset(); | |||
| 50 | ic5[1].reset(); | |||
| 51 | ic4[0].reset(); | |||
| 52 | ic4[1].reset(); | |||
| 53 | ic3[0].reset(); | |||
| 54 | ic3[1].reset(); | |||
| 55 | ic2[0].reset(); | |||
| 56 | ic2[1].reset(); | |||
| 57 | } | |||
| 58 | ||||
| 59 | /* clear scalar integral cache */ | |||
| 60 | void ICache::ClearIC() | |||
| 61 | { | |||
| 62 | ics4.reset(); | |||
| 63 | ics3.reset(); | |||
| 64 | ics2.reset(); | |||
| 65 | ics1.reset(); | |||
| 66 | } | |||
| 67 | ||||
| 68 | /* clear minor cache */ | |||
| 69 | void MCache::Clear() | |||
| 70 | { | |||
| 71 | cm5.reset(); | |||
| 72 | cm4.reset(); | |||
| 73 | cm3.reset(); | |||
| 74 | cm2.reset(); | |||
| 75 | } | |||
| 76 | ||||
| 77 | // const double ICache::sNan=std::numeric_limits<double>::signaling_NaN(); | |||
| 78 | // const int64_t ICache::sNAN=0x7ffc0000BA13BA13LL; | |||
| 79 | // const double ICache::sNAN.d64=reinterpret_cast<const double&>(sNAN); // Bad because breaks strict aliasing | |||
| 80 | // const double ICache::sNAN.d64=((const ICache::ID64&)sNAN).dbl; | |||
| 81 | ||||
| 82 | const ICache::ID64 ICache::sNAN={ 0x7ffc0000BA13BA13LL }; | |||
| 83 | ||||
| 84 | ICache::Array5 ICache::ic5[3]; | |||
| 85 | ICache::Array4 ICache::ic4[3]; | |||
| 86 | ICache::Array3 ICache::ic3[3]; | |||
| 87 | ICache::Array2 ICache::ic2[3]; | |||
| 88 | ||||
| 89 | ICache::ArrayS4 ICache::ics4; | |||
| 90 | ICache::ArrayS3 ICache::ics3; | |||
| 91 | ICache::ArrayS2 ICache::ics2; | |||
| 92 | ICache::ArrayS1 ICache::ics1; | |||
| 93 | ||||
| 94 | /* =========================================================== | |||
| 95 | * | |||
| 96 | * PENTAGON: 5 point coefficients | |||
| 97 | * | |||
| 98 | * =========================================================== | |||
| 99 | */ | |||
| 100 | ||||
| 101 | /* -------------------------------------------------------- | |||
| 102 | Rank-5 PENTAGON | |||
| 103 | * -------------------------------------------------------- | |||
| 104 | */ | |||
| 105 | ncomplex ICache::getE(int ep, int i, int j, int k, int l, int m, const Kinem5 &kin) | |||
| 106 | { | |||
| 107 | #ifdef USE_CACHE_HIGH"1" | |||
| 108 | assert( (i==0 && j==0 && ( (k==0 && l==0 && m!=0) || (k!=0 && l!=0 && m!=0) ))(static_cast <bool> ((i==0 && j==0 && ( (k==0 && l==0 && m!=0) || (k!=0 && l !=0 && m!=0) )) || (i!=0 && j!=0 && k !=0 && l!=0 && m!=0)) ? void (0) : __assert_fail ("(i==0 && j==0 && ( (k==0 && l==0 && m!=0) || (k!=0 && l!=0 && m!=0) )) || (i!=0 && j!=0 && k!=0 && l!=0 && m!=0)" , "generators/phokhara/phokhara/eemmg-lib/src/cache.cpp", 109 , __extension__ __PRETTY_FUNCTION__)) | |||
| 109 | || (i!=0 && j!=0 && k!=0 && l!=0 && m!=0) )(static_cast <bool> ((i==0 && j==0 && ( (k==0 && l==0 && m!=0) || (k!=0 && l !=0 && m!=0) )) || (i!=0 && j!=0 && k !=0 && l!=0 && m!=0)) ? void (0) : __assert_fail ("(i==0 && j==0 && ( (k==0 && l==0 && m!=0) || (k!=0 && l!=0 && m!=0) )) || (i!=0 && j!=0 && k!=0 && l!=0 && m!=0)" , "generators/phokhara/phokhara/eemmg-lib/src/cache.cpp", 109 , __extension__ __PRETTY_FUNCTION__)); | |||
| 110 | int coefn=0; | |||
| 111 | if (i==0 && j==0) { | |||
| 112 | if (k==0 && l==0) | |||
| 113 | coefn=(m-1)+ee00001; | |||
| 114 | else | |||
| 115 | coefn=Minor5::is(k-1,l-1,m-1)+ee00111; | |||
| 116 | } | |||
| 117 | else { | |||
| 118 | coefn=Minor5::iss(i-1,j-1,k-1,l-1,m-1)+ee11111; | |||
| 119 | } | |||
| 120 | Save5 *s5=getS5(ep, kin, coefn); | |||
| 121 | ||||
| 122 | ncomplex ivalue=(*s5)[coefn]; | |||
| 123 | if (ivalue.real() == sNAN) { | |||
| 124 | ivalue=MCache::getMinor5(kin)->evalE(ep, i, j, k, l, m); | |||
| 125 | (*s5)[coefn]=ivalue; | |||
| 126 | } | |||
| 127 | #else | |||
| 128 | ncomplex ivalue=MCache::getMinor5(kin)->evalE(ep, i, j, k, l, m); | |||
| 129 | #endif /* USE_CACHE_HIGH */ | |||
| 130 | return ivalue; | |||
| 131 | } | |||
| 132 | ||||
| 133 | /* -------------------------------------------------------- | |||
| 134 | Rank-4 PENTAGON | |||
| 135 | * -------------------------------------------------------- | |||
| 136 | */ | |||
| 137 | ncomplex ICache::getE(int ep, int i, int j, int k, int l, const Kinem5 &kin) | |||
| 138 | { | |||
| 139 | #ifdef USE_CACHE_HIGH"1" | |||
| 140 | assert( (i==0 && j==0 && ( (k==0 && l==0) || (k!=0 && l!=0) )) || (i!=0 && j!=0 && k!=0 && l!=0) )(static_cast <bool> ((i==0 && j==0 && ( (k==0 && l==0) || (k!=0 && l!=0) )) || (i!=0 && j!=0 && k!=0 && l!=0)) ? void (0) : __assert_fail ("(i==0 && j==0 && ( (k==0 && l==0) || (k!=0 && l!=0) )) || (i!=0 && j!=0 && k!=0 && l!=0)" , "generators/phokhara/phokhara/eemmg-lib/src/cache.cpp", 140 , __extension__ __PRETTY_FUNCTION__)); | |||
| 141 | int coefn=0; | |||
| 142 | if (i==0 && j==0) { | |||
| 143 | if (k==0 && l==0) | |||
| 144 | coefn=ee0000; | |||
| 145 | else | |||
| 146 | coefn=Minor5::is(k-1,l-1)+ee0011; | |||
| 147 | } | |||
| 148 | else { | |||
| 149 | coefn=Minor5::is(i-1,j-1,k-1,l-1)+ee1111; | |||
| 150 | } | |||
| 151 | Save5 *s5=getS5(ep, kin, coefn); | |||
| 152 | ||||
| 153 | ncomplex ivalue=(*s5)[coefn]; | |||
| 154 | if (ivalue.real() == sNAN) { | |||
| 155 | ivalue=MCache::getMinor5(kin)->evalE(ep, i, j, k, l); | |||
| 156 | (*s5)[coefn]=ivalue; | |||
| 157 | } | |||
| 158 | #else | |||
| 159 | ncomplex ivalue=MCache::getMinor5(kin)->evalE(ep, i, j, k, l); | |||
| 160 | #endif /* USE_CACHE_HIGH */ | |||
| 161 | return ivalue; | |||
| 162 | } | |||
| 163 | ||||
| 164 | /* -------------------------------------------------------- | |||
| 165 | Rank-3 PENTAGON | |||
| 166 | * -------------------------------------------------------- | |||
| 167 | */ | |||
| 168 | ncomplex ICache::getE(int ep, int i, int j, int k, const Kinem5 &kin) | |||
| 169 | { | |||
| 170 | #ifdef USE_CACHE_HIGH"1" | |||
| 171 | assert( (i==0 && j==0 && k!=0) || (i!=0 && j!=0 && k!=0) )(static_cast <bool> ((i==0 && j==0 && k !=0) || (i!=0 && j!=0 && k!=0)) ? void (0) : __assert_fail ("(i==0 && j==0 && k!=0) || (i!=0 && j!=0 && k!=0)" , "generators/phokhara/phokhara/eemmg-lib/src/cache.cpp", 171 , __extension__ __PRETTY_FUNCTION__)); | |||
| 172 | int coefn=(i==0 && j==0) ? (k-1)+ee001 : Minor5::is(i-1,j-1,k-1)+ee111; | |||
| 173 | Save5 *s5=getS5(ep, kin, coefn); | |||
| 174 | ||||
| 175 | ncomplex ivalue=(*s5)[coefn]; | |||
| 176 | if (ivalue.real() == sNAN) { | |||
| 177 | ivalue=MCache::getMinor5(kin)->evalE(ep, i, j, k); | |||
| 178 | (*s5)[coefn]=ivalue; | |||
| 179 | } | |||
| 180 | #else | |||
| 181 | ncomplex ivalue=MCache::getMinor5(kin)->evalE(ep, i, j, k); | |||
| 182 | #endif /* USE_CACHE_HIGH */ | |||
| 183 | return ivalue; | |||
| 184 | } | |||
| 185 | ||||
| 186 | /* -------------------------------------------------------- | |||
| 187 | Rank-2 PENTAGON | |||
| 188 | * -------------------------------------------------------- | |||
| 189 | */ | |||
| 190 | ncomplex ICache::getE(int ep, int i, int j, const Kinem5 &kin) | |||
| 191 | { | |||
| 192 | #ifdef USE_CACHE_HIGH"1" | |||
| 193 | assert( (i==0 && j==0) || (i!=0 && j!=0) )(static_cast <bool> ((i==0 && j==0) || (i!=0 && j!=0)) ? void (0) : __assert_fail ("(i==0 && j==0) || (i!=0 && j!=0)" , "generators/phokhara/phokhara/eemmg-lib/src/cache.cpp", 193 , __extension__ __PRETTY_FUNCTION__)); | |||
| 194 | int coefn=(i==0 && j==0) ? ee00 : Minor5::is(i-1,j-1)+ee11; | |||
| 195 | Save5 *s5=getS5(ep, kin, coefn); | |||
| 196 | ||||
| 197 | ncomplex ivalue=(*s5)[coefn]; | |||
| 198 | if (ivalue.real() == sNAN) { | |||
| 199 | ivalue=MCache::getMinor5(kin)->evalE(ep, i, j); | |||
| 200 | (*s5)[coefn]=ivalue; | |||
| 201 | } | |||
| 202 | #else | |||
| 203 | ncomplex ivalue=MCache::getMinor5(kin)->evalE(ep, i, j); | |||
| 204 | #endif /* USE_CACHE_HIGH */ | |||
| 205 | return ivalue; | |||
| 206 | } | |||
| 207 | ||||
| 208 | /* -------------------------------------------------------- | |||
| 209 | Rank-1 PENTAGON | |||
| 210 | * -------------------------------------------------------- | |||
| 211 | */ | |||
| 212 | ncomplex ICache::getE(int ep, int i, const Kinem5 &kin) | |||
| 213 | { | |||
| 214 | #ifdef USE_CACHE_HIGH"1" | |||
| 215 | int coefn=(i-1)+ee1; | |||
| 216 | Save5 *s5=getS5(ep, kin, coefn); | |||
| 217 | ||||
| 218 | ncomplex ivalue=(*s5)[coefn]; | |||
| 219 | if (ivalue.real() == sNAN) { | |||
| 220 | ivalue=MCache::getMinor5(kin)->evalE(ep, i); | |||
| 221 | (*s5)[coefn]=ivalue; | |||
| 222 | } | |||
| 223 | #else | |||
| 224 | ncomplex ivalue=MCache::getMinor5(kin)->evalE(ep, i); | |||
| 225 | #endif /* USE_CACHE_HIGH */ | |||
| 226 | return ivalue; | |||
| 227 | } | |||
| 228 | ||||
| 229 | /* -------------------------------------------------------- | |||
| 230 | Rank-0 PENTAGON | |||
| 231 | * -------------------------------------------------------- | |||
| 232 | */ | |||
| 233 | ncomplex ICache::getE(int ep, const Kinem5 &kin) | |||
| 234 | { | |||
| 235 | #ifdef USE_CACHE_HIGH"1" | |||
| 236 | int coefn=ee0; | |||
| 237 | Save5 *s5=getS5(ep, kin, coefn); | |||
| 238 | ||||
| 239 | ncomplex ivalue=(*s5)[coefn]; | |||
| 240 | if (ivalue.real() == sNAN) { | |||
| 241 | ivalue=MCache::getMinor5(kin)->evalE(ep); | |||
| 242 | (*s5)[coefn]=ivalue; | |||
| 243 | } | |||
| 244 | #else | |||
| 245 | ncomplex ivalue=MCache::getMinor5(kin)->evalE(ep); | |||
| 246 | #endif /* USE_CACHE_HIGH */ | |||
| 247 | return ivalue; | |||
| 248 | } | |||
| 249 | ||||
| 250 | /* =========================================================== | |||
| 251 | * | |||
| 252 | * BOX: 4 point coefficients | |||
| 253 | * | |||
| 254 | * =========================================================== | |||
| 255 | */ | |||
| 256 | ||||
| 257 | /* -------------------------------------------------------- | |||
| 258 | Rank-4 BOX | |||
| 259 | * -------------------------------------------------------- | |||
| 260 | */ | |||
| 261 | ncomplex ICache::getD(int ep, int i, int j, int k, int l, const Kinem4 &kin) | |||
| 262 | { | |||
| 263 | #ifdef USE_CACHE_LOW | |||
| 264 | assert( (i==0 && j==0 && ( (k==0 && l==0) || (k!=0 && l!=0) )) || (i!=0 && j!=0 && k!=0 && l!=0) )(static_cast <bool> ((i==0 && j==0 && ( (k==0 && l==0) || (k!=0 && l!=0) )) || (i!=0 && j!=0 && k!=0 && l!=0)) ? void (0) : __assert_fail ("(i==0 && j==0 && ( (k==0 && l==0) || (k!=0 && l!=0) )) || (i!=0 && j!=0 && k!=0 && l!=0)" , "generators/phokhara/phokhara/eemmg-lib/src/cache.cpp", 264 , __extension__ __PRETTY_FUNCTION__)); | |||
| 265 | int coefn=0; | |||
| 266 | if (i==0 && j==0) { | |||
| 267 | if (k==0 && l==0) | |||
| 268 | coefn=dd0000; | |||
| 269 | else | |||
| 270 | coefn=Minor4::is(k-1,l-1)+dd0011; | |||
| 271 | } | |||
| 272 | else { | |||
| 273 | coefn=Minor5::is(i-1,j-1,k-1,l-1)+dd1111; | |||
| 274 | } | |||
| 275 | Save4 *s4=getS4(ep, kin, coefn); | |||
| 276 | ||||
| 277 | ncomplex ivalue=(*s4)[coefn]; | |||
| 278 | if (ivalue.real() == sNAN) { | |||
| 279 | ivalue=MCache::getMinor4(kin)->evalD(ep, i, j, k, l); | |||
| 280 | (*s4)[coefn]=ivalue; | |||
| 281 | } | |||
| 282 | #else | |||
| 283 | ncomplex ivalue=MCache::getMinor4(kin)->evalD(ep, i, j, k, l); | |||
| 284 | #endif /* USE_CACHE_LOW */ | |||
| 285 | return ivalue; | |||
| 286 | } | |||
| 287 | ||||
| 288 | /* -------------------------------------------------------- | |||
| 289 | Rank-3 BOX | |||
| 290 | * -------------------------------------------------------- | |||
| 291 | */ | |||
| 292 | ncomplex ICache::getD(int ep, int i, int j, int k, const Kinem4 &kin) | |||
| 293 | { | |||
| 294 | #ifdef USE_CACHE_LOW | |||
| 295 | assert( (i==0 && j==0 && k!=0) || (i!=0 && j!=0 && k!=0) )(static_cast <bool> ((i==0 && j==0 && k !=0) || (i!=0 && j!=0 && k!=0)) ? void (0) : __assert_fail ("(i==0 && j==0 && k!=0) || (i!=0 && j!=0 && k!=0)" , "generators/phokhara/phokhara/eemmg-lib/src/cache.cpp", 295 , __extension__ __PRETTY_FUNCTION__)); | |||
| 296 | int coefn=(i==0 && j==0) ? (k-1)+dd001 : Minor4::is(i-1,j-1,k-1)+dd111; | |||
| 297 | Save4 *s4=getS4(ep, kin, coefn); | |||
| 298 | ||||
| 299 | ncomplex ivalue=(*s4)[coefn]; | |||
| 300 | if (ivalue.real() == sNAN) { | |||
| 301 | ivalue=MCache::getMinor4(kin)->evalD(ep, i, j, k); | |||
| 302 | (*s4)[coefn]=ivalue; | |||
| 303 | } | |||
| 304 | #else | |||
| 305 | ncomplex ivalue=MCache::getMinor4(kin)->evalD(ep, i, j, k); | |||
| 306 | #endif /* USE_CACHE_LOW */ | |||
| 307 | return ivalue; | |||
| 308 | } | |||
| 309 | ||||
| 310 | /* -------------------------------------------------------- | |||
| 311 | Rank-2 BOX | |||
| 312 | * -------------------------------------------------------- | |||
| 313 | */ | |||
| 314 | ncomplex ICache::getD(int ep, int i, int j, const Kinem4 &kin) | |||
| 315 | { | |||
| 316 | #ifdef USE_CACHE_LOW | |||
| 317 | assert( (i==0 && j==0) || (i!=0 && j!=0) )(static_cast <bool> ((i==0 && j==0) || (i!=0 && j!=0)) ? void (0) : __assert_fail ("(i==0 && j==0) || (i!=0 && j!=0)" , "generators/phokhara/phokhara/eemmg-lib/src/cache.cpp", 317 , __extension__ __PRETTY_FUNCTION__)); | |||
| 318 | int coefn=(i==0 && j==0) ? dd00 : Minor4::is(i-1,j-1)+dd11; | |||
| 319 | Save4 *s4=getS4(ep, kin, coefn); | |||
| 320 | ||||
| 321 | ncomplex ivalue=(*s4)[coefn]; | |||
| 322 | if (ivalue.real() == sNAN) { | |||
| 323 | ivalue=MCache::getMinor4(kin)->evalD(ep, i, j); | |||
| 324 | (*s4)[coefn]=ivalue; | |||
| 325 | } | |||
| 326 | #else | |||
| 327 | ncomplex ivalue=MCache::getMinor4(kin)->evalD(ep, i, j); | |||
| 328 | #endif /* USE_CACHE_LOW */ | |||
| 329 | return ivalue; | |||
| 330 | } | |||
| 331 | ||||
| 332 | /* -------------------------------------------------------- | |||
| 333 | Rank-1 BOX | |||
| 334 | * -------------------------------------------------------- | |||
| 335 | */ | |||
| 336 | ncomplex ICache::getD(int ep, int i, const Kinem4 &kin) | |||
| 337 | { | |||
| 338 | #ifdef USE_CACHE_LOW | |||
| 339 | int coefn=(i-1)+dd1; | |||
| 340 | Save4 *s4=getS4(ep, kin, coefn); | |||
| 341 | ||||
| 342 | ncomplex ivalue=(*s4)[coefn]; | |||
| 343 | if (ivalue.real() == sNAN) { | |||
| 344 | ivalue=MCache::getMinor4(kin)->evalD(ep, i); | |||
| 345 | (*s4)[coefn]=ivalue; | |||
| 346 | } | |||
| 347 | #else | |||
| 348 | ncomplex ivalue=MCache::getMinor4(kin)->evalD(ep, i); | |||
| 349 | #endif /* USE_CACHE_LOW */ | |||
| 350 | return ivalue; | |||
| 351 | } | |||
| 352 | ||||
| 353 | /* =========================================================== | |||
| 354 | * | |||
| 355 | * TRIANGLE: 3 point coefficients | |||
| 356 | * | |||
| 357 | * =========================================================== | |||
| 358 | */ | |||
| 359 | ||||
| 360 | ||||
| 361 | /* -------------------------------------------------------- | |||
| 362 | Rank-3 TRIANGLE | |||
| 363 | * -------------------------------------------------------- | |||
| 364 | */ | |||
| 365 | ncomplex ICache::getC(int ep, int i, int j, int k, const Kinem3 &kin) | |||
| 366 | { | |||
| 367 | #ifdef USE_CACHE_LOW | |||
| 368 | assert( (i==0 && j==0 && k!=0) || (i!=0 && j!=0 && k!=0) )(static_cast <bool> ((i==0 && j==0 && k !=0) || (i!=0 && j!=0 && k!=0)) ? void (0) : __assert_fail ("(i==0 && j==0 && k!=0) || (i!=0 && j!=0 && k!=0)" , "generators/phokhara/phokhara/eemmg-lib/src/cache.cpp", 368 , __extension__ __PRETTY_FUNCTION__)); | |||
| 369 | int coefn=(i==0 && j==0) ? (k-1)+cc001 : Minor3::is(i-1,j-1,k-1)+cc111; | |||
| 370 | Save3 *s3=getS3(ep, kin, coefn); | |||
| 371 | ||||
| 372 | ncomplex ivalue=(*s3)[coefn]; | |||
| 373 | Minor3::Ptr pm3; | |||
| 374 | if (ivalue.real() == sNAN && (pm3=MCache::getMinor3(kin))!=0) { | |||
| 375 | ivalue=pm3->evalC(ep, i, j, k); | |||
| 376 | (*s3)[coefn]=ivalue; | |||
| 377 | } | |||
| 378 | #else | |||
| 379 | Minor3::Ptr pm3=MCache::getMinor3(kin); | |||
| 380 | ncomplex ivalue= ( pm3!=0 ? pm3->evalC(ep, i, j, k) : sNAN.d64 ); | |||
| 381 | #endif /* USE_CACHE_LOW */ | |||
| 382 | #ifndef NDEBUG | |||
| 383 | if (pm3==0) printf("C%d%d%d(%.18e,%.18e,%.18e,%e,%e,%e)=%f\n",i,j,k,kin.p1(),kin.p2(),kin.p3(),kin.m1(),kin.m2(),kin.m3(),ivalue.real()); | |||
| 384 | #endif | |||
| 385 | return ivalue; | |||
| 386 | } | |||
| 387 | ||||
| 388 | /* -------------------------------------------------------- | |||
| 389 | Rank-2 TRIANGLE | |||
| 390 | * -------------------------------------------------------- | |||
| 391 | */ | |||
| 392 | ncomplex ICache::getC(int ep, int i, int j, const Kinem3 &kin) | |||
| 393 | { | |||
| 394 | #ifdef USE_CACHE_LOW | |||
| 395 | assert( (i==0 && j==0) || (i!=0 && j!=0) )(static_cast <bool> ((i==0 && j==0) || (i!=0 && j!=0)) ? void (0) : __assert_fail ("(i==0 && j==0) || (i!=0 && j!=0)" , "generators/phokhara/phokhara/eemmg-lib/src/cache.cpp", 395 , __extension__ __PRETTY_FUNCTION__)); | |||
| 396 | int coefn=(i==0 && j==0) ? cc00 : Minor3::is(i-1,j-1)+cc11; | |||
| 397 | Save3 *s3=getS3(ep, kin, coefn); | |||
| 398 | ||||
| 399 | ncomplex ivalue=(*s3)[coefn]; | |||
| 400 | Minor3::Ptr pm3; | |||
| 401 | if (ivalue.real() == sNAN && (pm3=MCache::getMinor3(kin))!=0) { | |||
| 402 | ivalue=pm3->evalC(ep, i, j); | |||
| 403 | (*s3)[coefn]=ivalue; | |||
| 404 | } | |||
| 405 | #else | |||
| 406 | Minor3::Ptr pm3=MCache::getMinor3(kin); | |||
| 407 | ncomplex ivalue= ( pm3!=0 ? pm3->evalC(ep, i, j) : sNAN.d64 ); | |||
| 408 | #endif /* USE_CACHE_LOW */ | |||
| 409 | #ifndef NDEBUG | |||
| 410 | if (pm3==0) printf("C%d%d(%.18e,%.18e,%.18e,%e,%e,%e)=%f\n",i,j,kin.p1(),kin.p2(),kin.p3(),kin.m1(),kin.m2(),kin.m3(),ivalue.real()); | |||
| 411 | #endif | |||
| 412 | return ivalue; | |||
| 413 | } | |||
| 414 | ||||
| 415 | /* -------------------------------------------------------- | |||
| 416 | Rank-1 TRIANGLE | |||
| 417 | * -------------------------------------------------------- | |||
| 418 | */ | |||
| 419 | ncomplex ICache::getC(int ep, int i, const Kinem3 &kin) | |||
| 420 | { | |||
| 421 | #ifdef USE_CACHE_LOW | |||
| 422 | int coefn=(i-1)+cc1; | |||
| 423 | Save3 *s3=getS3(ep, kin, coefn); | |||
| 424 | ||||
| 425 | ncomplex ivalue=(*s3)[coefn]; | |||
| 426 | Minor3::Ptr pm3; | |||
| 427 | if (ivalue.real() == sNAN && (pm3=MCache::getMinor3(kin))!=0) { | |||
| 428 | ivalue=pm3->evalC(ep, i); | |||
| 429 | (*s3)[coefn]=ivalue; | |||
| 430 | } | |||
| 431 | #else | |||
| 432 | Minor3::Ptr pm3=MCache::getMinor3(kin); | |||
| 433 | ncomplex ivalue= ( pm3!=0 ? pm3->evalC(ep, i) : sNAN.d64 ); | |||
| 434 | #endif /* USE_CACHE_LOW */ | |||
| 435 | #ifndef NDEBUG | |||
| 436 | if (pm3==0) printf("C%d(%.18e,%.18e,%.18e,%e,%e,%e)=%f\n",i,kin.p1(),kin.p2(),kin.p3(),kin.m1(),kin.m2(),kin.m3(),ivalue.real()); | |||
| 437 | #endif | |||
| 438 | return ivalue; | |||
| 439 | } | |||
| 440 | ||||
| 441 | /* =========================================================== | |||
| 442 | * | |||
| 443 | * BUBBLE: 2 point coefficients | |||
| 444 | * | |||
| 445 | * =========================================================== | |||
| 446 | */ | |||
| 447 | ||||
| 448 | /* -------------------------------------------------------- | |||
| 449 | Rank-2 BUBBLE | |||
| 450 | * -------------------------------------------------------- | |||
| 451 | */ | |||
| 452 | ncomplex ICache::getB(int ep, int i, int j, const Kinem2 &kin) | |||
| 453 | { | |||
| 454 | #ifdef USE_CACHE_LOW | |||
| 455 | assert( (i==0 && j==0) || (i!=0 && j!=0) )(static_cast <bool> ((i==0 && j==0) || (i!=0 && j!=0)) ? void (0) : __assert_fail ("(i==0 && j==0) || (i!=0 && j!=0)" , "generators/phokhara/phokhara/eemmg-lib/src/cache.cpp", 455 , __extension__ __PRETTY_FUNCTION__)); | |||
| 456 | int coefn=(i==0 && j==0) ? bb00 : Minor2::is(i-1,j-1)+bb11; | |||
| 457 | Save2 *s2=getS2(ep, kin, coefn); | |||
| 458 | ||||
| 459 | ncomplex ivalue=(*s2)[coefn]; | |||
| 460 | Minor2::Ptr pm2; | |||
| 461 | if (ivalue.real() == sNAN && (pm2=MCache::getMinor2(kin))!=0) { | |||
| 462 | ivalue=pm2->evalB(ep, i, j); | |||
| 463 | (*s2)[coefn]=ivalue; | |||
| 464 | } | |||
| 465 | #else | |||
| 466 | Minor2::Ptr pm2=MCache::getMinor2(kin); | |||
| 467 | ncomplex ivalue= ( pm2!=0 ? pm2->evalB(ep, i, j) : sNAN.d64 ); | |||
| 468 | #endif /* USE_CACHE_LOW */ | |||
| 469 | #ifndef NDEBUG | |||
| 470 | if (pm2==0) printf("B%d%d(%.18e,%.18e,%.18e)=%f\n",i,j,kin.p1(),kin.m1(),kin.m2(),ivalue.real()); | |||
| 471 | #endif | |||
| 472 | return ivalue; | |||
| 473 | } | |||
| 474 | ||||
| 475 | /* -------------------------------------------------------- | |||
| 476 | Rank-1 BUBBLE | |||
| 477 | * -------------------------------------------------------- | |||
| 478 | */ | |||
| 479 | ncomplex ICache::getB(int ep, int i, const Kinem2 &kin) | |||
| 480 | { | |||
| 481 | #ifdef USE_CACHE_LOW | |||
| 482 | int coefn=(i-1)+bb1; | |||
| 483 | Save2 *s2=getS2(ep, kin, coefn); | |||
| 484 | ||||
| 485 | ncomplex ivalue=(*s2)[coefn]; | |||
| 486 | Minor2::Ptr pm2; | |||
| 487 | if (ivalue.real() == sNAN && (pm2=MCache::getMinor2(kin))!=0) { | |||
| 488 | ivalue=pm2->evalB(ep, i); | |||
| 489 | (*s2)[coefn]=ivalue; | |||
| 490 | } | |||
| 491 | #else | |||
| 492 | Minor2::Ptr pm2=MCache::getMinor2(kin); | |||
| 493 | ncomplex ivalue= ( pm2!=0 ? pm2->evalB(ep, i) : sNAN.d64 ); | |||
| 494 | #endif /* USE_CACHE_LOW */ | |||
| 495 | #ifndef NDEBUG | |||
| 496 | if (pm2==0) printf("B%d(%.18e,%.18e,%.18e)=%f\n",i,kin.p1(),kin.m1(),kin.m2(),ivalue.real()); | |||
| 497 | #endif | |||
| 498 | return ivalue; | |||
| 499 | } | |||
| 500 | ||||
| 501 | /* =========================================================== | |||
| 502 | * | |||
| 503 | * Get saved value | |||
| 504 | * | |||
| 505 | * =========================================================== | |||
| 506 | */ | |||
| 507 | ||||
| 508 | // ICache::Save5* ICache::getS5(int ep, const Kinem5 &kin, int coefn) | |||
| 509 | // { | |||
| 510 | // Save5 *s5=0; | |||
| 511 | // for (Array5::iterator it5=ic5[ep].begin(); it5 != ic5[ep].end(); ++it5) { | |||
| 512 | // if (it5->key == kin) { | |||
| 513 | // s5=it5->val.get(); | |||
| 514 | // break; | |||
| 515 | // } | |||
| 516 | // } | |||
| 517 | // if (s5 == 0) { | |||
| 518 | // Save5::Ptr sptr(new Save5(ncomplex(sNAN.d64, 0))); | |||
| 519 | // s5=sptr.get(); | |||
| 520 | // ic5[ep].insert(Entry5(kin, sptr)); | |||
| 521 | // } | |||
| 522 | // return s5; | |||
| 523 | // } | |||
| 524 | ||||
| 525 | #define getSave(n) \ | |||
| 526 | ICache::Save##n * ICache::getS##n(int ep, const Kinem##n &kin, int coefn) \ | |||
| 527 | { \ | |||
| 528 | Save##n *s##n=0; \ | |||
| 529 | for (Array##n::iterator it##n=ic##n[ep].begin(); it##n != ic##n[ep].end(); ++it##n) { \ | |||
| 530 | if (it##n->key == kin) { \ | |||
| 531 | s##n=it##n->val.get(); \ | |||
| 532 | break; \ | |||
| 533 | } \ | |||
| 534 | } \ | |||
| 535 | if (s##n == 0) { \ | |||
| 536 | Save##n::Ptr sptr(new Save##n(ncomplex(sNAN.d64, 0))); \ | |||
| 537 | s##n=sptr.get(); \ | |||
| 538 | ic##n[ep].insert(Entry##n(kin, sptr)); \ | |||
| 539 | } \ | |||
| 540 | return s##n; \ | |||
| 541 | } \ | |||
| 542 | ||||
| 543 | getSave(5) | |||
| 544 | getSave(4) | |||
| 545 | getSave(3) | |||
| ||||
| ||||
| 546 | getSave(2) | |||
| 547 | ||||
| 548 | #undef getSave | |||
| 549 | ||||
| 550 | // ncomplex ICache::getI2(int ep, const Kinem2 &k) | |||
| 551 | // { | |||
| 552 | // ncomplex ivalue(sNAN.d64, 0); | |||
| 553 | // for (ArrayS2::iterator it2=ics2[ep].begin(); it2 != ics2[ep].end(); ++it2) { | |||
| 554 | // if (it2->key == k) { | |||
| 555 | // ivalue=it2->val; | |||
| 556 | // break; | |||
| 557 | // } | |||
| 558 | // } | |||
| 559 | // if (ivalue.real() == sNAN) { | |||
| 560 | // ivalue=qlI2(k.p1(), | |||
| 561 | // k.m1(), k.m2(), | |||
| 562 | // -ep); | |||
| 563 | // ics2[ep].insert(EntryS2(k,ivalue)); | |||
| 564 | // } | |||
| 565 | // return ivalue; | |||
| 566 | // } | |||
| 567 | ||||
| 568 | #define getIN(n) \ | |||
| 569 | ncomplex ICache::getI##n(int ep, const Kinem##n &k) \ | |||
| 570 | { \ | |||
| 571 | Ival ivalue; \ | |||
| 572 | bool found=false; \ | |||
| 573 | for (ArrayS##n::iterator it##n=ics##n.begin(); it##n != ics##n.end(); ++it##n) { \ | |||
| 574 | if (it##n->key == k) { \ | |||
| 575 | ivalue=it##n->val; \ | |||
| 576 | found=true; \ | |||
| 577 | break; \ | |||
| 578 | } \ | |||
| 579 | } \ | |||
| 580 | if ( ! found ) { \ | |||
| 581 | ivalue=qlI##n(k); \ | |||
| 582 | ics##n.insert(EntryS##n(k,ivalue)); \ | |||
| 583 | } \ | |||
| 584 | return ivalue.val[ep]; \ | |||
| 585 | } | |||
| 586 | ||||
| 587 | getIN(1) | |||
| 588 | getIN(2) | |||
| 589 | getIN(3) | |||
| 590 | getIN(4) | |||
| 591 | ||||
| 592 | #undef getIN | |||
| 593 | ||||
| 594 | /* ------------------------------------------------------------ | |||
| 595 | * ------------------------------------------------------------ | |||
| 596 | * MCache section | |||
| 597 | * ------------------------------------------------------------ | |||
| 598 | * ------------------------------------------------------------ | |||
| 599 | */ | |||
| 600 | ||||
| 601 | MCache::Array5 MCache::cm5; | |||
| 602 | MCache::Array4 MCache::cm4; | |||
| 603 | MCache::Array3 MCache::cm3; | |||
| 604 | MCache::Array2 MCache::cm2; | |||
| 605 | ||||
| 606 | // Minor5::Ptr MCache::getMinor5(const Kinem5 &k) | |||
| 607 | // { | |||
| 608 | // Minor5::Ptr minor; | |||
| 609 | // for (Array5::iterator it5=cm5.begin(); it5!=cm5.end(); ++it5) { | |||
| 610 | // if (it5->key == k) { | |||
| 611 | // minor=it5->val; | |||
| 612 | // break; | |||
| 613 | // } | |||
| 614 | // } | |||
| 615 | // if (minor==0) { | |||
| 616 | // minor=Minor5::create(k); | |||
| 617 | // cm5.insert(Entry5(k,minor)); | |||
| 618 | // } | |||
| 619 | // return minor; | |||
| 620 | // } | |||
| 621 | ||||
| 622 | #define getMinorN(n) \ | |||
| 623 | Minor##n::Ptr MCache::getMinor##n(const Kinem##n &k) \ | |||
| 624 | { \ | |||
| 625 | Minor##n::Ptr minor; \ | |||
| 626 | for (Array##n::iterator it##n=cm##n.begin(); it##n!=cm##n.end(); ++it##n) { \ | |||
| 627 | if (it##n->key == k) { \ | |||
| 628 | minor=it##n->val; \ | |||
| 629 | break; \ | |||
| 630 | } \ | |||
| 631 | } \ | |||
| 632 | /* if (minor==0) { \ | |||
| 633 | minor=Minor##n::create(k); \ | |||
| 634 | cm##n.insert(Entry##n(k,minor)); \ | |||
| 635 | } \ | |||
| 636 | assert(minor!=0); */ \ | |||
| 637 | return minor; \ | |||
| 638 | } | |||
| 639 | ||||
| 640 | getMinorN(3) | |||
| 641 | getMinorN(2) | |||
| 642 | ||||
| 643 | #undef getMinorN | |||
| 644 | ||||
| 645 | Minor5::Ptr MCache::getMinor5(const Kinem5 &k) | |||
| 646 | { | |||
| 647 | Minor5::Ptr minor; | |||
| 648 | for (Array5::iterator it5=cm5.begin(); it5!=cm5.end(); ++it5) { | |||
| 649 | if (it5->key == k) { | |||
| 650 | minor=it5->val; | |||
| 651 | break; | |||
| 652 | } | |||
| 653 | } | |||
| 654 | if (minor==0) { | |||
| 655 | minor=Minor5::create(k); | |||
| 656 | cm5.insert(Entry5(k,minor)); | |||
| 657 | } | |||
| 658 | assert(minor!=0)(static_cast <bool> (minor!=0) ? void (0) : __assert_fail ("minor!=0", "generators/phokhara/phokhara/eemmg-lib/src/cache.cpp" , 658, __extension__ __PRETTY_FUNCTION__)); | |||
| 659 | return minor; | |||
| 660 | } | |||
| 661 | ||||
| 662 | Minor4::Ptr MCache::getMinor4(const Kinem4 &k) | |||
| 663 | { | |||
| 664 | Minor4::Ptr minor; | |||
| 665 | for (Array4::iterator it4=cm4.begin(); it4!=cm4.end(); ++it4) { | |||
| 666 | if (it4->key == k) { | |||
| 667 | minor=it4->val; | |||
| 668 | break; | |||
| 669 | } | |||
| 670 | } | |||
| 671 | if (minor==0) { | |||
| 672 | Minor5::create(k); | |||
| 673 | minor=cm4.begin()->val; | |||
| 674 | cm4.insert(Entry4(k,minor)); | |||
| 675 | } | |||
| 676 | assert(minor!=0)(static_cast <bool> (minor!=0) ? void (0) : __assert_fail ("minor!=0", "generators/phokhara/phokhara/eemmg-lib/src/cache.cpp" , 676, __extension__ __PRETTY_FUNCTION__)); | |||
| 677 | return minor; | |||
| 678 | } | |||
| 679 | ||||
| 680 | ||||
| 681 | #ifdef USE_SMART_INSERT"1" | |||
| 682 | ||||
| 683 | void MCache::smartinsertMinor3(const Kinem3 &k, Minor3::Ptr &m) | |||
| 684 | { | |||
| 685 | for (Array3::iterator it3=cm3.begin(); it3!=cm3.end(); ++it3) { | |||
| 686 | if (it3->key == k) { | |||
| 687 | cm3.remove(it3); | |||
| 688 | break; | |||
| 689 | } | |||
| 690 | } | |||
| 691 | insertMinor3(k,m); | |||
| 692 | } | |||
| 693 | ||||
| 694 | void MCache::smartinsertMinor2(const Kinem2 &k, Minor2::Ptr &m) | |||
| 695 | { | |||
| 696 | for (Array2::iterator it2=cm2.begin(); it2!=cm2.end(); ++it2) { | |||
| 697 | if (it2->key == k) { | |||
| 698 | cm2.remove(it2); | |||
| 699 | break; | |||
| 700 | } | |||
| 701 | } | |||
| 702 | insertMinor2(k,m); | |||
| 703 | } | |||
| 704 | ||||
| 705 | #endif | |||
| 706 | ||||
| 707 | // ------------------------------------------------------- |
| 1 | /* |
| 2 | * cache.h - cache classes header |
| 3 | * |
| 4 | * this file is part of PJFry library |
| 5 | * Copyright 2011 Valery Yundin |
| 6 | */ |
| 7 | |
| 8 | #ifndef QUL_CACHE_H |
| 9 | #define QUL_CACHE_H |
| 10 | |
| 11 | #include "common.h" |
| 12 | #include "kinem.h" |
| 13 | #include "minor.h" |
| 14 | #ifdef USE_GOLEM_MODE |
| 15 | #include "golem.h" |
| 16 | #endif |
| 17 | |
| 18 | template <typename TK, typename TV> |
| 19 | class MEntry { |
| 20 | public: |
| 21 | MEntry() : key(), val() {} |
| 22 | MEntry(const TK& k, TV& v) : key(k), val(v) {} |
| 23 | |
| 24 | MEntry& operator= (const MEntry& entry) |
| 25 | { |
| 26 | key = entry.key; |
| 27 | val = entry.val; |
| 28 | return *this; |
| 29 | } |
| 30 | |
| 31 | TK key; |
| 32 | mutable TV val; // TODO: remove auto_ptr in the future |
| 33 | |
| 34 | MEntry(const MEntry& entry); |
| 35 | }; |
| 36 | |
| 37 | class Cache { |
| 38 | protected: |
| 39 | static const int size6 = 2; |
| 40 | |
| 41 | static const int size5 = size6 * 6; |
| 42 | static const int size4 = size6 * 15; |
| 43 | static const int size3 = size6 * 20; |
| 44 | static const int size2 = size6 * 15; |
| 45 | static const int size1 = size6 * 6; |
| 46 | |
| 47 | }; |
| 48 | |
| 49 | class ICache : public Cache { |
| 50 | #ifdef USE_GOLEM_MODE |
| 51 | friend class Golem; |
| 52 | #endif |
| 53 | public: |
| 54 | typedef struct { ncomplex val[3]; } Ival; |
| 55 | |
| 56 | enum Ecoefs {ee0 = 1, ee1, ee2, ee3, ee4, |
| 57 | ee00, ee11, ee12, ee13, ee14, ee22, ee23, ee24, ee33, ee34, ee44, |
| 58 | ee001, ee002, ee003, ee004, |
| 59 | ee111, ee112, ee113, ee114, ee122, ee123, ee124, ee133, ee134, ee144, |
| 60 | ee222, ee223, ee224, ee233, ee234, ee244, ee333, ee334, ee344, ee444, |
| 61 | ee0000, ee0011, ee0012, ee0013, ee0014, ee0022, ee0023, ee0024, ee0033, ee0034, ee0044, |
| 62 | ee1111, ee1112, ee1113, ee1114, ee1122, ee1123, ee1124, ee1133, ee1134, ee1144, |
| 63 | ee1222, ee1223, ee1224, ee1233, ee1234, ee1244, ee1333, ee1334, ee1344, ee1444, |
| 64 | ee2222, ee2223, ee2224, ee2233, ee2234, ee2244, ee2333, ee2334, ee2344, ee2444, |
| 65 | ee3333, ee3334, ee3344, ee3444, ee4444, |
| 66 | ee00001, ee00002, ee00003, ee00004, ee00111, ee00112, ee00113, ee00114, |
| 67 | ee00122, ee00123, ee00124, ee00133, ee00134, ee00144, ee00222, ee00223, ee00224, |
| 68 | ee00233, ee00234, ee00244, ee00333, ee00334, ee00344, ee00444, |
| 69 | ee11111, ee11112, ee11113, ee11114, ee11122, ee11123, ee11124, ee11133, ee11134, ee11144, |
| 70 | ee11222, ee11223, ee11224, ee11233, ee11234, ee11244, ee11333, ee11334, ee11344, ee11444, |
| 71 | ee12222, ee12223, ee12224, ee12233, ee12234, ee12244, ee12333, ee12334, ee12344, ee12444, |
| 72 | ee13333, ee13334, ee13344, ee13444, ee14444, |
| 73 | ee22222, ee22223, ee22224, ee22233, ee22234, ee22244, ee22333, ee22334, ee22344, ee22444, |
| 74 | ee23333, ee23334, ee23344, ee23444, ee24444, ee33333, ee33334, ee33344, ee33444, ee34444, |
| 75 | ee44444, eeLAST |
| 76 | }; |
| 77 | |
| 78 | enum Dcoefs {dd0 = 1, dd1, dd2, dd3, |
| 79 | dd00, dd11, dd12, dd13, dd22, dd23, dd33, |
| 80 | dd001, dd002, dd003, |
| 81 | dd111, dd112, dd113, dd122, dd123, dd133, dd222, dd223, dd233, dd333, |
| 82 | dd0000, dd0011, dd0012, dd0013, dd0022, dd0023, dd0033, |
| 83 | dd1111, dd1112, dd1113, dd1122, dd1123, dd1133, |
| 84 | dd1222, dd1223, dd1233, dd1333, |
| 85 | dd2222, dd2223, dd2233, dd2333, |
| 86 | dd3333, ddLAST |
| 87 | }; |
| 88 | |
| 89 | enum Ccoefs {cc0 = 1, cc1, cc2, |
| 90 | cc00, cc11, cc12, cc22, |
| 91 | cc001, cc002, |
| 92 | cc111, cc112, cc122, cc222, ccLAST |
| 93 | }; |
| 94 | |
| 95 | enum Bcoefs {bb0 = 1, bb1, |
| 96 | bb00, bb11, |
| 97 | bb001, |
| 98 | bb111, bbLAST |
| 99 | }; |
| 100 | |
| 101 | // Scalars |
| 102 | static ncomplex getI4(int ep, const Kinem4& k); |
| 103 | static ncomplex getI3(int ep, const Kinem3& k); |
| 104 | static ncomplex getI2(int ep, const Kinem2& k); |
| 105 | static ncomplex getI1(int ep, const Kinem1& k); |
| 106 | |
| 107 | // Tensor PENTAGON |
| 108 | static ncomplex getE(int ep, const Kinem5& kin); |
| 109 | static ncomplex getE(int ep, int i, const Kinem5& kin); |
| 110 | static ncomplex getE(int ep, int i, int j, const Kinem5& kin); |
| 111 | static ncomplex getE(int ep, int i, int j, int k, const Kinem5& kin); |
| 112 | static ncomplex getE(int ep, int i, int j, int k, int l, const Kinem5& kin); |
| 113 | static ncomplex getE(int ep, int i, int j, int k, int l, int m, const Kinem5& kin); |
| 114 | |
| 115 | // Tensor BOX |
| 116 | static ncomplex getD(int ep, const Kinem4& kin) { return getI4(ep, kin); } |
| 117 | static ncomplex getD(int ep, int i, const Kinem4& kin); |
| 118 | static ncomplex getD(int ep, int i, int j, const Kinem4& kin); |
| 119 | static ncomplex getD(int ep, int i, int j, int k, const Kinem4& kin); |
| 120 | static ncomplex getD(int ep, int i, int j, int k, int l, const Kinem4& kin); |
| 121 | |
| 122 | // Tensor TRIANGLE |
| 123 | static ncomplex getC(int ep, const Kinem3& kin) { return getI3(ep, kin); } |
| 124 | static ncomplex getC(int ep, int i, const Kinem3& kin); |
| 125 | static ncomplex getC(int ep, int i, int j, const Kinem3& kin); |
| 126 | static ncomplex getC(int ep, int i, int j, int k, const Kinem3& kin); |
| 127 | |
| 128 | // Tensor BUBBLE |
| 129 | static ncomplex getB(int ep, const Kinem2& kin) { return getI2(ep, kin); } |
| 130 | static ncomplex getB(int ep, int i, const Kinem2& kin); |
| 131 | static ncomplex getB(int ep, int i, int j, const Kinem2& kin); |
| 132 | |
| 133 | // Tadpole |
| 134 | static ncomplex getA(int ep, const Kinem1& kin) { return getI1(ep, kin); } |
| 135 | |
| 136 | static void Clear(); |
| 137 | static void ClearCC(); |
| 138 | static void ClearIC(); |
| 139 | |
| 140 | static double getMu2(); |
| 141 | static double setMu2(const double newmu2); |
| 142 | |
| 143 | private: |
| 144 | static double mu2; |
| 145 | typedef union { int64_t i64; double d64; } ID64; |
| 146 | typedef union { double d64; int64_t i64; } DI64; |
| 147 | static const ID64 sNAN; |
| 148 | friend bool operator==(const double& x, const ICache::ID64& y); |
| 149 | |
| 150 | // ------------------------------ |
| 151 | // Tensor integral coefficients |
| 152 | // ------------------------------ |
| 153 | // TODO: rethink and optimize layout later |
| 154 | typedef CArray< ncomplex, eeLAST > Save5; |
| 155 | typedef MEntry< Kinem5, Save5::Ptr > Entry5; |
| 156 | typedef DArray< Entry5, size5 > Array5; |
| 157 | static Array5 ic5[3]; |
| 158 | static Save5* getS5(int ep, const Kinem5& kin, int coefn); |
| 159 | |
| 160 | typedef CArray< ncomplex, ddLAST > Save4; |
| 161 | typedef MEntry< Kinem4, Save4::Ptr > Entry4; |
| 162 | typedef DArray< Entry4, size4 > Array4; |
| 163 | static Array4 ic4[3]; |
| 164 | static Save4* getS4(int ep, const Kinem4& kin, int coefn); |
| 165 | |
| 166 | typedef CArray< ncomplex, ccLAST > Save3; |
| 167 | typedef MEntry< Kinem3, Save3::Ptr > Entry3; |
| 168 | typedef DArray< Entry3, size3 > Array3; |
| 169 | static Array3 ic3[3]; |
| 170 | static Save3* getS3(int ep, const Kinem3& kin, int coefn); |
| 171 | |
| 172 | typedef CArray< ncomplex, bbLAST > Save2; |
| 173 | typedef MEntry< Kinem2, Save2::Ptr > Entry2; |
| 174 | typedef DArray< Entry2, size2 > Array2; |
| 175 | static Array2 ic2[3]; |
| 176 | static Save2* getS2(int ep, const Kinem2& kin, int coefn); |
| 177 | |
| 178 | // ------------------------------ |
| 179 | // Scalar integrals |
| 180 | // ------------------------------ |
| 181 | typedef MEntry< Kinem4, Ival > EntryS4; |
| 182 | typedef DArray< EntryS4, size4 > ArrayS4; |
| 183 | static ArrayS4 ics4; |
| 184 | |
| 185 | typedef MEntry< Kinem3, Ival > EntryS3; |
| 186 | typedef DArray< EntryS3, size3 > ArrayS3; |
| 187 | static ArrayS3 ics3; |
| 188 | |
| 189 | typedef MEntry< Kinem2, Ival > EntryS2; |
| 190 | typedef DArray< EntryS2, size2 > ArrayS2; |
| 191 | static ArrayS2 ics2; |
| 192 | |
| 193 | typedef MEntry< Kinem1, Ival > EntryS1; |
| 194 | typedef DArray< EntryS1, size1 > ArrayS1; |
| 195 | static ArrayS1 ics1; |
| 196 | }; |
| 197 | |
| 198 | inline |
| 199 | bool operator==(const double& x, const ICache::ID64& y) |
| 200 | { |
| 201 | const ICache::DI64 ix = {x}; |
| 202 | return ix.i64 == y.i64; |
| 203 | } |
| 204 | |
| 205 | |
| 206 | class MCache : public Cache { |
| 207 | #ifdef USE_GOLEM_MODE |
| 208 | friend class Golem; |
| 209 | #endif |
| 210 | public: |
| 211 | // TODO: may be return by reference here? |
| 212 | static Minor5::Ptr getMinor5(const Kinem5& k); |
| 213 | static Minor4::Ptr getMinor4(const Kinem4& k); |
| 214 | static Minor3::Ptr getMinor3(const Kinem3& k); |
| 215 | static Minor2::Ptr getMinor2(const Kinem2& k); |
| 216 | |
| 217 | static void insertMinor5(const Kinem5& k, Minor5::Ptr& m); |
| 218 | static void insertMinor4(const Kinem4& k, Minor4::Ptr& m); |
| 219 | static void insertMinor3(const Kinem3& k, Minor3::Ptr& m); |
| 220 | static void insertMinor2(const Kinem2& k, Minor2::Ptr& m); |
| 221 | |
| 222 | #ifdef USE_SMART_INSERT"1" |
| 223 | # define INSERTMINOR3smartinsertMinor3 smartinsertMinor3 |
| 224 | # define INSERTMINOR2smartinsertMinor2 smartinsertMinor2 |
| 225 | static void smartinsertMinor3(const Kinem3& k, Minor3::Ptr& m); |
| 226 | static void smartinsertMinor2(const Kinem2& k, Minor2::Ptr& m); |
| 227 | #else |
| 228 | # define INSERTMINOR3smartinsertMinor3 insertMinor3 |
| 229 | # define INSERTMINOR2smartinsertMinor2 insertMinor2 |
| 230 | #endif |
| 231 | |
| 232 | static void Clear(); |
| 233 | |
| 234 | private: |
| 235 | |
| 236 | typedef MEntry< Kinem5, Minor5::Ptr > Entry5; |
| 237 | typedef DArray< Entry5, size5 > Array5; |
| 238 | static Array5 cm5; |
| 239 | |
| 240 | typedef MEntry< Kinem4, Minor4::Ptr > Entry4; |
| 241 | typedef DArray< Entry4, size4 > Array4; |
| 242 | static Array4 cm4; |
| 243 | |
| 244 | typedef MEntry< Kinem3, Minor3::Ptr > Entry3; |
| 245 | typedef DArray< Entry3, size3 > Array3; |
| 246 | static Array3 cm3; |
| 247 | |
| 248 | typedef MEntry< Kinem2, Minor2::Ptr > Entry2; |
| 249 | typedef DArray< Entry2, size2 > Array2; |
| 250 | static Array2 cm2; |
| 251 | |
| 252 | }; |
| 253 | |
| 254 | /* ============================================= |
| 255 | * |
| 256 | * inline functions |
| 257 | * |
| 258 | * ============================================= |
| 259 | */ |
| 260 | |
| 261 | #define insertMinorN(n) \ |
| 262 | inline \ |
| 263 | void MCache::insertMinor##n(const Kinem##n &k, Minor##n::Ptr &m) \ |
| 264 | { \ |
| 265 | cm##n.insert(Entry##n(k,m)); \ |
| 266 | } |
| 267 | |
| 268 | insertMinorN(5) |
| 269 | insertMinorN(4) |
| 270 | insertMinorN(3) |
| 271 | insertMinorN(2) |
| 272 | |
| 273 | #undef insertMinorN |
| 274 | |
| 275 | #endif /* _QUL_CACHE_H */ |
| 1 | // auto_ptr implementation -*- C++ -*- |
| 2 | |
| 3 | // Copyright (C) 2007-2025 Free Software Foundation, Inc. |
| 4 | // |
| 5 | // This file is part of the GNU ISO C++ Library. This library is free |
| 6 | // software; you can redistribute it and/or modify it under the |
| 7 | // terms of the GNU General Public License as published by the |
| 8 | // Free Software Foundation; either version 3, or (at your option) |
| 9 | // any later version. |
| 10 | |
| 11 | // This library is distributed in the hope that it will be useful, |
| 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | // GNU General Public License for more details. |
| 15 | |
| 16 | // Under Section 7 of GPL version 3, you are granted additional |
| 17 | // permissions described in the GCC Runtime Library Exception, version |
| 18 | // 3.1, as published by the Free Software Foundation. |
| 19 | |
| 20 | // You should have received a copy of the GNU General Public License and |
| 21 | // a copy of the GCC Runtime Library Exception along with this program; |
| 22 | // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
| 23 | // <http://www.gnu.org/licenses/>. |
| 24 | |
| 25 | /** @file backward/auto_ptr.h |
| 26 | * This is an internal header file, included by other library headers. |
| 27 | * Do not attempt to use it directly. @headername{memory} |
| 28 | */ |
| 29 | |
| 30 | #ifndef _BACKWARD_AUTO_PTR_H1 |
| 31 | #define _BACKWARD_AUTO_PTR_H1 1 |
| 32 | |
| 33 | #include <bits/c++config.h> |
| 34 | #include <debug/debug.h> |
| 35 | |
| 36 | namespace std _GLIBCXX_VISIBILITY(default)__attribute__ ((__visibility__ ("default"))) |
| 37 | { |
| 38 | _GLIBCXX_BEGIN_NAMESPACE_VERSION |
| 39 | |
| 40 | /** |
| 41 | * A wrapper class to provide auto_ptr with reference semantics. |
| 42 | * For example, an auto_ptr can be assigned (or constructed from) |
| 43 | * the result of a function which returns an auto_ptr by value. |
| 44 | * |
| 45 | * All the auto_ptr_ref stuff should happen behind the scenes. |
| 46 | */ |
| 47 | template<typename _Tp1> |
| 48 | struct auto_ptr_ref |
| 49 | { |
| 50 | _Tp1* _M_ptr; |
| 51 | |
| 52 | explicit |
| 53 | auto_ptr_ref(_Tp1* __p): _M_ptr(__p) { } |
| 54 | } _GLIBCXX11_DEPRECATED__attribute__ ((__deprecated__)); |
| 55 | |
| 56 | #pragma GCC diagnostic push |
| 57 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" |
| 58 | |
| 59 | /** |
| 60 | * @brief A simple smart pointer providing strict ownership semantics. |
| 61 | * |
| 62 | * The Standard says: |
| 63 | * <pre> |
| 64 | * An @c auto_ptr owns the object it holds a pointer to. Copying |
| 65 | * an @c auto_ptr copies the pointer and transfers ownership to the |
| 66 | * destination. If more than one @c auto_ptr owns the same object |
| 67 | * at the same time the behavior of the program is undefined. |
| 68 | * |
| 69 | * The uses of @c auto_ptr include providing temporary |
| 70 | * exception-safety for dynamically allocated memory, passing |
| 71 | * ownership of dynamically allocated memory to a function, and |
| 72 | * returning dynamically allocated memory from a function. @c |
| 73 | * auto_ptr does not meet the CopyConstructible and Assignable |
| 74 | * requirements for Standard Library <a |
| 75 | * href="tables.html#65">container</a> elements and thus |
| 76 | * instantiating a Standard Library container with an @c auto_ptr |
| 77 | * results in undefined behavior. |
| 78 | * </pre> |
| 79 | * Quoted from [20.4.5]/3. |
| 80 | * |
| 81 | * Good examples of what can and cannot be done with auto_ptr can |
| 82 | * be found in the libstdc++ testsuite. |
| 83 | * |
| 84 | * _GLIBCXX_RESOLVE_LIB_DEFECTS |
| 85 | * 127. auto_ptr<> conversion issues |
| 86 | * These resolutions have all been incorporated. |
| 87 | * |
| 88 | * @headerfile memory |
| 89 | * @deprecated Deprecated in C++11, no longer in the standard since C++17. |
| 90 | * Use `unique_ptr` instead. |
| 91 | */ |
| 92 | template<typename _Tp> |
| 93 | class auto_ptr |
| 94 | { |
| 95 | private: |
| 96 | _Tp* _M_ptr; |
| 97 | |
| 98 | public: |
| 99 | /// The pointed-to type. |
| 100 | typedef _Tp element_type; |
| 101 | |
| 102 | /** |
| 103 | * @brief An %auto_ptr is usually constructed from a raw pointer. |
| 104 | * @param __p A pointer (defaults to NULL). |
| 105 | * |
| 106 | * This object now @e owns the object pointed to by @a __p. |
| 107 | */ |
| 108 | explicit |
| 109 | auto_ptr(element_type* __p = 0) throw() : _M_ptr(__p) { } |
| 110 | |
| 111 | /** |
| 112 | * @brief An %auto_ptr can be constructed from another %auto_ptr. |
| 113 | * @param __a Another %auto_ptr of the same type. |
| 114 | * |
| 115 | * This object now @e owns the object previously owned by @a __a, |
| 116 | * which has given up ownership. |
| 117 | */ |
| 118 | auto_ptr(auto_ptr& __a) throw() : _M_ptr(__a.release()) { } |
| 119 | |
| 120 | /** |
| 121 | * @brief An %auto_ptr can be constructed from another %auto_ptr. |
| 122 | * @param __a Another %auto_ptr of a different but related type. |
| 123 | * |
| 124 | * A pointer-to-Tp1 must be convertible to a |
| 125 | * pointer-to-Tp/element_type. |
| 126 | * |
| 127 | * This object now @e owns the object previously owned by @a __a, |
| 128 | * which has given up ownership. |
| 129 | */ |
| 130 | template<typename _Tp1> |
| 131 | auto_ptr(auto_ptr<_Tp1>& __a) throw() : _M_ptr(__a.release()) { } |
| 132 | |
| 133 | /** |
| 134 | * @brief %auto_ptr assignment operator. |
| 135 | * @param __a Another %auto_ptr of the same type. |
| 136 | * |
| 137 | * This object now @e owns the object previously owned by @a __a, |
| 138 | * which has given up ownership. The object that this one @e |
| 139 | * used to own and track has been deleted. |
| 140 | */ |
| 141 | auto_ptr& |
| 142 | operator=(auto_ptr& __a) throw() |
| 143 | { |
| 144 | reset(__a.release()); |
| 145 | return *this; |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * @brief %auto_ptr assignment operator. |
| 150 | * @param __a Another %auto_ptr of a different but related type. |
| 151 | * |
| 152 | * A pointer-to-Tp1 must be convertible to a pointer-to-Tp/element_type. |
| 153 | * |
| 154 | * This object now @e owns the object previously owned by @a __a, |
| 155 | * which has given up ownership. The object that this one @e |
| 156 | * used to own and track has been deleted. |
| 157 | */ |
| 158 | template<typename _Tp1> |
| 159 | auto_ptr& |
| 160 | operator=(auto_ptr<_Tp1>& __a) throw() |
| 161 | { |
| 162 | reset(__a.release()); |
| 163 | return *this; |
| 164 | } |
| 165 | |
| 166 | /** |
| 167 | * When the %auto_ptr goes out of scope, the object it owns is |
| 168 | * deleted. If it no longer owns anything (i.e., @c get() is |
| 169 | * @c NULL), then this has no effect. |
| 170 | * |
| 171 | * The C++ standard says there is supposed to be an empty throw |
| 172 | * specification here, but omitting it is standard conforming. Its |
| 173 | * presence can be detected only if _Tp::~_Tp() throws, but this is |
| 174 | * prohibited. [17.4.3.6]/2 |
| 175 | */ |
| 176 | ~auto_ptr() { delete _M_ptr; } |
| 177 | |
| 178 | /** |
| 179 | * @brief Smart pointer dereferencing. |
| 180 | * |
| 181 | * If this %auto_ptr no longer owns anything, then this |
| 182 | * operation will crash. (For a smart pointer, <em>no longer owns |
| 183 | * anything</em> is the same as being a null pointer, and you know |
| 184 | * what happens when you dereference one of those...) |
| 185 | */ |
| 186 | element_type& |
| 187 | operator*() const throw() |
| 188 | { |
| 189 | __glibcxx_assert(_M_ptr != 0)do { if (std::__is_constant_evaluated() && !bool(_M_ptr != 0)) std::__glibcxx_assert_fail(); } while (false); |
| 190 | return *_M_ptr; |
| 191 | } |
| 192 | |
| 193 | /** |
| 194 | * @brief Smart pointer dereferencing. |
| 195 | * |
| 196 | * This returns the pointer itself, which the language then will |
| 197 | * automatically cause to be dereferenced. |
| 198 | */ |
| 199 | element_type* |
| 200 | operator->() const throw() |
| 201 | { |
| 202 | __glibcxx_assert(_M_ptr != 0)do { if (std::__is_constant_evaluated() && !bool(_M_ptr != 0)) std::__glibcxx_assert_fail(); } while (false); |
| 203 | return _M_ptr; |
| 204 | } |
| 205 | |
| 206 | /** |
| 207 | * @brief Bypassing the smart pointer. |
| 208 | * @return The raw pointer being managed. |
| 209 | * |
| 210 | * You can get a copy of the pointer that this object owns, for |
| 211 | * situations such as passing to a function which only accepts |
| 212 | * a raw pointer. |
| 213 | * |
| 214 | * @note This %auto_ptr still owns the memory. |
| 215 | */ |
| 216 | element_type* |
| 217 | get() const throw() { return _M_ptr; } |
| 218 | |
| 219 | /** |
| 220 | * @brief Bypassing the smart pointer. |
| 221 | * @return The raw pointer being managed. |
| 222 | * |
| 223 | * You can get a copy of the pointer that this object owns, for |
| 224 | * situations such as passing to a function which only accepts |
| 225 | * a raw pointer. |
| 226 | * |
| 227 | * @note This %auto_ptr no longer owns the memory. When this object |
| 228 | * goes out of scope, nothing will happen. |
| 229 | */ |
| 230 | element_type* |
| 231 | release() throw() |
| 232 | { |
| 233 | element_type* __tmp = _M_ptr; |
| 234 | _M_ptr = 0; |
| 235 | return __tmp; |
| 236 | } |
| 237 | |
| 238 | /** |
| 239 | * @brief Forcibly deletes the managed object. |
| 240 | * @param __p A pointer (defaults to NULL). |
| 241 | * |
| 242 | * This object now @e owns the object pointed to by @a __p. The |
| 243 | * previous object has been deleted. |
| 244 | */ |
| 245 | void |
| 246 | reset(element_type* __p = 0) throw() |
| 247 | { |
| 248 | if (__p != _M_ptr) |
| 249 | { |
| 250 | delete _M_ptr; |
| 251 | _M_ptr = __p; |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | /** |
| 256 | * @brief Automatic conversions |
| 257 | * |
| 258 | * These operations are supposed to convert an %auto_ptr into and from |
| 259 | * an auto_ptr_ref automatically as needed. This would allow |
| 260 | * constructs such as |
| 261 | * @code |
| 262 | * auto_ptr<Derived> func_returning_auto_ptr(.....); |
| 263 | * ... |
| 264 | * auto_ptr<Base> ptr = func_returning_auto_ptr(.....); |
| 265 | * @endcode |
| 266 | * |
| 267 | * But it doesn't work, and won't be fixed. For further details see |
| 268 | * https://cplusplus.github.io/LWG/lwg-closed.html#463 |
| 269 | */ |
| 270 | auto_ptr(auto_ptr_ref<element_type> __ref) throw() |
| 271 | : _M_ptr(__ref._M_ptr) { } |
| 272 | |
| 273 | auto_ptr& |
| 274 | operator=(auto_ptr_ref<element_type> __ref) throw() |
| 275 | { |
| 276 | if (__ref._M_ptr != this->get()) |
| 277 | { |
| 278 | delete _M_ptr; |
| 279 | _M_ptr = __ref._M_ptr; |
| 280 | } |
| 281 | return *this; |
| 282 | } |
| 283 | |
| 284 | template<typename _Tp1> |
| 285 | operator auto_ptr_ref<_Tp1>() throw() |
| 286 | { return auto_ptr_ref<_Tp1>(this->release()); } |
| 287 | |
| 288 | template<typename _Tp1> |
| 289 | operator auto_ptr<_Tp1>() throw() |
| 290 | { return auto_ptr<_Tp1>(this->release()); } |
| 291 | } _GLIBCXX11_DEPRECATED_SUGGEST("std::unique_ptr")__attribute__ ((__deprecated__ ("use '" "std::unique_ptr" "' instead" ))); |
| 292 | |
| 293 | // _GLIBCXX_RESOLVE_LIB_DEFECTS |
| 294 | // 541. shared_ptr template assignment and void |
| 295 | template<> |
| 296 | class auto_ptr<void> |
| 297 | { |
| 298 | public: |
| 299 | typedef void element_type; |
| 300 | } _GLIBCXX11_DEPRECATED__attribute__ ((__deprecated__)); |
| 301 | |
| 302 | #if __cplusplus202002L >= 201103L |
| 303 | #if _GLIBCXX_HOSTED1 |
| 304 | template<_Lock_policy _Lp> |
| 305 | template<typename _Tp> |
| 306 | inline |
| 307 | __shared_count<_Lp>::__shared_count(std::auto_ptr<_Tp>&& __r) |
| 308 | : _M_pi(new _Sp_counted_ptr<_Tp*, _Lp>(__r.get())) |
| 309 | { __r.release(); } |
| 310 | |
| 311 | template<typename _Tp, _Lock_policy _Lp> |
| 312 | template<typename _Tp1, typename> |
| 313 | inline |
| 314 | __shared_ptr<_Tp, _Lp>::__shared_ptr(std::auto_ptr<_Tp1>&& __r) |
| 315 | : _M_ptr(__r.get()), _M_refcount() |
| 316 | { |
| 317 | __glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>) |
| 318 | static_assert( sizeof(_Tp1) > 0, "incomplete type" ); |
| 319 | _Tp1* __tmp = __r.get(); |
| 320 | _M_refcount = __shared_count<_Lp>(std::move(__r)); |
| 321 | _M_enable_shared_from_this_with(__tmp); |
| 322 | } |
| 323 | |
| 324 | template<typename _Tp> |
| 325 | template<typename _Tp1, typename> |
| 326 | inline |
| 327 | shared_ptr<_Tp>::shared_ptr(std::auto_ptr<_Tp1>&& __r) |
| 328 | : __shared_ptr<_Tp>(std::move(__r)) { } |
| 329 | #endif // HOSTED |
| 330 | |
| 331 | template<typename _Tp, typename _Dp> |
| 332 | template<typename _Up, typename> |
| 333 | inline |
| 334 | unique_ptr<_Tp, _Dp>::unique_ptr(auto_ptr<_Up>&& __u) noexcept |
| 335 | : _M_t(__u.release(), deleter_type()) { } |
| 336 | #endif // C++11 |
| 337 | |
| 338 | #pragma GCC diagnostic pop |
| 339 | |
| 340 | _GLIBCXX_END_NAMESPACE_VERSION |
| 341 | } // namespace |
| 342 | |
| 343 | #endif /* _BACKWARD_AUTO_PTR_H */ |