mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-03 22:33:06 +00:00
Merge pull request #144 from mir-protocol/optimize_small_exp_u64
Hardcode small exponents in `exp_u64_extension`
This commit is contained in:
commit
08b018fc02
@ -315,6 +315,11 @@ impl<F: Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
|||||||
self.mul_extension(x, x)
|
self.mul_extension(x, x)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Computes `x^3`.
|
||||||
|
pub fn cube_extension(&mut self, x: ExtensionTarget<D>) -> ExtensionTarget<D> {
|
||||||
|
self.mul_three_extension(x, x, x)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn mul_ext_algebra(
|
pub fn mul_ext_algebra(
|
||||||
&mut self,
|
&mut self,
|
||||||
a: ExtensionAlgebraTarget<D>,
|
a: ExtensionAlgebraTarget<D>,
|
||||||
@ -450,6 +455,13 @@ impl<F: Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
|||||||
base: ExtensionTarget<D>,
|
base: ExtensionTarget<D>,
|
||||||
exponent: u64,
|
exponent: u64,
|
||||||
) -> ExtensionTarget<D> {
|
) -> ExtensionTarget<D> {
|
||||||
|
match exponent {
|
||||||
|
0 => return self.one_extension(),
|
||||||
|
1 => return base,
|
||||||
|
2 => return self.square_extension(base),
|
||||||
|
3 => return self.cube_extension(base),
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
let mut current = base;
|
let mut current = base;
|
||||||
let mut product = self.one_extension();
|
let mut product = self.one_extension();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user