make_evaluation_domain.hpp
Go to the documentation of this file.
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2020-2021 Mikhail Komarov <nemo@nil.foundation>
3 // Copyright (c) 2020-2021 Nikita Kaskov <nbering@nil.foundation>
4 //
5 // MIT License
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining a copy
8 // of this software and associated documentation files (the "Software"), to deal
9 // in the Software without restriction, including without limitation the rights
10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 // copies of the Software, and to permit persons to whom the Software is
12 // furnished to do so, subject to the following conditions:
13 //
14 // The above copyright notice and this permission notice shall be included in all
15 // copies or substantial portions of the Software.
16 //
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 // SOFTWARE.
24 //---------------------------------------------------------------------------//
25 
26 #ifndef CRYPTO3_MATH_MAKE_EVALUATION_DOMAIN_HPP
27 #define CRYPTO3_MATH_MAKE_EVALUATION_DOMAIN_HPP
28 
35 
37 
38 namespace nil {
39  namespace crypto3 {
40  namespace math {
41 
50  template<typename FieldType>
51  std::shared_ptr<evaluation_domain<FieldType>> make_evaluation_domain(std::size_t m) {
52  typedef std::shared_ptr<evaluation_domain<FieldType>> result_type;
53 
54  const std::size_t big = 1ul << (std::size_t(std::ceil(std::log2(m))) - 1);
55  const std::size_t rounded_small = (1ul << std::size_t(std::ceil(std::log2(m - big))));
56 
57  if (detail::is_basic_radix2_domain<FieldType>(m)) {
58  result_type result;
59  result.reset(new basic_radix2_domain<FieldType>(m));
60  return result;
61  }
62 
63  if (detail::is_extended_radix2_domain<FieldType>(m)) {
64  result_type result;
65  result.reset(new extended_radix2_domain<FieldType>(m));
66  return result;
67  }
68 
69  if (detail::is_step_radix2_domain<FieldType>(m)) {
70  result_type result;
71  result.reset(new step_radix2_domain<FieldType>(m));
72  return result;
73  }
74 
75  if (detail::is_basic_radix2_domain<FieldType>(big + rounded_small)) {
76  result_type result;
77  result.reset(new basic_radix2_domain<FieldType>(big + rounded_small));
78  return result;
79  }
80 
81  if (detail::is_extended_radix2_domain<FieldType>(big + rounded_small)) {
82  result_type result;
83  result.reset(new extended_radix2_domain<FieldType>(big + rounded_small));
84  return result;
85  }
86 
87  if (detail::is_step_radix2_domain<FieldType>(big + rounded_small)) {
88  result_type result;
89  result.reset(new step_radix2_domain<FieldType>(big + rounded_small));
90  return result;
91  }
92 
93  if (detail::is_geometric_sequence_domain<FieldType>(m)) {
94  result_type result;
95  result.reset(new geometric_sequence_domain<FieldType>(m));
96  return result;
97  }
98 
99  if (detail::is_arithmetic_sequence_domain<FieldType>(m)) {
100  result_type result;
101  result.reset(new arithmetic_sequence_domain<FieldType>(m));
102  return result;
103  }
104 
105  return result_type();
106  }
107  } // namespace math
108  } // namespace crypto3
109 } // namespace nil
110 
111 #endif // CRYPTO3_MATH_MAKE_EVALUATION_DOMAIN_HPP
Definition: arithmetic_sequence_domain.hpp:49
Definition: basic_radix2_domain.hpp:47
Definition: extended_radix2_domain.hpp:45
Definition: geometric_sequence_domain.hpp:49
Definition: step_radix2_domain.hpp:45
std::shared_ptr< evaluation_domain< FieldType > > make_evaluation_domain(std::size_t m)
A convenience method for choosing an evaluation domain Returns an evaluation domain object in which t...
Definition: make_evaluation_domain.hpp:51
Definition: pair.hpp:31