generated from Tiphereth-A/TINplate
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
093293d
commit 7e4b903
Showing
8 changed files
with
67 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#ifndef TIFALIBS_COMB_FACT_HELPER | ||
#define TIFALIBS_COMB_FACT_HELPER | ||
|
||
#include "gen_fact.hpp" | ||
#include "gen_ifact.hpp" | ||
|
||
namespace tifa_libs::math { | ||
|
||
template <class mint> | ||
struct fact_helper { | ||
static CEXP u32 DEFUALT_MAX = 10'000'001; | ||
static CEXP u64 mod() NE { return mint::mod(); } | ||
static inline vec<mint> fact = gen_fact<mint>(DEFUALT_MAX), | ||
ifact = gen_ifact<mint>(DEFUALT_MAX); | ||
CEXPE fact_helper(u32 n = 0) NE { | ||
if (u32 _ = std::min((u32)mod(), n); _ > fact.size()) [[unlikely]] { | ||
fact = gen_fact<mint>(_); | ||
ifact = gen_ifact<mint>(_); | ||
} | ||
} | ||
|
||
CEXP mint get_fact(u64 n) CNE { | ||
if (n >= mod()) [[unlikely]] | ||
return 0; | ||
if (n < fact.size()) [[likely]] | ||
return fact[n]; | ||
mint _ = fact.back() * n; | ||
flt_ (u64, i, fact.size(), n) _ *= i; | ||
return _; | ||
} | ||
CEXP mint get_ifact(u64 n) CNE { | ||
if (n >= mod()) [[unlikely]] | ||
return 0; | ||
if (n < ifact.size()) [[likely]] | ||
return ifact[n]; | ||
return get_fact(n).inv(); | ||
} | ||
}; | ||
|
||
} // namespace tifa_libs::math | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
title: fact_helper | ||
documentation_of: //src/code/comb/fact_helper.hpp | ||
--- |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.