1 // 2 // BAGEL - Brilliantly Advanced General Electronic Structure Library 3 // Filename: reldffull.h 4 // Copyright (C) 2013 Toru Shiozaki 5 // 6 // Author: Toru Shiozaki <shiozaki@northwestern.edu> 7 // Maintainer: Shiozaki group 8 // 9 // This file is part of the BAGEL package. 10 // 11 // This program is free software: you can redistribute it and/or modify 12 // it under the terms of the GNU General Public License as published by 13 // the Free Software Foundation, either version 3 of the License, or 14 // (at your option) any later version. 15 // 16 // This program 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 General Public License for more details. 20 // 21 // You should have received a copy of the GNU General Public License 22 // along with this program. If not, see <http://www.gnu.org/licenses/>. 23 // 24 25 #ifndef __SRC_DF_RELDFFULL_H 26 #define __SRC_DF_RELDFFULL_H 27 28 #include <src/df/reldf.h> 29 #include <src/df/reldfhalf.h> 30 31 namespace bagel { 32 33 class RelDF; 34 class RelDFHalf; 35 36 class RelDFFull : public RelDFBase { 37 protected: 38 std::array<std::shared_ptr<DFFullDist>,2> dffull_; 39 40 void init(std::shared_ptr<const RelDFHalf>, std::array<std::shared_ptr<const Matrix>,4>, std::array<std::shared_ptr<const Matrix>,4>); 41 42 public: 43 RelDFFull(std::shared_ptr<const RelDFHalf>, std::shared_ptr<const ZMatrix>); 44 RelDFFull(std::shared_ptr<const RelDFHalf>, std::array<std::shared_ptr<const Matrix>,4>, std::array<std::shared_ptr<const Matrix>,4>); 45 RelDFFull(std::array<std::shared_ptr<DFFullDist>,2> a, std::pair<int,int> cartesian, std::vector<std::shared_ptr<const SpinorInfo>> basis); 46 RelDFFull(const RelDFFull& o); 47 get_data()48 std::array<std::shared_ptr<DFFullDist>, 2> get_data() const { return dffull_; } get_real()49 std::shared_ptr<DFFullDist> get_real() const { return dffull_[0]; } get_imag()50 std::shared_ptr<DFFullDist> get_imag() const { return dffull_[1]; } 51 matches(std::shared_ptr<const RelDFFull> o)52 bool matches(std::shared_ptr<const RelDFFull> o) const { return alpha_matches(o); } alpha_matches(std::shared_ptr<const RelDFFull> o)53 bool alpha_matches(std::shared_ptr<const RelDFFull> o) const { return alpha_comp() == o->alpha_comp(); } alpha_comp()54 int alpha_comp() const { assert(basis_.size() == 1); return basis_[0]->alpha_comp(); } 55 nocc1()56 int nocc1() const { assert(dffull_[0]->nocc1() == dffull_[1]->nocc1()); return dffull_[0]->nocc1(); } nocc2()57 int nocc2() const { assert(dffull_[0]->nocc2() == dffull_[1]->nocc2()); return dffull_[0]->nocc2(); } 58 copy()59 std::shared_ptr<RelDFFull> copy() const { return std::make_shared<RelDFFull>(*this); } 60 std::shared_ptr<RelDFFull> clone() const; 61 std::shared_ptr<RelDFFull> apply_J() const; 62 std::shared_ptr<RelDFFull> apply_JJ() const; 63 std::shared_ptr<RelDFFull> swap() const; 64 65 // zaxpy ax_plus_y(const std::complex<double> & a,std::shared_ptr<const RelDFFull> o)66 void ax_plus_y(const std::complex<double>& a, std::shared_ptr<const RelDFFull> o) { ax_plus_y(a, *o); } 67 void ax_plus_y(const std::complex<double>& a, const RelDFFull& o); 68 void scale(std::complex<double> a); 69 70 RelDFFull& operator+=(const RelDFFull& o) { ax_plus_y(1.0, o); return *this; } 71 RelDFFull& operator-=(const RelDFFull& o) { ax_plus_y(-1.0, o); return *this; } 72 fac()73 std::complex<double> fac() const { assert(basis_.size() == 1); return basis_[0]->fac(cartesian_); } 74 form_aux_2index_real()75 std::shared_ptr<Matrix> form_aux_2index_real() const { 76 std::shared_ptr<Matrix> out = dffull_[0]->form_aux_2index(dffull_[0], 1.0); 77 *out += *dffull_[1]->form_aux_2index(dffull_[1], 1.0); // positive, due to complex conjugate 78 return out; 79 } 80 81 std::shared_ptr<btas::Tensor3<std::complex<double>>> 82 get_block(const int i, const int ii, const int j, const int jj, const int k, const int kk) const; 83 84 std::list<std::shared_ptr<RelDFHalfB>> back_transform(std::array<std::shared_ptr<const Matrix>,4>, 85 std::array<std::shared_ptr<const Matrix>,4>) const; 86 std::shared_ptr<ZMatrix> form_4index(std::shared_ptr<const RelDFFull>, const double fac) const; 87 std::shared_ptr<ZMatrix> form_2index(std::shared_ptr<const RelDFFull>, const double fac, const bool conjugate_left = true) const; 88 std::shared_ptr<ZMatrix> form_4index_1fixed(std::shared_ptr<const RelDFFull>, const double fac, const int i) const; 89 90 std::shared_ptr<RelDFFull> apply_2rdm(std::shared_ptr<const ZRDM<2>>) const; 91 std::shared_ptr<RelDFFull> apply_2rdm(std::shared_ptr<const ZMatrix>) const; 92 93 }; 94 95 96 class ListRelDFFull { 97 protected: 98 std::list<std::shared_ptr<RelDFFull>> data_; 99 public: ListRelDFFull()100 ListRelDFFull() { } ListRelDFFull(std::list<std::shared_ptr<RelDFFull>> o)101 ListRelDFFull(std::list<std::shared_ptr<RelDFFull>> o) : data_(o) { } 102 begin()103 std::list<std::shared_ptr<RelDFFull>>::iterator begin() { return data_.begin(); } end()104 std::list<std::shared_ptr<RelDFFull>>::iterator end() { return data_.end(); } begin()105 std::list<std::shared_ptr<RelDFFull>>::const_iterator begin() const { return data_.cbegin(); } end()106 std::list<std::shared_ptr<RelDFFull>>::const_iterator end() const { return data_.cend(); } 107 push_back(std::shared_ptr<RelDFFull> a)108 void push_back(std::shared_ptr<RelDFFull> a) { data_.push_back(a); } 109 data()110 std::list<std::shared_ptr<RelDFFull>> data() const { return data_; } 111 nocc1()112 int nocc1() const { assert(!data_.empty()); return data_.front()->nocc1(); } nocc2()113 int nocc2() const { assert(!data_.empty()); return data_.front()->nocc2(); } 114 115 void ax_plus_y(const std::complex<double>& a, std::shared_ptr<const ListRelDFFull> o); 116 117 std::shared_ptr<ListRelDFFull> copy() const; 118 std::shared_ptr<ListRelDFFull> clone() const; 119 std::shared_ptr<ListRelDFFull> swap() const; 120 std::shared_ptr<ListRelDFFull> apply_2rdm(std::shared_ptr<const ZRDM<2>>) const; 121 std::shared_ptr<ListRelDFFull> apply_2rdm(std::shared_ptr<const ZMatrix>) const; 122 123 std::shared_ptr<ZMatrix> form_4index(std::shared_ptr<const ListRelDFFull> o, const double fac) const; 124 std::shared_ptr<ZMatrix> form_4index_1fixed(std::shared_ptr<const ListRelDFFull> o, const double fac, const int i) const; 125 std::shared_ptr<ZMatrix> form_2index(std::shared_ptr<const ListRelDFFull> o, const double fac, const bool conjugate_left = true) const; 126 }; 127 128 } 129 130 #endif 131