numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
adc_group.h
Go to the documentation of this file.
1/*
2 * Copyright 2025 MusicScience37 (Kenta Kabashima)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
20#pragma once
21
22#include <queue>
23#include <utility>
24#include <vector>
25
29
31
39template <base::concepts::real_scalar Value, typename TernaryVector>
40class adc_group {
41public:
43 using value_type = Value;
44
47
54
60 void push(rectangle_type rect) { rects_.push(std::move(rect)); }
61
68 [[nodiscard]] auto min_rect() const -> const rectangle_type& {
70 return rects_.top();
71 }
72
78 [[nodiscard]] auto empty() const -> bool { return rects_.empty(); }
79
86 [[nodiscard]] auto pop() -> rectangle_type {
88 auto rect = std::move(rects_.top());
89 rects_.pop();
90 return rect;
91 }
92
99 [[nodiscard]] auto is_dividable() const -> bool {
100 if (rects_.empty()) {
101 return false;
102 }
103 const auto& rect = rects_.top();
104 return !rect.vertex().is_full();
105 }
106
112 [[nodiscard]] auto dist() const -> const value_type& { return dist_; }
113
114private:
118 struct greater {
126 [[nodiscard]] auto operator()(const rectangle_type& left,
127 const rectangle_type& right) const -> bool {
128 return left.ave_value() > right.ave_value();
129 }
130 };
131
133 using queue_type = std::priority_queue<rectangle_type,
134 std::vector<rectangle_type>, greater>;
135
138
141};
142
143} // namespace num_collect::opt::impl
Definition of adc_rectangle class.
Definition of assertion macros.
#define NUM_COLLECT_DEBUG_ASSERT(CONDITION)
Macro to check whether a condition is satisfied in debug build only.
Definition assert.h:75
auto is_dividable() const -> bool
Check whether the hyper-rectangle in this group can be divided.
Definition adc_group.h:99
adc_rectangle< value_type, ternary_vector_type > rectangle_type
Definition adc_group.h:46
auto pop() -> rectangle_type
Pick out the hyper-rectangle with the smallest average of function values at diagonal vertices.
Definition adc_group.h:86
auto min_rect() const -> const rectangle_type &
Access the hyper-rectangle with the smallest average of function values at diagonal vertices.
Definition adc_group.h:68
adc_group(value_type dist)
Constructor.
Definition adc_group.h:53
auto empty() const -> bool
Check whether this group is empty.
Definition adc_group.h:78
void push(rectangle_type rect)
Add a hyper-rectangle to this group.
Definition adc_group.h:60
std::priority_queue< rectangle_type, std::vector< rectangle_type >, greater > queue_type
Definition adc_group.h:133
Class of rectangles as proposed in sergeyev2000 for num_collect::opt::adaptive_diagonal_curves.
Namespace of internal implementations.
Definition adc_group.h:30
Definition of real_scalar concept.
Class to compare rectangles.
Definition adc_group.h:118
auto operator()(const rectangle_type &left, const rectangle_type &right) const -> bool
Compare rectangles.
Definition adc_group.h:126