kyopro-lib

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

View on GitHub

:warning: Array monoid
(Mylib/AlgebraicStructure/Monoid/array.cpp)

Operations

Requirements

Notes

Problems

References

Code

#pragma once
#include <array>

namespace haar_lib {
  template <typename Monoid, int B>
  struct array_monoid {
    using value_type = std::array<typename Monoid::value_type, B>;
    const static Monoid M;

    value_type operator()() const {
      value_type ret;
      ret.fill(M());
      return ret;
    }

    value_type operator()(const value_type &a, const value_type &b) const {
      value_type ret;
      for (int i = 0; i < B; ++i) ret[i] = M(a[i], b[i]);
      return ret;
    }
  };
}  // namespace haar_lib
#line 2 "Mylib/AlgebraicStructure/Monoid/array.cpp"
#include <array>

namespace haar_lib {
  template <typename Monoid, int B>
  struct array_monoid {
    using value_type = std::array<typename Monoid::value_type, B>;
    const static Monoid M;

    value_type operator()() const {
      value_type ret;
      ret.fill(M());
      return ret;
    }

    value_type operator()(const value_type &a, const value_type &b) const {
      value_type ret;
      for (int i = 0; i < B; ++i) ret[i] = M(a[i], b[i]);
      return ret;
    }
  };
}  // namespace haar_lib
Back to top page