Opt const eval#17
Conversation
| let mut b = self; | ||
|
|
||
| if power == 0 { | ||
| return Self::ONE; | ||
| } else if b == Self::ZERO { | ||
| return Self::ZERO; | ||
| } | ||
|
|
||
| let mut r = if power & 1 == 1 { b } else { Self::ONE }; | ||
| for i in 1..64 - power.leading_zeros() { | ||
| b = b.square(); | ||
| if (power >> i) & 1 == 1 { | ||
| r *= b; | ||
| } |
There was a problem hiding this comment.
This is fine to have for testing purposes - but it probably shouldn't be a part of this PR.
There was a problem hiding this comment.
Sure, I will remove it before making the PR against Novi/Winterfell main.
There was a problem hiding this comment.
Actually, I will just change it back so that I don't forget it.
| /// always $n - 1$. Thus, once we divide out the divisor, the evaluations will represent a | ||
| /// polynomial of degree $D$. | ||
| pub fn merge_evaluations<B, F>(&self, evaluations: &[F], x: B) -> E | ||
| pub fn merge_evaluations<B, F>(&self, evaluations: &[F], xp: B) -> E |
There was a problem hiding this comment.
The comment above probably should be updated.
There was a problem hiding this comment.
Done, let me know what you think.
| } | ||
|
|
||
| /// Returns (offset * g^(step))^degree_adjustment. | ||
| pub fn get_ce_x_power_at<A: Air<BaseField = B>>( |
There was a problem hiding this comment.
We could try adding #[inline(always)] attribute to this function (and maybe some other functions). Sometimes, this improves performance.
There was a problem hiding this comment.
Sure, I did here and in the helper function on the same file.
| let index = index % (self.ce_domain_size()); | ||
| let xp = self.ce_domain()[index] * *self.degree_adj_map().get(°ree_adjustment).unwrap(); |
There was a problem hiding this comment.
I wonder if instead of % we could use a shift here somehow (because we know that ce_domain_size is a power of 2).
Also, we should change unwrap to expect (we shouldn't use unwrap's in non-test code).
For some reason the previous PR says that it has been merged. I am creating this new PR which implements the improvements suggested in the old one.
Sorry for the mess.