| 1 | //
|
|---|
| 2 | // transform_factory.cc
|
|---|
| 3 | //
|
|---|
| 4 | // Copyright (C) 2004 Edward Valeev
|
|---|
| 5 | //
|
|---|
| 6 | // Author: Edward Valeev <edward.valeev@chemistry.gatech.edu>
|
|---|
| 7 | // Maintainer: EV
|
|---|
| 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 __GNUG__
|
|---|
| 29 | #pragma implementation
|
|---|
| 30 | #endif
|
|---|
| 31 |
|
|---|
| 32 | #include <stdexcept>
|
|---|
| 33 |
|
|---|
| 34 | #include <util/misc/formio.h>
|
|---|
| 35 | #include <util/state/state_bin.h>
|
|---|
| 36 | #include <util/ref/ref.h>
|
|---|
| 37 | #include <math/scmat/local.h>
|
|---|
| 38 | #include <chemistry/qc/mbptr12/transform_factory.h>
|
|---|
| 39 | #include <chemistry/qc/mbptr12/transform_ijxy.h>
|
|---|
| 40 | #include <chemistry/qc/mbptr12/transform_ixjy.h>
|
|---|
| 41 | #include <chemistry/qc/mbptr12/transform_ikjy.h>
|
|---|
| 42 |
|
|---|
| 43 | using namespace std;
|
|---|
| 44 | using namespace sc;
|
|---|
| 45 |
|
|---|
| 46 | inline int max(int a,int b) { return (a > b) ? a : b;}
|
|---|
| 47 |
|
|---|
| 48 | /*-----------
|
|---|
| 49 | MOIntsTransformFactory
|
|---|
| 50 | -----------*/
|
|---|
| 51 | static ClassDesc MOIntsTransformFactory_cd(
|
|---|
| 52 | typeid(MOIntsTransformFactory),"MOIntsTransformFactory",1,"virtual public SavableState",
|
|---|
| 53 | 0, 0, create<MOIntsTransformFactory>);
|
|---|
| 54 |
|
|---|
| 55 | MOIntsTransformFactory::MOIntsTransformFactory(const Ref<Integral>& integral,
|
|---|
| 56 | const Ref<MOIndexSpace>& space1, const Ref<MOIndexSpace>& space2,
|
|---|
| 57 | const Ref<MOIndexSpace>& space3, const Ref<MOIndexSpace>& space4) :
|
|---|
| 58 | integral_(integral), space1_(space1), space2_(space2), space3_(space3), space4_(space4)
|
|---|
| 59 | {
|
|---|
| 60 | if (space2.null())
|
|---|
| 61 | space2_ = space1_;
|
|---|
| 62 | if (space3.null())
|
|---|
| 63 | space3_ = space2_;
|
|---|
| 64 | if (space4.null())
|
|---|
| 65 | space4_ = space3_;
|
|---|
| 66 |
|
|---|
| 67 | mem_ = MemoryGrp::get_default_memorygrp();
|
|---|
| 68 | msg_ = MessageGrp::get_default_messagegrp();
|
|---|
| 69 | thr_ = ThreadGrp::get_default_threadgrp();
|
|---|
| 70 |
|
|---|
| 71 | // Default values
|
|---|
| 72 | memory_ = DEFAULT_SC_MEMORY;
|
|---|
| 73 | debug_ = 0;
|
|---|
| 74 | dynamic_ = false;
|
|---|
| 75 | print_percent_ = 10.0;
|
|---|
| 76 | ints_method_ = mem_posix;
|
|---|
| 77 | file_prefix_ = "/tmp/moints";
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | MOIntsTransformFactory::MOIntsTransformFactory(StateIn& si) : SavableState(si)
|
|---|
| 81 | {
|
|---|
| 82 | integral_ << SavableState::restore_state(si);
|
|---|
| 83 | space1_ << SavableState::restore_state(si);
|
|---|
| 84 | space2_ << SavableState::restore_state(si);
|
|---|
| 85 | space3_ << SavableState::restore_state(si);
|
|---|
| 86 | space4_ << SavableState::restore_state(si);
|
|---|
| 87 |
|
|---|
| 88 | mem_ = MemoryGrp::get_default_memorygrp();
|
|---|
| 89 | msg_ = MessageGrp::get_default_messagegrp();
|
|---|
| 90 | thr_ = ThreadGrp::get_default_threadgrp();
|
|---|
| 91 |
|
|---|
| 92 | double memory; si.get(memory); memory_ = (size_t) memory;
|
|---|
| 93 | si.get(debug_);
|
|---|
| 94 | int dynamic; si.get(dynamic); dynamic_ = (bool) dynamic;
|
|---|
| 95 | si.get(print_percent_);
|
|---|
| 96 | int ints_method; si.get(ints_method); ints_method_ = (StoreMethod) ints_method;
|
|---|
| 97 | si.get(file_prefix_);
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | MOIntsTransformFactory::~MOIntsTransformFactory()
|
|---|
| 101 | {
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | void
|
|---|
| 105 | MOIntsTransformFactory::save_data_state(StateOut& so)
|
|---|
| 106 | {
|
|---|
| 107 | SavableState::save_state(integral_.pointer(),so);
|
|---|
| 108 | SavableState::save_state(space1_.pointer(),so);
|
|---|
| 109 | SavableState::save_state(space2_.pointer(),so);
|
|---|
| 110 | SavableState::save_state(space3_.pointer(),so);
|
|---|
| 111 | SavableState::save_state(space4_.pointer(),so);
|
|---|
| 112 |
|
|---|
| 113 | so.put((double)memory_);
|
|---|
| 114 | so.put(debug_);
|
|---|
| 115 | so.put((int)dynamic_);
|
|---|
| 116 | so.put(print_percent_);
|
|---|
| 117 | so.put((int)ints_method_);
|
|---|
| 118 | so.put(file_prefix_);
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | void
|
|---|
| 122 | MOIntsTransformFactory::set_spaces(const Ref<MOIndexSpace>& space1, const Ref<MOIndexSpace>& space2,
|
|---|
| 123 | const Ref<MOIndexSpace>& space3, const Ref<MOIndexSpace>& space4)
|
|---|
| 124 | {
|
|---|
| 125 | space1_ = space1;
|
|---|
| 126 | if (space2.null())
|
|---|
| 127 | space2_ = space1_;
|
|---|
| 128 | else
|
|---|
| 129 | space2_ = space2;
|
|---|
| 130 | if (space3.null())
|
|---|
| 131 | space3_ = space2_;
|
|---|
| 132 | else
|
|---|
| 133 | space3_ = space3;
|
|---|
| 134 | if (space4.null())
|
|---|
| 135 | space4_ = space3_;
|
|---|
| 136 | else
|
|---|
| 137 | space4_ = space4;
|
|---|
| 138 | }
|
|---|
| 139 |
|
|---|
| 140 | Ref<TwoBodyMOIntsTransform>
|
|---|
| 141 | MOIntsTransformFactory::twobody_transform_13(const std::string& name)
|
|---|
| 142 | {
|
|---|
| 143 | Ref<TwoBodyMOIntsTransform> result;
|
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 | if (space2_->rank() <= space2_->basis()->nbasis()) {
|
|---|
| 147 | result = new TwoBodyMOIntsTransform_ikjy(name,this,space1_,space2_,space3_,space4_);
|
|---|
| 148 | }
|
|---|
| 149 | else {
|
|---|
| 150 | result = new TwoBodyMOIntsTransform_ixjy(name,this,space1_,space2_,space3_,space4_);
|
|---|
| 151 | }
|
|---|
| 152 |
|
|---|
| 153 | if (top_mole_.nonnull())
|
|---|
| 154 | result->set_top_mole(top_mole_);
|
|---|
| 155 |
|
|---|
| 156 | return result;
|
|---|
| 157 | }
|
|---|
| 158 |
|
|---|
| 159 | Ref<TwoBodyMOIntsTransform>
|
|---|
| 160 | MOIntsTransformFactory::twobody_transform_12(const std::string& name)
|
|---|
| 161 | {
|
|---|
| 162 | Ref<TwoBodyMOIntsTransform> result;
|
|---|
| 163 |
|
|---|
| 164 | result = new TwoBodyMOIntsTransform_ijxy(name,this,space1_,space2_,space3_,space4_);
|
|---|
| 165 |
|
|---|
| 166 | if (top_mole_.nonnull())
|
|---|
| 167 | result->set_top_mole(top_mole_);
|
|---|
| 168 |
|
|---|
| 169 | return result;
|
|---|
| 170 | }
|
|---|
| 171 |
|
|---|
| 172 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 173 |
|
|---|
| 174 | // Local Variables:
|
|---|
| 175 | // mode: c++
|
|---|
| 176 | // c-file-style: "CLJ-CONDENSED"
|
|---|
| 177 | // End:
|
|---|