Skip to content

Commit 454e1bb

Browse files
author
XuhuaHuang
committed
Reformat basics.hpp
1 parent 466e1cd commit 454e1bb

1 file changed

Lines changed: 21 additions & 21 deletions

File tree

Util/math/basics.hpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,46 +24,46 @@ namespace math {
2424
template <typename T>
2525
[[nodiscard]]
2626
inline T mean(const auto& data)
27-
requires std::ranges::range<decltype(data)>
27+
requires std::ranges::range<decltype(data)>
2828
{
29-
return std::accumulate(std::begin(data), std::end(data), static_cast<T>(0)) / data.size();
29+
return std::accumulate(std::begin(data), std::end(data), static_cast<T>(0)) / data.size();
3030
}
3131

3232
template <typename T>
3333
[[nodiscard]]
3434
inline T std_deviation(const auto& data) {
35-
T mean = std::accumulate(std::begin(data), std::end(data), static_cast<T>(0)) / data.size();
36-
T sq_sum = std::inner_product(data.begin(), data.end(), data.begin(), static_cast<T>(0));
37-
T std_dev = std::sqrt(sq_sum / data.size() - static_cast<T>(mean * mean));
38-
return std_dev;
35+
T mean = std::accumulate(std::begin(data), std::end(data), static_cast<T>(0)) / data.size();
36+
T sq_sum = std::inner_product(data.begin(), data.end(), data.begin(), static_cast<T>(0));
37+
T std_dev = std::sqrt(sq_sum / data.size() - static_cast<T>(mean * mean));
38+
return std_dev;
3939
}
4040

4141
template <typename Iterable>
4242
bool any(Iterable&& iterable) {
43-
return std::any_of(std::begin(iterable), std::end(iterable), [](const auto& x) { return static_cast<bool>(x); });
43+
return std::any_of(std::begin(iterable), std::end(iterable), [](const auto& x) { return static_cast<bool>(x); });
4444
}
4545

4646
template <typename InputIt, typename UnaryPredicate>
4747
bool any(InputIt first, InputIt last, UnaryPredicate pred) {
48-
for (; first != last; ++first) {
49-
if (pred(*first)) {
50-
return true;
51-
}
48+
for (; first != last; ++first) {
49+
if (pred(*first)) {
50+
return true;
5251
}
53-
return false;
52+
}
53+
return false;
5454
}
5555

5656
bool all(const auto& data) {
57-
bool true_so_far = true;
58-
for (const auto& d : data) {
59-
true_so_far = d && true;
60-
if (!true_so_far) [[likely]] {
61-
return false;
62-
} else {
63-
continue;
64-
}
57+
bool true_so_far = true;
58+
for (const auto& d : data) {
59+
true_so_far = d && true;
60+
if (!true_so_far) [[likely]] {
61+
return false;
62+
} else {
63+
continue;
6564
}
66-
return true_so_far;
65+
}
66+
return true_so_far;
6767
}
6868

6969
} // namespace math

0 commit comments

Comments
 (0)