clang-format and clang-tidy fixes for 2ad5420a

This commit is contained in:
github-actions 2021-01-17 20:44:59 +00:00
parent 0e1e441ab3
commit b9cdab9354

View File

@ -5,7 +5,8 @@
* @details To calculate division of two numbers under modulo p
* Modulo operator is not distributive under division, therefore
* we first have to calculate the inverse of divisor using
* [Fermat's little theorem](https://en.wikipedia.org/wiki/Fermat%27s_little_theorem)
* [Fermat's little
theorem](https://en.wikipedia.org/wiki/Fermat%27s_little_theorem)
* Now, we can multiply the dividend with the inverse of divisor
* and modulo is distributive over multiplication operation.
* Let,
@ -31,12 +32,12 @@
* @brief Mathematical algorithms
*/
namespace math {
/**
/**
* @namespace modular_division
* @brief Functions for Modular Division implementation
*/
namespace modular_division {
/**
namespace modular_division {
/**
* @brief This function calculates a raised to exponent b under modulo c using
* modular exponentiation.
* @param a integer base
@ -44,7 +45,7 @@ namespace math {
* @param c integer modulo
* @return a raised to power b modulo c
*/
uint64_t power(uint64_t a, uint64_t b, uint64_t c) {
uint64_t power(uint64_t a, uint64_t b, uint64_t c) {
uint64_t ans = 1; /// Initialize the answer to be returned
a = a % c; /// Update a if it is more than or equal to c
if (a == 0) {
@ -60,21 +61,22 @@ namespace math {
a = ((a % c) * (a % c)) % c;
}
return ans;
}
}
/**
/**
* @brief This function calculates modular division
* @param a integer dividend
* @param b integer divisor
* @param p integer modulo
* @return a/b modulo c
*/
uint64_t mod_division(uint64_t a, uint64_t b, uint64_t p) {
uint64_t inverse = power(b, p-2, p)%p; /// Calculate the inverse of b
uint64_t result = ((a%p)*(inverse%p))%p; /// Calculate the final result
uint64_t mod_division(uint64_t a, uint64_t b, uint64_t p) {
uint64_t inverse = power(b, p - 2, p) % p; /// Calculate the inverse of b
uint64_t result =
((a % p) * (inverse % p)) % p; /// Calculate the final result
return result;
}
} // namespace modular_division
}
} // namespace modular_division
} // namespace math
/**