GCC Code Coverage Report


Directory: Bembel/src/
File: Bembel/src/H2Matrix/TreeLeaf.hpp
Date: 2024-09-30 07:01:38
Exec Total Coverage
Lines: 24 24 100.0%
Functions: 12 12 100.0%
Branches: 5 10 50.0%

Line Branch Exec Source
1 // This file is part of Bembel, the higher order C++ boundary element library.
2 //
3 // Copyright (C) 2022 see <http://www.bembel.eu>
4 //
5 // It was written as part of a cooperation of J. Doelz, H. Harbrecht, S. Kurz,
6 // M. Multerer, S. Schoeps, and F. Wolf at Technische Universitaet Darmstadt,
7 // Universitaet Basel, and Universita della Svizzera italiana, Lugano. This
8 // source code is subject to the GNU General Public License version 3 and
9 // provided WITHOUT ANY WARRANTY, see <http://www.bembel.eu> for further
10 // information.
11 //
12 #ifndef BEMBEL_SRC_H2MATRIX_TREELEAF_HPP_
13 #define BEMBEL_SRC_H2MATRIX_TREELEAF_HPP_
14
15 namespace Bembel {
16 /**
17 * \brief This class is managing the leafs of the H2Matrix BlockClusterTree.
18 */
19 template <typename Derived>
20 class TreeLeaf {
21 public:
22 //////////////////////////////////////////////////////////////////////////////
23 // Constructors
24 //////////////////////////////////////////////////////////////////////////////
25 /**
26 * \brief void constructor
27 **/
28 7488 TreeLeaf(void)
29
1/2
✓ Branch 1 taken 7488 times.
✗ Branch 2 not taken.
7488 : F_(Derived(0, 0)),
30
1/2
✓ Branch 1 taken 7488 times.
✗ Branch 2 not taken.
7488 L_(Derived(0, 0)),
31
1/2
✓ Branch 1 taken 7488 times.
✗ Branch 2 not taken.
7488 R_(Derived(0, 0)),
32 7488 is_low_rank_(false) {}
33 /**
34 * \brief copy constructor
35 **/
36 4608 TreeLeaf(const TreeLeaf &other)
37 4608 : F_(other.F_),
38
1/2
✓ Branch 1 taken 4608 times.
✗ Branch 2 not taken.
4608 L_(other.L_),
39
1/2
✓ Branch 1 taken 4608 times.
✗ Branch 2 not taken.
4608 R_(other.R_),
40 4608 is_low_rank_(other.is_low_rank_) {}
41 /**
42 * \brief move constructor
43 **/
44 TreeLeaf(TreeLeaf &&other)
45 : F_(std::move(other.F_)),
46 L_(std::move(other.L_)),
47 R_(std::move(other.R_)),
48 is_low_rank_(other.is_low_rank_) {}
49 /**
50 * \brief lowRank constructor
51 * whatever Eigen object is put in here will be evaluated
52 */
53 template <typename otherDerived>
54 TreeLeaf(const Eigen::MatrixBase<otherDerived> &L,
55 const Eigen::MatrixBase<otherDerived> &R)
56 : F_(Derived(0, 0)), L_(L), R_(R), is_low_rank_(true) {}
57 /**
58 * \brief full constructor
59 * whatever Eigen object is put in here will be evaluated
60 **/
61 template <typename otherDerived>
62 explicit TreeLeaf(const Eigen::MatrixBase<otherDerived> &F)
63 : F_(F), L_(Derived(0, 0)), R_(Derived(0, 0)), is_low_rank_(false) {}
64 /**
65 * \brief lowRank move constructor
66 **/
67 TreeLeaf(Derived &&L, Derived &&R)
68 : F_(Derived(0, 0)), L_(L), R_(R), is_low_rank_(true) {}
69 /**
70 * \brief full move constructor
71 **/
72 explicit TreeLeaf(Derived &&F)
73 : F_(F), L_(Derived(0, 0)), R_(Derived(0, 0)), is_low_rank_(false) {}
74 //////////////////////////////////////////////////////////////////////////////
75 // getter
76 //////////////////////////////////////////////////////////////////////////////
77 bool is_low_rank() { return is_low_rank_; }
78 Eigen::Matrix<typename Derived::Scalar, Eigen::Dynamic, Eigen::Dynamic>
79 445824 &get_F() {
80 445824 return F_;
81 }
82 Eigen::Matrix<typename Derived::Scalar, Eigen::Dynamic, Eigen::Dynamic>
83 &get_L() {
84 return L_;
85 }
86 Eigen::Matrix<typename Derived::Scalar, Eigen::Dynamic, Eigen::Dynamic>
87 &get_R() {
88 return R_;
89 }
90 const Eigen::Matrix<typename Derived::Scalar, Eigen::Dynamic, Eigen::Dynamic>
91 &get_F() const {
92 return F_;
93 }
94 const Eigen::Matrix<typename Derived::Scalar, Eigen::Dynamic, Eigen::Dynamic>
95 &get_L() const {
96 return L_;
97 }
98 Eigen::Matrix<typename Derived::Scalar, Eigen::Dynamic, Eigen::Dynamic>
99 &get_R() const {
100 return R_;
101 }
102 //////////////////////////////////////////////////////////////////////////////
103 // setter
104 //////////////////////////////////////////////////////////////////////////////
105 1632 void set_low_rank_flag(bool flag) {
106 1632 is_low_rank_ = flag;
107 1632 return;
108 }
109 4608 void set_F(const Eigen::Matrix<typename Derived::Scalar, Eigen::Dynamic,
110 Eigen::Dynamic> &F) {
111 4608 F_ = F;
112 4608 }
113 void set_L(const Eigen::Matrix<typename Derived::Scalar, Eigen::Dynamic,
114 Eigen::Dynamic> &L) {
115 L_ = L;
116 }
117 void set_R(const Eigen::Matrix<typename Derived::Scalar, Eigen::Dynamic,
118 Eigen::Dynamic> &R) {
119 R_ = R;
120 }
121 //////////////////////////////////////////////////////////////////////////////
122 // Operators
123 //////////////////////////////////////////////////////////////////////////////
124 /**
125 * \brief assignment operator, works for copy and move assignment
126 **/
127 4608 TreeLeaf &operator=(TreeLeaf other) {
128 4608 F_.swap(other.F_);
129 4608 L_.swap(other.L_);
130 4608 R_.swap(other.R_);
131 4608 std::swap(is_low_rank_, other.is_low_rank_);
132 4608 return *this;
133 }
134
135 //////////////////////////////////////////////////////////////////////////////
136 /// private members
137 //////////////////////////////////////////////////////////////////////////////
138 private:
139 // independently how the leave is instatiated, it will always be casted to
140 // an actual matrix
141 Eigen::Matrix<typename Derived::Scalar, Eigen::Dynamic, Eigen::Dynamic> F_,
142 L_, R_;
143 bool is_low_rank_;
144 };
145 } // namespace Bembel
146 #endif // BEMBEL_SRC_H2MATRIX_TREELEAF_HPP_
147