library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub maspypy/library

:heavy_check_mark: alg/acted_set/affine.hpp

Depends on

Verified with

Code

#include "alg/monoid/affine.hpp"

// 1 次元ベクトル空間に、アフィン変換が作用
template <typename T>
struct ActedSet_Affine {
  using Monoid_A = Monoid_Affine<T>;
  using A = typename Monoid_A::value_type;
  using S = T;
  static S act(const S &x, const A &g) { return g.fi * x + g.se; }
};
#line 2 "alg/monoid/affine.hpp"

// op(F, G) = comp(G,F), F のあとで G
template <typename K>
struct Monoid_Affine {
  using F = pair<K, K>;
  using value_type = F;
  using X = value_type;
  static constexpr F op(const F &x, const F &y) noexcept {
    return F({x.first * y.first, x.second * y.first + y.second});
  }
  static constexpr F inverse(const F &x) {
    auto [a, b] = x;
    a = K(1) / a;
    return {a, a * (-b)};
  }
  static constexpr K eval(const F &f, K x) noexcept {
    return f.first * x + f.second;
  }
  static constexpr F unit() { return {K(1), K(0)}; }
  static constexpr bool commute = false;
};
#line 2 "alg/acted_set/affine.hpp"

// 1 次元ベクトル空間に、アフィン変換が作用
template <typename T>
struct ActedSet_Affine {
  using Monoid_A = Monoid_Affine<T>;
  using A = typename Monoid_A::value_type;
  using S = T;
  static S act(const S &x, const A &g) { return g.fi * x + g.se; }
};
Back to top page