Function mul_power

Source
pub fn mul_power<T, U>(b: T, a: T, p: U) -> T
where T: Sized + for<'x> MulAssign<&'x T> + for<'x> From<<&'x T as Mul>::Output>, for<'x> &'x T: Mul, U: Sized + Zero + One + Eq + for<'x> ShrAssign<usize> + for<'x> From<<&'x U as BitAnd>::Output>, for<'x> &'x U: BitAnd,
Expand description

calcurate $b \cdot a^p$ with exponentiation by squaring

This function doesn’t require T: num_traits::One.

use ring_algorithm::mul_power;
assert_eq!(mul_power::<i32, u64>(3, 2, 7), 384);