| 1 | //
|
|---|
| 2 | // store.cc
|
|---|
| 3 | //
|
|---|
| 4 | // Copyright (C) 1996 Limit Point Systems, Inc.
|
|---|
| 5 | //
|
|---|
| 6 | // Author: Curtis Janssen <cljanss@limitpt.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 <stdlib.h>
|
|---|
| 33 | #include <chemistry/qc/intv3/macros.h>
|
|---|
| 34 | #include <chemistry/qc/intv3/flags.h>
|
|---|
| 35 | #include <chemistry/qc/intv3/types.h>
|
|---|
| 36 |
|
|---|
| 37 | #include <chemistry/qc/intv3/storage.h>
|
|---|
| 38 | #include <chemistry/qc/intv3/int2e.h>
|
|---|
| 39 |
|
|---|
| 40 | using namespace sc;
|
|---|
| 41 |
|
|---|
| 42 | void
|
|---|
| 43 | Int2eV3::init_storage(int size)
|
|---|
| 44 | {
|
|---|
| 45 | storer = new IntegralStorer();
|
|---|
| 46 | storer->init(size);
|
|---|
| 47 | if (size) int_integral_storage = size;
|
|---|
| 48 | else int_integral_storage = 0;
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | void
|
|---|
| 52 | Int2eV3::done_storage()
|
|---|
| 53 | {
|
|---|
| 54 | if (storer.nonnull()) {
|
|---|
| 55 | storer->done();
|
|---|
| 56 | }
|
|---|
| 57 | int_integral_storage = 0;
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | int
|
|---|
| 61 | Int2eV3::int_have_stored_integral(int sh1,int sh2,int sh3,int sh4,
|
|---|
| 62 | int p12,int p34,int p13p24)
|
|---|
| 63 | {
|
|---|
| 64 | IntegralKey key(sh1,sh2,sh3,sh4,p12,p34,p13p24);
|
|---|
| 65 | IntegralLink *integral = storer->find(key);
|
|---|
| 66 |
|
|---|
| 67 | if (!integral) return 0;
|
|---|
| 68 |
|
|---|
| 69 | #if PRINT_STORED
|
|---|
| 70 | if (sh1 != integral->intlist.key.sh0()
|
|---|
| 71 | ||sh2 != integral->intlist.key.sh1()
|
|---|
| 72 | ||sh3 != integral->intlist.key.sh2()
|
|---|
| 73 | ||sh4 != integral->intlist.key.sh3()
|
|---|
| 74 | ||p12 != integral->intlist.key.p12()
|
|---|
| 75 | ||p34 != integral->intlist.key.p34()
|
|---|
| 76 | ||p13p24 != integral->intlist.key.p13p24()) {
|
|---|
| 77 | ExEnv::outn() << scprintf("!!!!! SHELL INFO INCONSISTENCY\n");
|
|---|
| 78 | abort();
|
|---|
| 79 | }
|
|---|
| 80 | ExEnv::outn() << scprintf("===== %d %d %d %d, %d %d %d size %5d cost %7d at 0x%x slot %5d\n",
|
|---|
| 81 | sh1, sh2, sh3, sh4,
|
|---|
| 82 | p12, p34, p13p24,
|
|---|
| 83 | integral->size, integral->costlist.key,
|
|---|
| 84 | integral, integral->hash()%storer->table_size());
|
|---|
| 85 | #endif
|
|---|
| 86 |
|
|---|
| 87 | int i;
|
|---|
| 88 | double *buffer = integral->buffer();
|
|---|
| 89 | for (i=0; i<integral->size; i++) {
|
|---|
| 90 | int_buffer[i] = buffer[i];
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | return 1;
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 | void
|
|---|
| 97 | Int2eV3::int_store_integral(int sh1,int sh2,int sh3,int sh4,
|
|---|
| 98 | int p12,int p34,int p13p24,
|
|---|
| 99 | int size)
|
|---|
| 100 | {
|
|---|
| 101 | // the cost of the integral is the time to evaluate it
|
|---|
| 102 | // times the number of times it is needed
|
|---|
| 103 | // divided by the amount of memory required to store it
|
|---|
| 104 | int cost;
|
|---|
| 105 | if (int_Qvec) cost = erep_4bound(sh1,sh2,sh3,sh4) + 30;
|
|---|
| 106 | else cost = 1;
|
|---|
| 107 | if (cost <= 0) return;
|
|---|
| 108 | cost *= int_shell1->nprimitive()
|
|---|
| 109 | * int_shell2->nprimitive()
|
|---|
| 110 | * int_shell3->nprimitive()
|
|---|
| 111 | * int_shell4->nprimitive()
|
|---|
| 112 | * size
|
|---|
| 113 | * 1024; // the 1024 is arbitrary
|
|---|
| 114 | int actualsize = IntegralLink::size_to_actualsize(size);
|
|---|
| 115 | cost /= actualsize;
|
|---|
| 116 |
|
|---|
| 117 | if (storer->should_store(cost, actualsize)) {
|
|---|
| 118 | IntegralKey key(sh1,sh2,sh3,sh4,p12,p34,p13p24);
|
|---|
| 119 | storer->store(key,int_buffer,size,cost,actualsize);
|
|---|
| 120 | }
|
|---|
| 121 | }
|
|---|
| 122 |
|
|---|
| 123 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 124 |
|
|---|
| 125 | // Local Variables:
|
|---|
| 126 | // mode: c++
|
|---|
| 127 | // c-file-style: "CLJ"
|
|---|
| 128 | // End:
|
|---|