Skip to content

Commit

Permalink
style: partial_sum -> inclusive_scan
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiphereth-A committed Jan 3, 2025
1 parent c5c95be commit ce01166
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/code/graph/alists.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class alists {
CEXP void add_arc(u32 u, Ts&&... args) { b.emplace_back(u, ET{std::forward<Ts>(args)...}), ++h[u]; }
CEXP void build() {
if (cnt_arc) return;
std::partial_sum(h.begin(), h.end(), h.begin());
std::inclusive_scan(h.begin(), h.end(), h.begin());
for (e.resize(cnt_arc = (u32)b.size()); auto CR[u, e] : b) e[--h[u]] = e;
if CEXP (with_deg)
for (auto CR[u, e] : b) ++deg_out[u], ++deg_in[e.to];
Expand Down
2 changes: 1 addition & 1 deletion src/code/graph/sat2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class sat2 {
CEXP void add(u32 x, bool vx, u32 y, bool vy) { x = x * 2 + vx, y = y * 2 + vy, e.emplace_back(x ^ 1, y), e.emplace_back(y ^ 1, x), ++st[x ^ 1], ++st[y ^ 1]; }
// @return a, a_i == 1 if c_i is true else a_i == 0
CEXP std::optional<vecu> solve() {
std::partial_sum(st.begin(), st.end(), st.begin()), *std::move_backward(st.begin(), st.end() - 1, st.end()) = 0;
std::inclusive_scan(st.begin(), st.end(), st.begin()), *std::move_backward(st.begin(), st.end() - 1, st.end()) = 0;
vecu to(e.size());
for (auto CR[u, v] : e) to[st[u]++] = v;
*std::move_backward(st.begin(), st.end() - 1, st.end()) = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/code/util/ndvec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct ndvec : vec<T> {
CEXP void resize(Ts &&...args) {
static_assert(sizeof...(args) == N);
u32 n = 0;
((idxs[n++] = (u32)args), ...), idxs[N] = 1, partial_sum(idxs.rbegin(), idxs.rend(), idxs.rbegin(), std::multiplies<>{}), vec<T>::resize(idxs[0]);
((idxs[n++] = (u32)args), ...), idxs[N] = 1, inclusive_scan(idxs.rbegin(), idxs.rend(), idxs.rbegin(), std::multiplies<>{}), vec<T>::resize(idxs[0]);
}
template <class... Ts>
CEXP T &operator()(Ts &&...args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int main() {
auto _ = tifa_libs::math::lsieve<tifa_libs::math::ls_phi>(tifa_libs::math::isqrt(n)).phi;
sphi.reserve(_.size());
for (auto i : _) sphi.push_back(i);
std::partial_sum(sphi.begin(), sphi.end(), sphi.begin());
std::inclusive_scan(sphi.begin(), sphi.end(), sphi.begin());
}
auto sf = [sphi](u64 x) -> mint { return sphi[x]; };
auto sg = [](u64 x) -> mint { return x; };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int main() {
auto _ = tifa_libs::math::lsieve<tifa_libs::math::ls_phi>(tifa_libs::math::isqrt(n)).phi;
sphi.reserve(_.size());
for (auto i : _) sphi.push_back(i);
std::partial_sum(sphi.begin(), sphi.end(), sphi.begin());
std::inclusive_scan(sphi.begin(), sphi.end(), sphi.begin());
}
auto sf = [sphi](u64 x) -> mint { return sphi[x]; };
auto sg = [](u64 x) -> mint { return x; };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ int main() {
auto _ = tifa_libs::math::lsieve<tifa_libs::math::ls_phi>(tifa_libs::math::isqrt(n)).phi;
sphi.reserve(_.size());
for (auto i : _) sphi.push_back(i);
std::partial_sum(sphi.begin(), sphi.end(), sphi.begin());
std::inclusive_scan(sphi.begin(), sphi.end(), sphi.begin());
}
auto sf = [sphi](u64 x) -> mint { return sphi[x]; };
auto sg = [](u64 x) -> mint { return x; };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ int main() {
auto _ = tifa_libs::math::lsieve<tifa_libs::math::ls_phi>(tifa_libs::math::isqrt(n)).phi;
sphi.reserve(_.size());
for (auto i : _) sphi.push_back(i);
std::partial_sum(sphi.begin(), sphi.end(), sphi.begin());
std::inclusive_scan(sphi.begin(), sphi.end(), sphi.begin());
}
auto sf = [sphi](u64 x) -> mint { return sphi[x]; };
auto sg = [](u64 x) -> mint { return x; };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int main() {
if (e == 1) return lst = p - 1;
else return lst = lst * p;
});
std::partial_sum(sphi.begin(), sphi.end(), sphi.begin());
std::inclusive_scan(sphi.begin(), sphi.end(), sphi.begin());
}
auto sf = [sphi](u64 x) -> mint { return sphi[x]; };
auto sg = [](u64 x) -> mint { return x; };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int main() {
if (e == 1) return lst = p - 1;
else return lst = lst * p;
});
std::partial_sum(sphi.begin(), sphi.end(), sphi.begin());
std::inclusive_scan(sphi.begin(), sphi.end(), sphi.begin());
}
auto sf = [sphi](u64 x) -> mint { return sphi[x]; };
auto sg = [](u64 x) -> mint { return x; };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int main() {
if (e == 1) return lst = p - 1;
else return lst = lst * p;
});
std::partial_sum(sphi.begin(), sphi.end(), sphi.begin());
std::inclusive_scan(sphi.begin(), sphi.end(), sphi.begin());
}
auto sf = [sphi](u64 x) -> mint { return sphi[x]; };
auto sg = [](u64 x) -> mint { return x; };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int main() {
if (e == 1) return lst = p - 1;
else return lst = lst * p;
});
std::partial_sum(sphi.begin(), sphi.end(), sphi.begin());
std::inclusive_scan(sphi.begin(), sphi.end(), sphi.begin());
}
auto sf = [sphi](u64 x) -> mint { return sphi[x]; };
auto sg = [](u64 x) -> mint { return x; };
Expand Down
2 changes: 1 addition & 1 deletion src/test_cpverifier/unit-test/nt/lsieve2.bzoj4407.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void test(strn CR data) {
if (e == 1) return lst = (pk = tifa_libs::math::qpow<mint>(p, k)) - 1;
else return lst *= pk;
});
std::partial_sum(g.begin(), g.end(), g.begin());
std::inclusive_scan(g.begin(), g.end(), g.begin());
flt_ (u32, i, 0, t) {
mint res = 0;
for (u32 n = ns[i], m = ms[i], l = 1, r, d1, d2; l <= n; l = r + 1) {
Expand Down

0 comments on commit ce01166

Please sign in to comment.