LIBINT 2.9.0
intset_to_ints.h
1/*
2 * Copyright (C) 2004-2024 Edward F. Valeev
3 *
4 * This file is part of Libint compiler.
5 *
6 * Libint compiler is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * Libint compiler 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 * You should have received a copy of the GNU General Public License
17 * along with Libint compiler. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21#include <algebra.h>
22#include <integral.h>
23#include <iter.h>
24#include <rr.h>
25
26#include <cassert>
27#include <iostream>
28#include <stdexcept>
29#include <string>
30#include <vector>
31
32#ifndef _libint2_src_bin_libint_intsettoints_h_
33#define _libint2_src_bin_libint_intsettoints_h_
34
35namespace libint2 {
36
40 protected:
42};
43
48template <class I>
51 public:
52 typedef I TargetType;
53 typedef typename I::iter_type ChildType;
56
57 IntegralSet_to_Integrals(const std::shared_ptr<I>&);
58 virtual ~IntegralSet_to_Integrals() {}
59
61 static std::shared_ptr<IntegralSet_to_Integrals<I>> Instance(
62 const std::shared_ptr<TargetType>& Tint, unsigned int dir) {
63 assert(dir == 0);
64 // attempt to construct
65 std::shared_ptr<IntegralSet_to_Integrals<I>> this_ptr(
67 // if succeeded (nchildren > 0) do post-construction
68 assert(this_ptr->num_children() != 0);
69 return this_ptr;
70 }
71 static bool directional() { return false; }
72
74 unsigned int num_children() const override { return children_.size(); }
76 std::shared_ptr<TargetType> target() const { return target_; };
78 std::shared_ptr<ChildType> child(unsigned int i) const;
80 std::shared_ptr<DGVertex> rr_target() const override {
81 return std::static_pointer_cast<DGVertex, TargetType>(target());
82 }
84 std::shared_ptr<DGVertex> rr_child(unsigned int i) const override {
85 return std::static_pointer_cast<DGVertex, ChildType>(child(i));
86 }
88 bool is_simple() const override { return true; }
90 bool invariant_type() const override {
91 // Converts from one BFSet to another!
92 return false;
93 }
94
95 private:
96 std::shared_ptr<TargetType> target_;
97 std::vector<std::shared_ptr<ChildType>> children_;
98
100 std::string generate_label() const override {
101 return "IntegralSet_to_Integrals";
102 // throw std::runtime_error("IntegralSet_to_Integrals::label() -- code for
103 // this RR is never generated, so this function should never be used");
104 }
106 std::string spfunction_call(
107 const std::shared_ptr<CodeContext>& context,
108 const std::shared_ptr<ImplicitDimensions>& dims) const override {
109 throw std::logic_error(
110 "IntegralSet_to_Integrals::spfunction_call -- should not call this "
111 "function");
112 }
113};
114
115template <class I>
116IntegralSet_to_Integrals<I>::IntegralSet_to_Integrals(
117 const std::shared_ptr<I>& Tint)
118 : target_(Tint) {
119 target_ = Tint;
120
121 // Construct a subiterator for I
122 SubIteratorBase<I> siter(Tint);
123
124 // Set children pointers
125 for (siter.init(); siter; ++siter) children_.push_back(siter.elem());
126};
127
128template <class I>
129std::shared_ptr<typename I::iter_type> IntegralSet_to_Integrals<I>::child(
130 unsigned int i) const {
131 return children_.at(i);
132};
133
134}; // namespace libint2
135
136#endif
AlgebraicOperator is an algebraic operator that acts on objects of type T.
Definition algebra.h:47
IntegralSet_to_Integrals_base is dummy class used for dynamic casts only.
Definition intset_to_ints.h:39
IntegralSet_to_Integrals converts I, a set of integrals, to individual integrals.
Definition intset_to_ints.h:50
std::shared_ptr< DGVertex > rr_target() const override
Implementation of RecurrenceRelation's target()
Definition intset_to_ints.h:80
bool is_simple() const override
Implementation of RecurrenceRelation::is_simple()
Definition intset_to_ints.h:88
static std::shared_ptr< IntegralSet_to_Integrals< I > > Instance(const std::shared_ptr< TargetType > &Tint, unsigned int dir)
Return an instance if applicable, or a null pointer otherwise.
Definition intset_to_ints.h:61
std::shared_ptr< TargetType > target() const
target() returns pointer to target
Definition intset_to_ints.h:76
std::shared_ptr< ChildType > child(unsigned int i) const
child(i) returns pointer i-th child
Definition intset_to_ints.h:129
RecurrenceRelation::ExprType ExprType
The type of expressions in which RecurrenceRelations result.
Definition intset_to_ints.h:55
std::shared_ptr< DGVertex > rr_child(unsigned int i) const override
Implementation of RecurrenceRelation's child()
Definition intset_to_ints.h:84
bool invariant_type() const override
Reimplementation of RecurrenceRelation::invariant_type()
Definition intset_to_ints.h:90
unsigned int num_children() const override
Implementation of RecurrenceRelation::num_children()
Definition intset_to_ints.h:74
RecurrenceRelation describes all recurrence relations.
Definition rr.h:97
Defaults definitions for various parameters assumed by Libint.
Definition algebra.cc:24