internal/internal_type_traits.hpp
lib/internal/internal_type_traits.hpp
概要
体 (field) であることを表明する opt-in マーカー基底。 四則演算(除算を含む)が閉じ、0/1 を構築でき == で比較できる型が継承する。 整数型・浮動小数点型は構文上は四則演算できても「体である」保証がないため 区別したく、構文ベースの concept では弾けないのでマーカー方式を採る。
インクルード
#include "internal/internal_type_traits.hpp"
内部実装
直接使うことは想定していないが、公開 API の基底として現れる。
| 名前 | 説明 |
|---|---|
field_base |
体 (field) であることを表明する opt-in マーカー基底。 四則演算(除算を含む)が閉じ、0/1 を構築でき == で比較できる型が継承する。 整数型・浮動小数点型は構文上は四則演算できても「体である」保証がないため 区別したく、構文ベースの concept では弾けないのでマーカー方式を採る。 |
field |
体 (field) として扱える型。field_base を継承した型のみが満たす。 modint(素数 mod)や有理数を想定。 |
このヘッダを使うライブラリ(18)
-
ベル数を $B_0$ から $B_n$ まで列挙する
lib/combinatorics/bell.hpp -
二項係数・階乗・順列・多項係数・重複組合せ
lib/combinatorics/combinatorics.hpp -
複数の二項係数部分和 $\sum_{i=0}^{k}\binom{n}{i}$ をまとめて求める
lib/combinatorics/offline_binomial_sum.hpp -
分割数を $p(0)$ から $p(n)$ まで列挙する
lib/combinatorics/partition_function.hpp -
第1種スターリング数(符号付き)s(n, 0), s(n, 1), ..., s(n, n) を求める(行)
lib/combinatorics/stirling.hpp -
第2種スターリング数・ベル数
lib/combinatorics/stirling_bell.hpp -
形式的冪級数 (FPS)
lib/convolution/formal_power_series.hpp -
NTT・畳み込み (convolution)
lib/convolution/ntt.hpp -
Montgomery + AVX2 による NTT 畳み込み (NTT-friendly な 32bit 素数 mod 専用)
lib/convolution/ntt_avx2.hpp -
internal/internal_fft.hpp
lib/internal/internal_fft.hpp -
internal/internal_fft_avx2.hpp
lib/internal/internal_fft_avx2.hpp -
internal/internal_fps_avx2.hpp
lib/internal/internal_fps_avx2.hpp -
Berlekamp-Massey 法
lib/linalg/berlekamp_massey.hpp -
きたまさ法(任意可換環版、$O(k^2 \log n)$)
lib/linalg/linear_recurrence.hpp -
多倍長整数
lib/number_theory/bigint.hpp -
分数ライブラリ
lib/number_theory/fraction.hpp -
modint (static_modint / dynamic_modint)
lib/number_theory/modint.hpp -
素数法上で `x` の平方根を 1 つ返す
lib/number_theory/root_mod.hpp
検証プログラム(71)
-
test/aoj/alds1/kitamasa.test.cpp
test/aoj/alds1/kitamasa.test.cpp -
test/aoj/challenge/0264.test.cpp
test/aoj/challenge/0264.test.cpp -
test/aoj/challenge/2863.test.cpp
test/aoj/challenge/2863.test.cpp -
test/aoj/dpl/bell.test.cpp
test/aoj/dpl/bell.test.cpp -
test/aoj/dpl/stirling.test.cpp
test/aoj/dpl/stirling.test.cpp -
test/aoj/ntl/addition.test.cpp
test/aoj/ntl/addition.test.cpp -
test/aoj/ntl/difference.test.cpp
test/aoj/ntl/difference.test.cpp -
test/aoj/ntl/division.test.cpp
test/aoj/ntl/division.test.cpp -
test/aoj/ntl/multiplication.test.cpp
test/aoj/ntl/multiplication.test.cpp -
test/aoj/ntl/multiplication2.test.cpp
test/aoj/ntl/multiplication2.test.cpp -
test/aoj/ntl/power.test.cpp
test/aoj/ntl/power.test.cpp -
test/aoj/ntl/remainder.test.cpp
test/aoj/ntl/remainder.test.cpp -
test/yosupo/big_integer/addition_of_big_integers.test.cpp
test/yosupo/big_integer/addition_of_big_integers.test.cpp -
test/yosupo/big_integer/division_of_big_integers.test.cpp
test/yosupo/big_integer/division_of_big_integers.test.cpp -
test/yosupo/big_integer/multiplication_of_big_integers.test.cpp
test/yosupo/big_integer/multiplication_of_big_integers.test.cpp -
test/yosupo/convolution/bitwise_and_convolution.test.cpp
test/yosupo/convolution/bitwise_and_convolution.test.cpp -
test/yosupo/convolution/bitwise_xor_convolution.test.cpp
test/yosupo/convolution/bitwise_xor_convolution.test.cpp -
test/yosupo/convolution/convolution.test.cpp
test/yosupo/convolution/convolution.test.cpp -
test/yosupo/convolution/convolution_mod.test.cpp
test/yosupo/convolution/convolution_mod.test.cpp -
test/yosupo/convolution/gcd_convolution.test.cpp
test/yosupo/convolution/gcd_convolution.test.cpp -
test/yosupo/convolution/lcm_convolution.test.cpp
test/yosupo/convolution/lcm_convolution.test.cpp -
test/yosupo/data_structure/dynamic_sequence_range_affine_range_sum.test.cpp
test/yosupo/data_structure/dynamic_sequence_range_affine_range_sum.test.cpp -
test/yosupo/data_structure/persistent_range_affine_range_sum.test.cpp
test/yosupo/data_structure/persistent_range_affine_range_sum.test.cpp -
test/yosupo/data_structure/point_set_range_composite.test.cpp
test/yosupo/data_structure/point_set_range_composite.test.cpp -
test/yosupo/data_structure/point_set_range_composite_large_array.test.cpp
test/yosupo/data_structure/point_set_range_composite_large_array.test.cpp -
test/yosupo/data_structure/queue_operate_all_composite.test.cpp
test/yosupo/data_structure/queue_operate_all_composite.test.cpp -
test/yosupo/data_structure/range_affine_range_sum.test.cpp
test/yosupo/data_structure/range_affine_range_sum.test.cpp -
test/yosupo/data_structure/range_affine_range_sum_large_array.test.cpp
test/yosupo/data_structure/range_affine_range_sum_large_array.test.cpp -
test/yosupo/data_structure/unionfind_with_potential.test.cpp
test/yosupo/data_structure/unionfind_with_potential.test.cpp -
test/yosupo/data_structure/unionfind_with_potential_non_commutative_group.test.cpp
test/yosupo/data_structure/unionfind_with_potential_non_commutative_group.test.cpp -
test/yosupo/enumerative_conbinatorics/bell_number.test.cpp
test/yosupo/enumerative_conbinatorics/bell_number.test.cpp -
test/yosupo/enumerative_conbinatorics/partition_function.test.cpp
test/yosupo/enumerative_conbinatorics/partition_function.test.cpp -
test/yosupo/enumerative_conbinatorics/stirling_number_of_the_first_kind.test.cpp
test/yosupo/enumerative_conbinatorics/stirling_number_of_the_first_kind.test.cpp -
test/yosupo/enumerative_conbinatorics/stirling_number_of_the_first_kind_fixed_k.test.cpp
test/yosupo/enumerative_conbinatorics/stirling_number_of_the_first_kind_fixed_k.test.cpp -
test/yosupo/enumerative_conbinatorics/stirling_number_of_the_second_kind.test.cpp
test/yosupo/enumerative_conbinatorics/stirling_number_of_the_second_kind.test.cpp -
test/yosupo/enumerative_conbinatorics/stirling_number_of_the_second_kind_fixed_k.test.cpp
test/yosupo/enumerative_conbinatorics/stirling_number_of_the_second_kind_fixed_k.test.cpp -
test/yosupo/math/bostan_mori.test.cpp
test/yosupo/math/bostan_mori.test.cpp -
test/yosupo/math/find_linear_recurrence.test.cpp
test/yosupo/math/find_linear_recurrence.test.cpp -
test/yosupo/math/kth_root_mod.test.cpp
test/yosupo/math/kth_root_mod.test.cpp -
test/yosupo/math/number_of_subsequences.test.cpp
test/yosupo/math/number_of_subsequences.test.cpp -
test/yosupo/math/sqrt_mod.test.cpp
test/yosupo/math/sqrt_mod.test.cpp -
test/yosupo/matrix/determinant_of_matrix.test.cpp
test/yosupo/matrix/determinant_of_matrix.test.cpp -
test/yosupo/matrix/matrix_product.test.cpp
test/yosupo/matrix/matrix_product.test.cpp -
test/yosupo/number_theory/discrete_logarithm_mod.test.cpp
test/yosupo/number_theory/discrete_logarithm_mod.test.cpp -
test/yosupo/number_theory/sum_of_multiplicative_function.test.cpp
test/yosupo/number_theory/sum_of_multiplicative_function.test.cpp -
test/yosupo/number_theory/sum_of_multiplicative_function_large.test.cpp
test/yosupo/number_theory/sum_of_multiplicative_function_large.test.cpp -
test/yosupo/number_theory/sum_of_totient_function.test.cpp
test/yosupo/number_theory/sum_of_totient_function.test.cpp -
test/yosupo/polynomial/composition_of_formal_power_series.test.cpp
test/yosupo/polynomial/composition_of_formal_power_series.test.cpp -
test/yosupo/polynomial/composition_of_formal_power_series_large.test.cpp
test/yosupo/polynomial/composition_of_formal_power_series_large.test.cpp -
test/yosupo/polynomial/compositional_inverse_of_formal_power_series.test.cpp
test/yosupo/polynomial/compositional_inverse_of_formal_power_series.test.cpp -
test/yosupo/polynomial/compositional_inverse_of_formal_power_series_large.test.cpp
test/yosupo/polynomial/compositional_inverse_of_formal_power_series_large.test.cpp -
test/yosupo/polynomial/division_of_polynomials.test.cpp
test/yosupo/polynomial/division_of_polynomials.test.cpp -
test/yosupo/polynomial/exp_of_formal_power_series.test.cpp
test/yosupo/polynomial/exp_of_formal_power_series.test.cpp -
test/yosupo/polynomial/inv_of_formal_power_series.test.cpp
test/yosupo/polynomial/inv_of_formal_power_series.test.cpp -
test/yosupo/polynomial/inv_of_polynomials.test.cpp
test/yosupo/polynomial/inv_of_polynomials.test.cpp -
test/yosupo/polynomial/log_of_formal_power_series.test.cpp
test/yosupo/polynomial/log_of_formal_power_series.test.cpp -
test/yosupo/polynomial/multipoint_evaluation.test.cpp
test/yosupo/polynomial/multipoint_evaluation.test.cpp -
test/yosupo/polynomial/polynomial_interpolation.test.cpp
test/yosupo/polynomial/polynomial_interpolation.test.cpp -
test/yosupo/polynomial/polynomial_taylor_shift.test.cpp
test/yosupo/polynomial/polynomial_taylor_shift.test.cpp -
test/yosupo/polynomial/pow_of_formal_power_series.test.cpp
test/yosupo/polynomial/pow_of_formal_power_series.test.cpp -
test/yosupo/polynomial/product_of_polynomial_sequence.test.cpp
test/yosupo/polynomial/product_of_polynomial_sequence.test.cpp -
test/yosupo/polynomial/shift_of_sampling_points_of_polynomial.test.cpp
test/yosupo/polynomial/shift_of_sampling_points_of_polynomial.test.cpp -
test/yosupo/polynomial/sqrt_of_formal_power_series.test.cpp
test/yosupo/polynomial/sqrt_of_formal_power_series.test.cpp -
test/yosupo/set_power_series/subset_convolution.test.cpp
test/yosupo/set_power_series/subset_convolution.test.cpp -
test/yosupo/tree/point_set_tree_path_composite_sum.test.cpp
test/yosupo/tree/point_set_tree_path_composite_sum.test.cpp -
test/yosupo/tree/point_set_tree_path_composite_sum_fixed_root.test.cpp
test/yosupo/tree/point_set_tree_path_composite_sum_fixed_root.test.cpp -
test/yosupo/tree/tree_path_composite_sum.test.cpp
test/yosupo/tree/tree_path_composite_sum.test.cpp -
test/yosupo/tree/vertex_set_path_composite.test.cpp
test/yosupo/tree/vertex_set_path_composite.test.cpp -
test/yukicoder/0551.test.cpp
test/yukicoder/0551.test.cpp -
test/yukicoder/2206.test.cpp
test/yukicoder/2206.test.cpp -
test/yukicoder/3354.test.cpp
test/yukicoder/3354.test.cpp
実装
#pragma once
#include <cassert>
#include <concepts>
#include <numeric>
#include <type_traits>
namespace internal {
/// 体 (field) であることを表明する opt-in マーカー基底。
/// 四則演算(除算を含む)が閉じ、`0`/`1` を構築でき `==` で比較できる型が継承する。
/// 整数型・浮動小数点型は構文上は四則演算できても「体である」保証がないため
/// 区別したく、構文ベースの concept では弾けないのでマーカー方式を採る。
struct field_base {};
/// 体 (field) として扱える型。`field_base` を継承した型のみが満たす。
/// modint(素数 mod)や有理数を想定。
template <class T>
concept field = std::is_base_of_v<field_base, T>;
template <class T>
using is_signed_int128 =
typename std::conditional<std::is_same<T, __int128_t>::value || std::is_same<T, __int128>::value, std::true_type,
std::false_type>::type;
template <class T>
using is_unsigned_int128 =
typename std::conditional<std::is_same<T, __uint128_t>::value || std::is_same<T, unsigned __int128>::value,
std::true_type, std::false_type>::type;
template <class T>
using make_unsigned_int128 =
typename std::conditional<std::is_same<T, __int128_t>::value, __uint128_t, unsigned __int128>;
template <class T>
using is_integral =
typename std::conditional<std::is_integral<T>::value || is_signed_int128<T>::value || is_unsigned_int128<T>::value,
std::true_type, std::false_type>::type;
template <class T>
using is_signed_int =
typename std::conditional<(is_integral<T>::value && std::is_signed<T>::value) || is_signed_int128<T>::value,
std::true_type, std::false_type>::type;
template <class T>
using is_unsigned_int =
typename std::conditional<(is_integral<T>::value && std::is_unsigned<T>::value) || is_unsigned_int128<T>::value,
std::true_type, std::false_type>::type;
template <class T>
using to_unsigned = typename std::conditional<
is_signed_int128<T>::value, make_unsigned_int128<T>,
typename std::conditional<std::is_signed<T>::value, std::make_unsigned<T>, std::common_type<T>>::type>::type;
template <class T>
using is_signed_int_t = std::enable_if_t<is_signed_int<T>::value>;
template <class T>
using is_unsigned_int_t = std::enable_if_t<is_unsigned_int<T>::value>;
template <class T>
using to_unsigned_t = typename to_unsigned<T>::type;
} // namespace internal
bundled
#line 2 "lib/internal/internal_type_traits.hpp"
#include <cassert>
#include <concepts>
#include <numeric>
#include <type_traits>
namespace internal {
/// 体 (field) であることを表明する opt-in マーカー基底。
/// 四則演算(除算を含む)が閉じ、`0`/`1` を構築でき `==` で比較できる型が継承する。
/// 整数型・浮動小数点型は構文上は四則演算できても「体である」保証がないため
/// 区別したく、構文ベースの concept では弾けないのでマーカー方式を採る。
struct field_base {};
/// 体 (field) として扱える型。`field_base` を継承した型のみが満たす。
/// modint(素数 mod)や有理数を想定。
template <class T>
concept field = std::is_base_of_v<field_base, T>;
template <class T>
using is_signed_int128 =
typename std::conditional<std::is_same<T, __int128_t>::value || std::is_same<T, __int128>::value, std::true_type,
std::false_type>::type;
template <class T>
using is_unsigned_int128 =
typename std::conditional<std::is_same<T, __uint128_t>::value || std::is_same<T, unsigned __int128>::value,
std::true_type, std::false_type>::type;
template <class T>
using make_unsigned_int128 =
typename std::conditional<std::is_same<T, __int128_t>::value, __uint128_t, unsigned __int128>;
template <class T>
using is_integral =
typename std::conditional<std::is_integral<T>::value || is_signed_int128<T>::value || is_unsigned_int128<T>::value,
std::true_type, std::false_type>::type;
template <class T>
using is_signed_int =
typename std::conditional<(is_integral<T>::value && std::is_signed<T>::value) || is_signed_int128<T>::value,
std::true_type, std::false_type>::type;
template <class T>
using is_unsigned_int =
typename std::conditional<(is_integral<T>::value && std::is_unsigned<T>::value) || is_unsigned_int128<T>::value,
std::true_type, std::false_type>::type;
template <class T>
using to_unsigned = typename std::conditional<
is_signed_int128<T>::value, make_unsigned_int128<T>,
typename std::conditional<std::is_signed<T>::value, std::make_unsigned<T>, std::common_type<T>>::type>::type;
template <class T>
using is_signed_int_t = std::enable_if_t<is_signed_int<T>::value>;
template <class T>
using is_unsigned_int_t = std::enable_if_t<is_unsigned_int<T>::value>;
template <class T>
using to_unsigned_t = typename to_unsigned<T>::type;
} // namespace internal