Implemented lookup table for finite field inversion#7
Implemented lookup table for finite field inversion#7michiexile wants to merge 1 commit intoappliedtopology:masterfrom
Conversation
| @@ -57,6 +58,43 @@ std::size_t inverse( const ctl::Finite_field< N> & x, const std::size_t prime){ | |||
| return inverse( x.value(), prime); | |||
| } | |||
|
|
|||
There was a problem hiding this comment.
CTL uses the snake_case convention, and the use of singletons is un-necessary here.
You can do something like this:
namespace ctl {
namespace detail {
template< std::size_t Prime>
constexpr std::array<std::size_t, Prime> inversion_table = { ctl::detail::inverse<prime>(0), ctl::detail::inverse<prime>(1), ..., ctl::detail::inverse<prime>(prime-1) };
} //end namespace detail
} //end namespace ctl
the compiler will just instantiate one (or lookup the value) when it is used..
There was a problem hiding this comment.
ctl::detail::inverse(_) just needs to be constexpr..
|
I just merged my massive PR which changes a bunch of the C++ API as well as provides the python api in the mainline. You will need to merge master into your branch. This change is a welcome change, although, I think there is something to think about, which is that this requires building a static I think we should consider these tradeoffs. |
If I understand C++ correctly, this design (with a singleton pattern carrying the actual lookup table) will keep instantiation of the actual lookup to once per program-and-prime.