LIBINT 2.9.0
dgarc.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 <rr.h>
22#include <smart_ptr.h>
23
24#include <iostream>
25
26#ifndef _libint2_src_bin_libint_dgarc_h_
27#define _libint2_src_bin_libint_dgarc_h_
28
29namespace libint2 {
30
31class RecurrenceRelation;
32class DGVertex;
35class DGArc {
36 std::shared_ptr<DGVertex> orig_; // Where this Arc leavs
37 std::shared_ptr<DGVertex> dest_; // Where this Arc leads to
38
39 public:
40 DGArc(const std::shared_ptr<DGVertex>& orig,
41 const std::shared_ptr<DGVertex>& dest);
42 virtual ~DGArc() {}
43
44 std::shared_ptr<DGVertex> orig() const { return orig_; }
45 std::shared_ptr<DGVertex> dest() const { return dest_; }
46
48 virtual void print(std::ostream& os) const = 0;
49};
50
53class DGArcDirect : public DGArc {
54 public:
55 DGArcDirect(const std::shared_ptr<DGVertex>& orig,
56 const std::shared_ptr<DGVertex>& dest)
57 : DGArc(orig, dest) {}
58 virtual ~DGArcDirect() {}
59
61 void print(std::ostream& os) const override {
62 os << "DGArcDirect: connects " << orig().get() << " to " << dest().get();
63 }
64};
65
68class DGArcRR : public DGArc {
69 public:
70 virtual ~DGArcRR() {}
71
73 virtual std::shared_ptr<RecurrenceRelation> rr() const = 0;
74
75 protected:
76 DGArcRR(const std::shared_ptr<DGVertex>& orig,
77 const std::shared_ptr<DGVertex>& dest);
78};
79
82// NOTE TO SELF (11/24/2004): need to implement checks on ArcRel
83// It obviously must implement some functions
84template <class ArcRel>
85class DGArcRel : public DGArcRR {
86 std::shared_ptr<ArcRel> rel_; // Relationship described by the arc
87
88 public:
89 DGArcRel(const std::shared_ptr<DGVertex>& orig,
90 const std::shared_ptr<DGVertex>& dest,
91 const std::shared_ptr<ArcRel>& rel);
92 virtual ~DGArcRel();
93
95 std::shared_ptr<RecurrenceRelation> rr() const override {
96 return std::dynamic_pointer_cast<RecurrenceRelation, ArcRel>(rel_);
97 }
99 void print(std::ostream& os) const override {
100 os << "DGArcRel<T>: connects " << orig().get() << " to " << dest().get()
101 << std::endl;
102 }
103};
104
105template <class ArcRel>
106DGArcRel<ArcRel>::DGArcRel(const std::shared_ptr<DGVertex>& orig,
107 const std::shared_ptr<DGVertex>& dest,
108 const std::shared_ptr<ArcRel>& rel)
109 : DGArcRR(orig, dest), rel_(rel){};
110
111template <class ArcRel>
112DGArcRel<ArcRel>::~DGArcRel(){};
113
114}; // namespace libint2
115
116#endif
Class DGArcDirect describes arcs that does not correspond to any relationship.
Definition dgarc.h:53
void print(std::ostream &os) const override
Overload of DGArc::print()
Definition dgarc.h:61
Class DGArcRR describes arcs correspond to recurrence relations.
Definition dgarc.h:68
virtual std::shared_ptr< RecurrenceRelation > rr() const =0
rr() returns pointer to the RecurrenceRelation describing the arc
Class DGArcRel describes arcs in a directed graph which is represented by a relationship ArcRel.
Definition dgarc.h:85
std::shared_ptr< RecurrenceRelation > rr() const override
Implementation of DGArcRR::rr()
Definition dgarc.h:95
void print(std::ostream &os) const override
Overload of DGArc::print()
Definition dgarc.h:99
Class DGArc describes arcs in a directed graph.
Definition dgarc.h:35
virtual void print(std::ostream &os) const =0
Print out the arc.
Defaults definitions for various parameters assumed by Libint.
Definition algebra.cc:24