| [0b990d] | 1 | //
 | 
|---|
 | 2 | // tbint.cc
 | 
|---|
 | 3 | //
 | 
|---|
 | 4 | // Copyright (C) 1996 Limit Point Systems, Inc.
 | 
|---|
 | 5 | //
 | 
|---|
 | 6 | // Author: Edward Seidl <seidl@janed.com>
 | 
|---|
 | 7 | // Maintainer: LPS
 | 
|---|
 | 8 | //
 | 
|---|
 | 9 | // This file is part of the SC Toolkit.
 | 
|---|
 | 10 | //
 | 
|---|
 | 11 | // The SC Toolkit is free software; you can redistribute it and/or modify
 | 
|---|
 | 12 | // it under the terms of the GNU Library General Public License as published by
 | 
|---|
 | 13 | // the Free Software Foundation; either version 2, or (at your option)
 | 
|---|
 | 14 | // any later version.
 | 
|---|
 | 15 | //
 | 
|---|
 | 16 | // The SC Toolkit is distributed in the hope that it will be useful,
 | 
|---|
 | 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|---|
 | 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|---|
 | 19 | // GNU Library General Public License for more details.
 | 
|---|
 | 20 | //
 | 
|---|
 | 21 | // You should have received a copy of the GNU Library General Public License
 | 
|---|
 | 22 | // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
 | 
|---|
 | 23 | // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 | 
|---|
 | 24 | //
 | 
|---|
 | 25 | // The U.S. Government is granted a limited license as per AL 91-7.
 | 
|---|
 | 26 | //
 | 
|---|
 | 27 | 
 | 
|---|
 | 28 | #ifdef __GNUC__
 | 
|---|
 | 29 | #pragma implementation
 | 
|---|
 | 30 | #endif
 | 
|---|
 | 31 | 
 | 
|---|
 | 32 | #include <math/scmat/offset.h>
 | 
|---|
 | 33 | 
 | 
|---|
 | 34 | #include <chemistry/qc/basis/tbint.h>
 | 
|---|
 | 35 | #include <chemistry/qc/basis/integral.h>
 | 
|---|
 | 36 | #include <chemistry/qc/basis/basis.h>
 | 
|---|
 | 37 | 
 | 
|---|
 | 38 | using namespace sc;
 | 
|---|
 | 39 | 
 | 
|---|
 | 40 | ///////////////////////////////////////////////////////////////////////
 | 
|---|
 | 41 | 
 | 
|---|
 | 42 | TwoBodyInt::TwoBodyInt(Integral *integral,
 | 
|---|
 | 43 |                        const Ref<GaussianBasisSet>&b1,
 | 
|---|
 | 44 |                        const Ref<GaussianBasisSet>&b2,
 | 
|---|
 | 45 |                        const Ref<GaussianBasisSet>&b3,
 | 
|---|
 | 46 |                        const Ref<GaussianBasisSet>&b4) :
 | 
|---|
 | 47 |   integral_(integral),
 | 
|---|
 | 48 |   bs1_(b1), bs2_(b2), bs3_(b3), bs4_(b4), redundant_(1)
 | 
|---|
 | 49 | {
 | 
|---|
 | 50 |   integral_->reference();
 | 
|---|
 | 51 |   buffer_ = 0;
 | 
|---|
 | 52 | }
 | 
|---|
 | 53 | 
 | 
|---|
 | 54 | TwoBodyInt::~TwoBodyInt()
 | 
|---|
 | 55 | {
 | 
|---|
 | 56 |   integral_->dereference();
 | 
|---|
 | 57 |   if (integral_->nreference() == 0) delete integral_;
 | 
|---|
 | 58 | }
 | 
|---|
 | 59 | 
 | 
|---|
 | 60 | int
 | 
|---|
 | 61 | TwoBodyInt::nbasis() const
 | 
|---|
 | 62 | {
 | 
|---|
 | 63 |   return bs1_->nbasis();
 | 
|---|
 | 64 | }
 | 
|---|
 | 65 | 
 | 
|---|
 | 66 | int
 | 
|---|
 | 67 | TwoBodyInt::nbasis1() const
 | 
|---|
 | 68 | {
 | 
|---|
 | 69 |   return bs1_->nbasis();
 | 
|---|
 | 70 | }
 | 
|---|
 | 71 | 
 | 
|---|
 | 72 | int
 | 
|---|
 | 73 | TwoBodyInt::nbasis2() const
 | 
|---|
 | 74 | {
 | 
|---|
 | 75 |   return bs2_->nbasis();
 | 
|---|
 | 76 | }
 | 
|---|
 | 77 | 
 | 
|---|
 | 78 | int
 | 
|---|
 | 79 | TwoBodyInt::nbasis3() const
 | 
|---|
 | 80 | {
 | 
|---|
 | 81 |   return bs3_->nbasis();
 | 
|---|
 | 82 | }
 | 
|---|
 | 83 | 
 | 
|---|
 | 84 | int
 | 
|---|
 | 85 | TwoBodyInt::nbasis4() const
 | 
|---|
 | 86 | {
 | 
|---|
 | 87 |   return bs4_->nbasis();
 | 
|---|
 | 88 | }
 | 
|---|
 | 89 | 
 | 
|---|
 | 90 | int
 | 
|---|
 | 91 | TwoBodyInt::nshell() const
 | 
|---|
 | 92 | {
 | 
|---|
 | 93 |   return bs1_->nshell();
 | 
|---|
 | 94 | }
 | 
|---|
 | 95 | 
 | 
|---|
 | 96 | int
 | 
|---|
 | 97 | TwoBodyInt::nshell1() const
 | 
|---|
 | 98 | {
 | 
|---|
 | 99 |   return bs1_->nshell();
 | 
|---|
 | 100 | }
 | 
|---|
 | 101 | 
 | 
|---|
 | 102 | int
 | 
|---|
 | 103 | TwoBodyInt::nshell2() const
 | 
|---|
 | 104 | {
 | 
|---|
 | 105 |   return bs2_->nshell();
 | 
|---|
 | 106 | }
 | 
|---|
 | 107 | 
 | 
|---|
 | 108 | int
 | 
|---|
 | 109 | TwoBodyInt::nshell3() const
 | 
|---|
 | 110 | {
 | 
|---|
 | 111 |   return bs3_->nshell();
 | 
|---|
 | 112 | }
 | 
|---|
 | 113 | 
 | 
|---|
 | 114 | int
 | 
|---|
 | 115 | TwoBodyInt::nshell4() const
 | 
|---|
 | 116 | {
 | 
|---|
 | 117 |   return bs4_->nshell();
 | 
|---|
 | 118 | }
 | 
|---|
 | 119 | 
 | 
|---|
 | 120 | Ref<GaussianBasisSet>
 | 
|---|
 | 121 | TwoBodyInt::basis()
 | 
|---|
 | 122 | {
 | 
|---|
 | 123 |   return bs1_;
 | 
|---|
 | 124 | }
 | 
|---|
 | 125 | 
 | 
|---|
 | 126 | Ref<GaussianBasisSet>
 | 
|---|
 | 127 | TwoBodyInt::basis1()
 | 
|---|
 | 128 | {
 | 
|---|
 | 129 |   return bs1_;
 | 
|---|
 | 130 | }
 | 
|---|
 | 131 | 
 | 
|---|
 | 132 | Ref<GaussianBasisSet>
 | 
|---|
 | 133 | TwoBodyInt::basis2()
 | 
|---|
 | 134 | {
 | 
|---|
 | 135 |   return bs2_;
 | 
|---|
 | 136 | }
 | 
|---|
 | 137 | 
 | 
|---|
 | 138 | Ref<GaussianBasisSet>
 | 
|---|
 | 139 | TwoBodyInt::basis3()
 | 
|---|
 | 140 | {
 | 
|---|
 | 141 |   return bs3_;
 | 
|---|
 | 142 | }
 | 
|---|
 | 143 | 
 | 
|---|
 | 144 | Ref<GaussianBasisSet>
 | 
|---|
 | 145 | TwoBodyInt::basis4()
 | 
|---|
 | 146 | {
 | 
|---|
 | 147 |   return bs4_;
 | 
|---|
 | 148 | }
 | 
|---|
 | 149 | 
 | 
|---|
 | 150 | const double *
 | 
|---|
 | 151 | TwoBodyInt::buffer(tbint_type i) const
 | 
|---|
 | 152 | {
 | 
|---|
 | 153 |   if (i==eri) return buffer_;
 | 
|---|
 | 154 |   return 0;
 | 
|---|
 | 155 | }
 | 
|---|
 | 156 | 
 | 
|---|
 | 157 | void
 | 
|---|
 | 158 | TwoBodyInt::set_integral_storage(size_t storage)
 | 
|---|
 | 159 | {
 | 
|---|
 | 160 | }
 | 
|---|
 | 161 | 
 | 
|---|
 | 162 | ///////////////////////////////////////////////////////////////////////
 | 
|---|
 | 163 | 
 | 
|---|
 | 164 | TwoBodyThreeCenterInt::TwoBodyThreeCenterInt(Integral *integral,
 | 
|---|
 | 165 |                        const Ref<GaussianBasisSet>&b1,
 | 
|---|
 | 166 |                        const Ref<GaussianBasisSet>&b2,
 | 
|---|
 | 167 |                        const Ref<GaussianBasisSet>&b3) :
 | 
|---|
 | 168 |   integral_(integral),
 | 
|---|
 | 169 |   bs1_(b1), bs2_(b2), bs3_(b3), redundant_(1)
 | 
|---|
 | 170 | {
 | 
|---|
 | 171 |   integral_->reference();
 | 
|---|
 | 172 |   buffer_ = 0;
 | 
|---|
 | 173 | }
 | 
|---|
 | 174 | 
 | 
|---|
 | 175 | TwoBodyThreeCenterInt::~TwoBodyThreeCenterInt()
 | 
|---|
 | 176 | {
 | 
|---|
 | 177 |   integral_->dereference();
 | 
|---|
 | 178 |   if (integral_->nreference() == 0) delete integral_;
 | 
|---|
 | 179 | }
 | 
|---|
 | 180 | 
 | 
|---|
 | 181 | int
 | 
|---|
 | 182 | TwoBodyThreeCenterInt::nbasis() const
 | 
|---|
 | 183 | {
 | 
|---|
 | 184 |   return bs1_->nbasis();
 | 
|---|
 | 185 | }
 | 
|---|
 | 186 | 
 | 
|---|
 | 187 | int
 | 
|---|
 | 188 | TwoBodyThreeCenterInt::nbasis1() const
 | 
|---|
 | 189 | {
 | 
|---|
 | 190 |   return bs1_->nbasis();
 | 
|---|
 | 191 | }
 | 
|---|
 | 192 | 
 | 
|---|
 | 193 | int
 | 
|---|
 | 194 | TwoBodyThreeCenterInt::nbasis2() const
 | 
|---|
 | 195 | {
 | 
|---|
 | 196 |   return bs2_->nbasis();
 | 
|---|
 | 197 | }
 | 
|---|
 | 198 | 
 | 
|---|
 | 199 | int
 | 
|---|
 | 200 | TwoBodyThreeCenterInt::nbasis3() const
 | 
|---|
 | 201 | {
 | 
|---|
 | 202 |   return bs3_->nbasis();
 | 
|---|
 | 203 | }
 | 
|---|
 | 204 | 
 | 
|---|
 | 205 | int
 | 
|---|
 | 206 | TwoBodyThreeCenterInt::nshell() const
 | 
|---|
 | 207 | {
 | 
|---|
 | 208 |   return bs1_->nshell();
 | 
|---|
 | 209 | }
 | 
|---|
 | 210 | 
 | 
|---|
 | 211 | int
 | 
|---|
 | 212 | TwoBodyThreeCenterInt::nshell1() const
 | 
|---|
 | 213 | {
 | 
|---|
 | 214 |   return bs1_->nshell();
 | 
|---|
 | 215 | }
 | 
|---|
 | 216 | 
 | 
|---|
 | 217 | int
 | 
|---|
 | 218 | TwoBodyThreeCenterInt::nshell2() const
 | 
|---|
 | 219 | {
 | 
|---|
 | 220 |   return bs2_->nshell();
 | 
|---|
 | 221 | }
 | 
|---|
 | 222 | 
 | 
|---|
 | 223 | int
 | 
|---|
 | 224 | TwoBodyThreeCenterInt::nshell3() const
 | 
|---|
 | 225 | {
 | 
|---|
 | 226 |   return bs3_->nshell();
 | 
|---|
 | 227 | }
 | 
|---|
 | 228 | 
 | 
|---|
 | 229 | Ref<GaussianBasisSet>
 | 
|---|
 | 230 | TwoBodyThreeCenterInt::basis()
 | 
|---|
 | 231 | {
 | 
|---|
 | 232 |   return bs1_;
 | 
|---|
 | 233 | }
 | 
|---|
 | 234 | 
 | 
|---|
 | 235 | Ref<GaussianBasisSet>
 | 
|---|
 | 236 | TwoBodyThreeCenterInt::basis1()
 | 
|---|
 | 237 | {
 | 
|---|
 | 238 |   return bs1_;
 | 
|---|
 | 239 | }
 | 
|---|
 | 240 | 
 | 
|---|
 | 241 | Ref<GaussianBasisSet>
 | 
|---|
 | 242 | TwoBodyThreeCenterInt::basis2()
 | 
|---|
 | 243 | {
 | 
|---|
 | 244 |   return bs2_;
 | 
|---|
 | 245 | }
 | 
|---|
 | 246 | 
 | 
|---|
 | 247 | Ref<GaussianBasisSet>
 | 
|---|
 | 248 | TwoBodyThreeCenterInt::basis3()
 | 
|---|
 | 249 | {
 | 
|---|
 | 250 |   return bs3_;
 | 
|---|
 | 251 | }
 | 
|---|
 | 252 | 
 | 
|---|
 | 253 | const double *
 | 
|---|
 | 254 | TwoBodyThreeCenterInt::buffer(tbint_type i) const
 | 
|---|
 | 255 | {
 | 
|---|
 | 256 |   if (i==eri) return buffer_;
 | 
|---|
 | 257 |   return 0;
 | 
|---|
 | 258 | }
 | 
|---|
 | 259 | 
 | 
|---|
 | 260 | void
 | 
|---|
 | 261 | TwoBodyThreeCenterInt::set_integral_storage(size_t storage)
 | 
|---|
 | 262 | {
 | 
|---|
 | 263 | }
 | 
|---|
 | 264 | 
 | 
|---|
 | 265 | ///////////////////////////////////////////////////////////////////////
 | 
|---|
 | 266 | 
 | 
|---|
 | 267 | TwoBodyTwoCenterInt::TwoBodyTwoCenterInt(Integral *integral,
 | 
|---|
 | 268 |                        const Ref<GaussianBasisSet>&b1,
 | 
|---|
 | 269 |                        const Ref<GaussianBasisSet>&b2) :
 | 
|---|
 | 270 |   integral_(integral),
 | 
|---|
 | 271 |   bs1_(b1), bs2_(b2), redundant_(1)
 | 
|---|
 | 272 | {
 | 
|---|
 | 273 |   integral_->reference();
 | 
|---|
 | 274 |   buffer_ = 0;
 | 
|---|
 | 275 | }
 | 
|---|
 | 276 | 
 | 
|---|
 | 277 | TwoBodyTwoCenterInt::~TwoBodyTwoCenterInt()
 | 
|---|
 | 278 | {
 | 
|---|
 | 279 |   integral_->dereference();
 | 
|---|
 | 280 |   if (integral_->nreference() == 0) delete integral_;
 | 
|---|
 | 281 | }
 | 
|---|
 | 282 | 
 | 
|---|
 | 283 | int
 | 
|---|
 | 284 | TwoBodyTwoCenterInt::nbasis() const
 | 
|---|
 | 285 | {
 | 
|---|
 | 286 |   return bs1_->nbasis();
 | 
|---|
 | 287 | }
 | 
|---|
 | 288 | 
 | 
|---|
 | 289 | int
 | 
|---|
 | 290 | TwoBodyTwoCenterInt::nbasis1() const
 | 
|---|
 | 291 | {
 | 
|---|
 | 292 |   return bs1_->nbasis();
 | 
|---|
 | 293 | }
 | 
|---|
 | 294 | 
 | 
|---|
 | 295 | int
 | 
|---|
 | 296 | TwoBodyTwoCenterInt::nbasis2() const
 | 
|---|
 | 297 | {
 | 
|---|
 | 298 |   return bs2_->nbasis();
 | 
|---|
 | 299 | }
 | 
|---|
 | 300 | 
 | 
|---|
 | 301 | int
 | 
|---|
 | 302 | TwoBodyTwoCenterInt::nshell() const
 | 
|---|
 | 303 | {
 | 
|---|
 | 304 |   return bs1_->nshell();
 | 
|---|
 | 305 | }
 | 
|---|
 | 306 | 
 | 
|---|
 | 307 | int
 | 
|---|
 | 308 | TwoBodyTwoCenterInt::nshell1() const
 | 
|---|
 | 309 | {
 | 
|---|
 | 310 |   return bs1_->nshell();
 | 
|---|
 | 311 | }
 | 
|---|
 | 312 | 
 | 
|---|
 | 313 | int
 | 
|---|
 | 314 | TwoBodyTwoCenterInt::nshell2() const
 | 
|---|
 | 315 | {
 | 
|---|
 | 316 |   return bs2_->nshell();
 | 
|---|
 | 317 | }
 | 
|---|
 | 318 | 
 | 
|---|
 | 319 | Ref<GaussianBasisSet>
 | 
|---|
 | 320 | TwoBodyTwoCenterInt::basis()
 | 
|---|
 | 321 | {
 | 
|---|
 | 322 |   return bs1_;
 | 
|---|
 | 323 | }
 | 
|---|
 | 324 | 
 | 
|---|
 | 325 | Ref<GaussianBasisSet>
 | 
|---|
 | 326 | TwoBodyTwoCenterInt::basis1()
 | 
|---|
 | 327 | {
 | 
|---|
 | 328 |   return bs1_;
 | 
|---|
 | 329 | }
 | 
|---|
 | 330 | 
 | 
|---|
 | 331 | Ref<GaussianBasisSet>
 | 
|---|
 | 332 | TwoBodyTwoCenterInt::basis2()
 | 
|---|
 | 333 | {
 | 
|---|
 | 334 |   return bs2_;
 | 
|---|
 | 335 | }
 | 
|---|
 | 336 | 
 | 
|---|
 | 337 | const double *
 | 
|---|
 | 338 | TwoBodyTwoCenterInt::buffer(tbint_type i) const
 | 
|---|
 | 339 | {
 | 
|---|
 | 340 |   if (i==eri) return buffer_;
 | 
|---|
 | 341 |   return 0;
 | 
|---|
 | 342 | }
 | 
|---|
 | 343 | 
 | 
|---|
 | 344 | void
 | 
|---|
 | 345 | TwoBodyTwoCenterInt::set_integral_storage(size_t storage)
 | 
|---|
 | 346 | {
 | 
|---|
 | 347 | }
 | 
|---|
 | 348 | 
 | 
|---|
 | 349 | ///////////////////////////////////////////////////////////////////////
 | 
|---|
 | 350 | 
 | 
|---|
 | 351 | ShellQuartetIter::ShellQuartetIter()
 | 
|---|
 | 352 | {
 | 
|---|
 | 353 | }
 | 
|---|
 | 354 | 
 | 
|---|
 | 355 | ShellQuartetIter::~ShellQuartetIter()
 | 
|---|
 | 356 | {
 | 
|---|
 | 357 | }
 | 
|---|
 | 358 | 
 | 
|---|
 | 359 | void
 | 
|---|
 | 360 | ShellQuartetIter::init(const double * b,
 | 
|---|
 | 361 |                        int is, int js, int ks, int ls,
 | 
|---|
 | 362 |                        int fi, int fj, int fk, int fl,
 | 
|---|
 | 363 |                        int ni, int nj, int nk, int nl,
 | 
|---|
 | 364 |                        double scl, int redund)
 | 
|---|
 | 365 | {
 | 
|---|
 | 366 |   redund_ = redund;
 | 
|---|
 | 367 |   
 | 
|---|
 | 368 |   e12 = (is==js);
 | 
|---|
 | 369 |   e34 = (ks==ls);
 | 
|---|
 | 370 |   e13e24 = (is==ks) && (js==ls);
 | 
|---|
 | 371 |   
 | 
|---|
 | 372 |   istart=fi;
 | 
|---|
 | 373 |   jstart=fj;
 | 
|---|
 | 374 |   kstart=fk;
 | 
|---|
 | 375 |   lstart=fl;
 | 
|---|
 | 376 | 
 | 
|---|
 | 377 |   index=0;
 | 
|---|
 | 378 |   
 | 
|---|
 | 379 |   iend=ni;
 | 
|---|
 | 380 |   jend=nj;
 | 
|---|
 | 381 |   kend=nk;
 | 
|---|
 | 382 |   lend=nl;
 | 
|---|
 | 383 | 
 | 
|---|
 | 384 |   buf=b;
 | 
|---|
 | 385 |   scale_=scl;
 | 
|---|
 | 386 | }
 | 
|---|
 | 387 | 
 | 
|---|
 | 388 | void
 | 
|---|
 | 389 | ShellQuartetIter::start()
 | 
|---|
 | 390 | {
 | 
|---|
 | 391 |   icur=0; i_ = istart;
 | 
|---|
 | 392 |   jcur=0; j_ = jstart;
 | 
|---|
 | 393 |   kcur=0; k_ = kstart;
 | 
|---|
 | 394 |   lcur=0; l_ = lstart;
 | 
|---|
 | 395 | }
 | 
|---|
 | 396 | 
 | 
|---|
 | 397 | void
 | 
|---|
 | 398 | ShellQuartetIter::next()
 | 
|---|
 | 399 | {
 | 
|---|
 | 400 |   index++;
 | 
|---|
 | 401 | 
 | 
|---|
 | 402 |   if (redund_) {
 | 
|---|
 | 403 |     if (lcur < lend-1) {
 | 
|---|
 | 404 |       lcur++;
 | 
|---|
 | 405 |       l_++;
 | 
|---|
 | 406 |       return;
 | 
|---|
 | 407 |     }
 | 
|---|
 | 408 | 
 | 
|---|
 | 409 |     lcur=0;
 | 
|---|
 | 410 |     l_=lstart;
 | 
|---|
 | 411 |     
 | 
|---|
 | 412 |     if (kcur < kend-1) {
 | 
|---|
 | 413 |       kcur++;
 | 
|---|
 | 414 |       k_++;
 | 
|---|
 | 415 |       return;
 | 
|---|
 | 416 |     }
 | 
|---|
 | 417 | 
 | 
|---|
 | 418 |     kcur=0;
 | 
|---|
 | 419 |     k_=kstart;
 | 
|---|
 | 420 | 
 | 
|---|
 | 421 |     if (jcur < jend-1) {
 | 
|---|
 | 422 |       jcur++;
 | 
|---|
 | 423 |       j_++;
 | 
|---|
 | 424 |       return;
 | 
|---|
 | 425 |     }
 | 
|---|
 | 426 | 
 | 
|---|
 | 427 |     jcur=0;
 | 
|---|
 | 428 |     j_=jstart;
 | 
|---|
 | 429 |   
 | 
|---|
 | 430 |     icur++;
 | 
|---|
 | 431 |     i_++;
 | 
|---|
 | 432 | 
 | 
|---|
 | 433 |   } else {
 | 
|---|
 | 434 |     if (lcur < ((e34) ? (((e13e24)&&((kcur)==(icur)))?(jcur):(kcur))
 | 
|---|
 | 435 |                 : ((e13e24)&&((kcur)==(icur)))?(jcur):(lend)-1)) {
 | 
|---|
 | 436 |       lcur++;
 | 
|---|
 | 437 |       l_++;
 | 
|---|
 | 438 |       return;
 | 
|---|
 | 439 |     }
 | 
|---|
 | 440 | 
 | 
|---|
 | 441 |     lcur=0;
 | 
|---|
 | 442 |     l_=lstart;
 | 
|---|
 | 443 | 
 | 
|---|
 | 444 |     if (kcur < ((e13e24)?(icur):((kend)-1))) {
 | 
|---|
 | 445 |       kcur++;
 | 
|---|
 | 446 |       k_++;
 | 
|---|
 | 447 |       return;
 | 
|---|
 | 448 |     }
 | 
|---|
 | 449 | 
 | 
|---|
 | 450 |     kcur=0;
 | 
|---|
 | 451 |     k_=kstart;
 | 
|---|
 | 452 | 
 | 
|---|
 | 453 |     if (jcur < ((e12)?(icur):((jend)-1))) {
 | 
|---|
 | 454 |       jcur++;
 | 
|---|
 | 455 |       j_++;
 | 
|---|
 | 456 |       return;
 | 
|---|
 | 457 |     }
 | 
|---|
 | 458 | 
 | 
|---|
 | 459 |     jcur=0;
 | 
|---|
 | 460 |     j_=jstart;
 | 
|---|
 | 461 |   
 | 
|---|
 | 462 |     icur++;
 | 
|---|
 | 463 |     i_++;
 | 
|---|
 | 464 |   }
 | 
|---|
 | 465 | }
 | 
|---|
 | 466 | 
 | 
|---|
 | 467 | ///////////////////////////////////////////////////////////////////////
 | 
|---|
 | 468 | 
 | 
|---|
 | 469 | TwoBodyIntIter::TwoBodyIntIter()
 | 
|---|
 | 470 | {
 | 
|---|
 | 471 | }
 | 
|---|
 | 472 | 
 | 
|---|
 | 473 | TwoBodyIntIter::TwoBodyIntIter(const Ref<TwoBodyInt>& t) :
 | 
|---|
 | 474 |   tbi(t)
 | 
|---|
 | 475 | {
 | 
|---|
 | 476 | }
 | 
|---|
 | 477 | 
 | 
|---|
 | 478 | TwoBodyIntIter::~TwoBodyIntIter()
 | 
|---|
 | 479 | {
 | 
|---|
 | 480 | }
 | 
|---|
 | 481 | 
 | 
|---|
 | 482 | void
 | 
|---|
 | 483 | TwoBodyIntIter::start()
 | 
|---|
 | 484 | {
 | 
|---|
 | 485 |   icur=0;
 | 
|---|
 | 486 |   jcur=0;
 | 
|---|
 | 487 |   kcur=0;
 | 
|---|
 | 488 |   lcur=0;
 | 
|---|
 | 489 | 
 | 
|---|
 | 490 |   iend = tbi->nshell();
 | 
|---|
 | 491 | }
 | 
|---|
 | 492 | 
 | 
|---|
 | 493 | void
 | 
|---|
 | 494 | TwoBodyIntIter::next()
 | 
|---|
 | 495 | {
 | 
|---|
 | 496 |   if (lcur < ((icur==kcur) ? jcur : kcur)) { // increment l loop?
 | 
|---|
 | 497 |     lcur++;
 | 
|---|
 | 498 |     return;
 | 
|---|
 | 499 |   }
 | 
|---|
 | 500 | 
 | 
|---|
 | 501 |   // restart l loop
 | 
|---|
 | 502 |   lcur=0;
 | 
|---|
 | 503 | 
 | 
|---|
 | 504 |   if (kcur < icur) { // increment k loop?
 | 
|---|
 | 505 |     kcur++;
 | 
|---|
 | 506 |     return;
 | 
|---|
 | 507 |   }
 | 
|---|
 | 508 | 
 | 
|---|
 | 509 |   // restart k loop
 | 
|---|
 | 510 |   kcur=0;
 | 
|---|
 | 511 | 
 | 
|---|
 | 512 |   if (jcur < icur) { // increment j loop?
 | 
|---|
 | 513 |     jcur++;
 | 
|---|
 | 514 |     return;
 | 
|---|
 | 515 |   }
 | 
|---|
 | 516 | 
 | 
|---|
 | 517 |   // restart j loop
 | 
|---|
 | 518 |   jcur=0;
 | 
|---|
 | 519 | 
 | 
|---|
 | 520 |   // increment i loop
 | 
|---|
 | 521 |   icur++;
 | 
|---|
 | 522 | }
 | 
|---|
 | 523 | 
 | 
|---|
 | 524 | double
 | 
|---|
 | 525 | TwoBodyIntIter::scale() const
 | 
|---|
 | 526 | {
 | 
|---|
 | 527 |   return 1.0;
 | 
|---|
 | 528 | }
 | 
|---|
 | 529 | 
 | 
|---|
 | 530 | ShellQuartetIter&
 | 
|---|
 | 531 | TwoBodyIntIter::current_quartet()
 | 
|---|
 | 532 | {
 | 
|---|
 | 533 |   tbi->compute_shell(icur,jcur,kcur,lcur);
 | 
|---|
 | 534 |   
 | 
|---|
 | 535 |   sqi.init(tbi->buffer(),
 | 
|---|
 | 536 |            icur, jcur, kcur, lcur,
 | 
|---|
 | 537 |            tbi->basis()->shell_to_function(icur),
 | 
|---|
 | 538 |            tbi->basis()->shell_to_function(jcur),
 | 
|---|
 | 539 |            tbi->basis()->shell_to_function(kcur),
 | 
|---|
 | 540 |            tbi->basis()->shell_to_function(lcur),
 | 
|---|
 | 541 |            tbi->basis()->operator()(icur).nfunction(),
 | 
|---|
 | 542 |            tbi->basis()->operator()(jcur).nfunction(),
 | 
|---|
 | 543 |            tbi->basis()->operator()(kcur).nfunction(),
 | 
|---|
 | 544 |            tbi->basis()->operator()(lcur).nfunction(),
 | 
|---|
 | 545 |            scale(),
 | 
|---|
 | 546 |            tbi->redundant()
 | 
|---|
 | 547 |     );
 | 
|---|
 | 548 | 
 | 
|---|
 | 549 |   return sqi;
 | 
|---|
 | 550 | }
 | 
|---|
 | 551 | 
 | 
|---|
 | 552 | ///////////////////////////////////////////////////////////////////////
 | 
|---|
 | 553 | 
 | 
|---|
 | 554 | TwoBodyDerivInt::TwoBodyDerivInt(Integral *integral,
 | 
|---|
 | 555 |                                  const Ref<GaussianBasisSet>&b1,
 | 
|---|
 | 556 |                                  const Ref<GaussianBasisSet>&b2,
 | 
|---|
 | 557 |                                  const Ref<GaussianBasisSet>&b3,
 | 
|---|
 | 558 |                                  const Ref<GaussianBasisSet>&b4):
 | 
|---|
 | 559 |   integral_(integral),
 | 
|---|
 | 560 |   bs1_(b1), bs2_(b2), bs3_(b3), bs4_(b4)
 | 
|---|
 | 561 | {
 | 
|---|
 | 562 |   integral_->reference();
 | 
|---|
 | 563 |   buffer_ = 0;
 | 
|---|
 | 564 | }
 | 
|---|
 | 565 | 
 | 
|---|
 | 566 | TwoBodyDerivInt::~TwoBodyDerivInt()
 | 
|---|
 | 567 | {
 | 
|---|
 | 568 |   integral_->dereference();
 | 
|---|
 | 569 |   if (integral_->nreference() == 0) delete integral_;
 | 
|---|
 | 570 | }
 | 
|---|
 | 571 | 
 | 
|---|
 | 572 | int
 | 
|---|
 | 573 | TwoBodyDerivInt::nbasis() const
 | 
|---|
 | 574 | {
 | 
|---|
 | 575 |   return bs1_->nbasis();
 | 
|---|
 | 576 | }
 | 
|---|
 | 577 | 
 | 
|---|
 | 578 | int
 | 
|---|
 | 579 | TwoBodyDerivInt::nbasis1() const
 | 
|---|
 | 580 | {
 | 
|---|
 | 581 |   return bs1_->nbasis();
 | 
|---|
 | 582 | }
 | 
|---|
 | 583 | 
 | 
|---|
 | 584 | int
 | 
|---|
 | 585 | TwoBodyDerivInt::nbasis2() const
 | 
|---|
 | 586 | {
 | 
|---|
 | 587 |   return bs2_->nbasis();
 | 
|---|
 | 588 | }
 | 
|---|
 | 589 | 
 | 
|---|
 | 590 | int
 | 
|---|
 | 591 | TwoBodyDerivInt::nbasis3() const
 | 
|---|
 | 592 | {
 | 
|---|
 | 593 |   return bs3_->nbasis();
 | 
|---|
 | 594 | }
 | 
|---|
 | 595 | 
 | 
|---|
 | 596 | int
 | 
|---|
 | 597 | TwoBodyDerivInt::nbasis4() const
 | 
|---|
 | 598 | {
 | 
|---|
 | 599 |   return bs4_->nbasis();
 | 
|---|
 | 600 | }
 | 
|---|
 | 601 | 
 | 
|---|
 | 602 | int
 | 
|---|
 | 603 | TwoBodyDerivInt::nshell() const
 | 
|---|
 | 604 | {
 | 
|---|
 | 605 |   return bs1_->nshell();
 | 
|---|
 | 606 | }
 | 
|---|
 | 607 | 
 | 
|---|
 | 608 | int
 | 
|---|
 | 609 | TwoBodyDerivInt::nshell1() const
 | 
|---|
 | 610 | {
 | 
|---|
 | 611 |   return bs1_->nshell();
 | 
|---|
 | 612 | }
 | 
|---|
 | 613 | 
 | 
|---|
 | 614 | int
 | 
|---|
 | 615 | TwoBodyDerivInt::nshell2() const
 | 
|---|
 | 616 | {
 | 
|---|
 | 617 |   return bs2_->nshell();
 | 
|---|
 | 618 | }
 | 
|---|
 | 619 | 
 | 
|---|
 | 620 | int
 | 
|---|
 | 621 | TwoBodyDerivInt::nshell3() const
 | 
|---|
 | 622 | {
 | 
|---|
 | 623 |   return bs3_->nshell();
 | 
|---|
 | 624 | }
 | 
|---|
 | 625 | 
 | 
|---|
 | 626 | int
 | 
|---|
 | 627 | TwoBodyDerivInt::nshell4() const
 | 
|---|
 | 628 | {
 | 
|---|
 | 629 |   return bs4_->nshell();
 | 
|---|
 | 630 | }
 | 
|---|
 | 631 | 
 | 
|---|
 | 632 | Ref<GaussianBasisSet>
 | 
|---|
 | 633 | TwoBodyDerivInt::basis()
 | 
|---|
 | 634 | {
 | 
|---|
 | 635 |   return bs1_;
 | 
|---|
 | 636 | }
 | 
|---|
 | 637 | 
 | 
|---|
 | 638 | Ref<GaussianBasisSet>
 | 
|---|
 | 639 | TwoBodyDerivInt::basis1()
 | 
|---|
 | 640 | {
 | 
|---|
 | 641 |   return bs1_;
 | 
|---|
 | 642 | }
 | 
|---|
 | 643 | 
 | 
|---|
 | 644 | Ref<GaussianBasisSet>
 | 
|---|
 | 645 | TwoBodyDerivInt::basis2()
 | 
|---|
 | 646 | {
 | 
|---|
 | 647 |   return bs2_;
 | 
|---|
 | 648 | }
 | 
|---|
 | 649 | 
 | 
|---|
 | 650 | Ref<GaussianBasisSet>
 | 
|---|
 | 651 | TwoBodyDerivInt::basis3()
 | 
|---|
 | 652 | {
 | 
|---|
 | 653 |   return bs3_;
 | 
|---|
 | 654 | }
 | 
|---|
 | 655 | 
 | 
|---|
 | 656 | Ref<GaussianBasisSet>
 | 
|---|
 | 657 | TwoBodyDerivInt::basis4()
 | 
|---|
 | 658 | {
 | 
|---|
 | 659 |   return bs4_;
 | 
|---|
 | 660 | }
 | 
|---|
 | 661 | 
 | 
|---|
 | 662 | const double *
 | 
|---|
 | 663 | TwoBodyDerivInt::buffer() const
 | 
|---|
 | 664 | {
 | 
|---|
 | 665 |   return buffer_;
 | 
|---|
 | 666 | }
 | 
|---|
 | 667 | 
 | 
|---|
 | 668 | ///////////////////////////////////////////////////////////////////////
 | 
|---|
 | 669 | 
 | 
|---|
 | 670 | TwoBodyThreeCenterDerivInt::TwoBodyThreeCenterDerivInt(Integral *integral,
 | 
|---|
 | 671 |                                  const Ref<GaussianBasisSet>&b1,
 | 
|---|
 | 672 |                                  const Ref<GaussianBasisSet>&b2,
 | 
|---|
 | 673 |                                  const Ref<GaussianBasisSet>&b3):
 | 
|---|
 | 674 |   integral_(integral),
 | 
|---|
 | 675 |   bs1_(b1), bs2_(b2), bs3_(b3)
 | 
|---|
 | 676 | {
 | 
|---|
 | 677 |   integral_->reference();
 | 
|---|
 | 678 |   buffer_ = 0;
 | 
|---|
 | 679 | }
 | 
|---|
 | 680 | 
 | 
|---|
 | 681 | TwoBodyThreeCenterDerivInt::~TwoBodyThreeCenterDerivInt()
 | 
|---|
 | 682 | {
 | 
|---|
 | 683 |   integral_->dereference();
 | 
|---|
 | 684 |   if (integral_->nreference() == 0) delete integral_;
 | 
|---|
 | 685 | }
 | 
|---|
 | 686 | 
 | 
|---|
 | 687 | int
 | 
|---|
 | 688 | TwoBodyThreeCenterDerivInt::nbasis() const
 | 
|---|
 | 689 | {
 | 
|---|
 | 690 |   return bs1_->nbasis();
 | 
|---|
 | 691 | }
 | 
|---|
 | 692 | 
 | 
|---|
 | 693 | int
 | 
|---|
 | 694 | TwoBodyThreeCenterDerivInt::nbasis1() const
 | 
|---|
 | 695 | {
 | 
|---|
 | 696 |   return bs1_->nbasis();
 | 
|---|
 | 697 | }
 | 
|---|
 | 698 | 
 | 
|---|
 | 699 | int
 | 
|---|
 | 700 | TwoBodyThreeCenterDerivInt::nbasis2() const
 | 
|---|
 | 701 | {
 | 
|---|
 | 702 |   return bs2_->nbasis();
 | 
|---|
 | 703 | }
 | 
|---|
 | 704 | 
 | 
|---|
 | 705 | int
 | 
|---|
 | 706 | TwoBodyThreeCenterDerivInt::nbasis3() const
 | 
|---|
 | 707 | {
 | 
|---|
 | 708 |   return bs3_->nbasis();
 | 
|---|
 | 709 | }
 | 
|---|
 | 710 | 
 | 
|---|
 | 711 | int
 | 
|---|
 | 712 | TwoBodyThreeCenterDerivInt::nshell() const
 | 
|---|
 | 713 | {
 | 
|---|
 | 714 |   return bs1_->nshell();
 | 
|---|
 | 715 | }
 | 
|---|
 | 716 | 
 | 
|---|
 | 717 | int
 | 
|---|
 | 718 | TwoBodyThreeCenterDerivInt::nshell1() const
 | 
|---|
 | 719 | {
 | 
|---|
 | 720 |   return bs1_->nshell();
 | 
|---|
 | 721 | }
 | 
|---|
 | 722 | 
 | 
|---|
 | 723 | int
 | 
|---|
 | 724 | TwoBodyThreeCenterDerivInt::nshell2() const
 | 
|---|
 | 725 | {
 | 
|---|
 | 726 |   return bs2_->nshell();
 | 
|---|
 | 727 | }
 | 
|---|
 | 728 | 
 | 
|---|
 | 729 | int
 | 
|---|
 | 730 | TwoBodyThreeCenterDerivInt::nshell3() const
 | 
|---|
 | 731 | {
 | 
|---|
 | 732 |   return bs3_->nshell();
 | 
|---|
 | 733 | }
 | 
|---|
 | 734 | 
 | 
|---|
 | 735 | Ref<GaussianBasisSet>
 | 
|---|
 | 736 | TwoBodyThreeCenterDerivInt::basis()
 | 
|---|
 | 737 | {
 | 
|---|
 | 738 |   return bs1_;
 | 
|---|
 | 739 | }
 | 
|---|
 | 740 | 
 | 
|---|
 | 741 | Ref<GaussianBasisSet>
 | 
|---|
 | 742 | TwoBodyThreeCenterDerivInt::basis1()
 | 
|---|
 | 743 | {
 | 
|---|
 | 744 |   return bs1_;
 | 
|---|
 | 745 | }
 | 
|---|
 | 746 | 
 | 
|---|
 | 747 | Ref<GaussianBasisSet>
 | 
|---|
 | 748 | TwoBodyThreeCenterDerivInt::basis2()
 | 
|---|
 | 749 | {
 | 
|---|
 | 750 |   return bs2_;
 | 
|---|
 | 751 | }
 | 
|---|
 | 752 | 
 | 
|---|
 | 753 | Ref<GaussianBasisSet>
 | 
|---|
 | 754 | TwoBodyThreeCenterDerivInt::basis3()
 | 
|---|
 | 755 | {
 | 
|---|
 | 756 |   return bs3_;
 | 
|---|
 | 757 | }
 | 
|---|
 | 758 | 
 | 
|---|
 | 759 | const double *
 | 
|---|
 | 760 | TwoBodyThreeCenterDerivInt::buffer() const
 | 
|---|
 | 761 | {
 | 
|---|
 | 762 |   return buffer_;
 | 
|---|
 | 763 | }
 | 
|---|
 | 764 | 
 | 
|---|
 | 765 | ///////////////////////////////////////////////////////////////////////
 | 
|---|
 | 766 | 
 | 
|---|
 | 767 | TwoBodyTwoCenterDerivInt::TwoBodyTwoCenterDerivInt(Integral *integral,
 | 
|---|
 | 768 |                                  const Ref<GaussianBasisSet>&b1,
 | 
|---|
 | 769 |                                  const Ref<GaussianBasisSet>&b2):
 | 
|---|
 | 770 |   integral_(integral),
 | 
|---|
 | 771 |   bs1_(b1), bs2_(b2)
 | 
|---|
 | 772 | {
 | 
|---|
 | 773 |   integral_->reference();
 | 
|---|
 | 774 |   buffer_ = 0;
 | 
|---|
 | 775 | }
 | 
|---|
 | 776 | 
 | 
|---|
 | 777 | TwoBodyTwoCenterDerivInt::~TwoBodyTwoCenterDerivInt()
 | 
|---|
 | 778 | {
 | 
|---|
 | 779 |   integral_->dereference();
 | 
|---|
 | 780 |   if (integral_->nreference() == 0) delete integral_;
 | 
|---|
 | 781 | }
 | 
|---|
 | 782 | 
 | 
|---|
 | 783 | int
 | 
|---|
 | 784 | TwoBodyTwoCenterDerivInt::nbasis() const
 | 
|---|
 | 785 | {
 | 
|---|
 | 786 |   return bs1_->nbasis();
 | 
|---|
 | 787 | }
 | 
|---|
 | 788 | 
 | 
|---|
 | 789 | int
 | 
|---|
 | 790 | TwoBodyTwoCenterDerivInt::nbasis1() const
 | 
|---|
 | 791 | {
 | 
|---|
 | 792 |   return bs1_->nbasis();
 | 
|---|
 | 793 | }
 | 
|---|
 | 794 | 
 | 
|---|
 | 795 | int
 | 
|---|
 | 796 | TwoBodyTwoCenterDerivInt::nbasis2() const
 | 
|---|
 | 797 | {
 | 
|---|
 | 798 |   return bs2_->nbasis();
 | 
|---|
 | 799 | }
 | 
|---|
 | 800 | 
 | 
|---|
 | 801 | int
 | 
|---|
 | 802 | TwoBodyTwoCenterDerivInt::nshell() const
 | 
|---|
 | 803 | {
 | 
|---|
 | 804 |   return bs1_->nshell();
 | 
|---|
 | 805 | }
 | 
|---|
 | 806 | 
 | 
|---|
 | 807 | int
 | 
|---|
 | 808 | TwoBodyTwoCenterDerivInt::nshell1() const
 | 
|---|
 | 809 | {
 | 
|---|
 | 810 |   return bs1_->nshell();
 | 
|---|
 | 811 | }
 | 
|---|
 | 812 | 
 | 
|---|
 | 813 | int
 | 
|---|
 | 814 | TwoBodyTwoCenterDerivInt::nshell2() const
 | 
|---|
 | 815 | {
 | 
|---|
 | 816 |   return bs2_->nshell();
 | 
|---|
 | 817 | }
 | 
|---|
 | 818 | 
 | 
|---|
 | 819 | Ref<GaussianBasisSet>
 | 
|---|
 | 820 | TwoBodyTwoCenterDerivInt::basis()
 | 
|---|
 | 821 | {
 | 
|---|
 | 822 |   return bs1_;
 | 
|---|
 | 823 | }
 | 
|---|
 | 824 | 
 | 
|---|
 | 825 | Ref<GaussianBasisSet>
 | 
|---|
 | 826 | TwoBodyTwoCenterDerivInt::basis1()
 | 
|---|
 | 827 | {
 | 
|---|
 | 828 |   return bs1_;
 | 
|---|
 | 829 | }
 | 
|---|
 | 830 | 
 | 
|---|
 | 831 | Ref<GaussianBasisSet>
 | 
|---|
 | 832 | TwoBodyTwoCenterDerivInt::basis2()
 | 
|---|
 | 833 | {
 | 
|---|
 | 834 |   return bs2_;
 | 
|---|
 | 835 | }
 | 
|---|
 | 836 | 
 | 
|---|
 | 837 | const double *
 | 
|---|
 | 838 | TwoBodyTwoCenterDerivInt::buffer() const
 | 
|---|
 | 839 | {
 | 
|---|
 | 840 |   return buffer_;
 | 
|---|
 | 841 | }
 | 
|---|
 | 842 | 
 | 
|---|
 | 843 | /////////////////////////////////////////////////////////////////////////////
 | 
|---|
 | 844 | 
 | 
|---|
 | 845 | // Local Variables:
 | 
|---|
 | 846 | // mode: c++
 | 
|---|
 | 847 | // c-file-style: "ETS"
 | 
|---|
 | 848 | // End:
 | 
|---|