Luzhiled's Library

This documentation is automatically generated by competitive-verifier/competitive-verifier

View the Project on GitHub ei1333/library

:heavy_check_mark: structure/class/affine.hpp

Required by

Verified with

Code

template <typename T>
struct Affine {
  T a, b;  // ax+b
  Affine() : a(1), b(0) {}
  Affine(T a, T b) : a(a), b(b) {}
  T eval(T x) const { return a * x + b; }
  static constexpr Affine op(const Affine& l, const Affine& r) {
    return {l.a * r.a, l.b * r.a + r.b};
  }
  constexpr bool operator==(const Affine& p) const {
    return a == p.a and b == p.b;
  }
  constexpr bool operator!=(const Affine& p) const {
    return a != p.a or b != p.b;
  }
};
#line 1 "structure/class/affine.hpp"
template <typename T>
struct Affine {
  T a, b;  // ax+b
  Affine() : a(1), b(0) {}
  Affine(T a, T b) : a(a), b(b) {}
  T eval(T x) const { return a * x + b; }
  static constexpr Affine op(const Affine& l, const Affine& r) {
    return {l.a * r.a, l.b * r.a + r.b};
  }
  constexpr bool operator==(const Affine& p) const {
    return a == p.a and b == p.b;
  }
  constexpr bool operator!=(const Affine& p) const {
    return a != p.a or b != p.b;
  }
};
Back to top page