Powers of a finite field as `[start, start*exp, start * exp^2, .. start * exp^{num-1}]`
(start: F, exp: &F, num: u32)
| 86 | |
| 87 | /// Powers of a finite field as `[start, start*exp, start * exp^2, .. start * exp^{num-1}]` |
| 88 | pub fn powers_starting_from<F: Field>(start: F, exp: &F, num: u32) -> Vec<F> { |
| 89 | let mut powers = Vec::with_capacity(num as usize); |
| 90 | if num > 0 { |
| 91 | powers.push(start); |
| 92 | for i in 1..num as usize { |
| 93 | powers.push(powers[i - 1] * exp); |
| 94 | } |
| 95 | } |
| 96 | powers |
| 97 | } |
| 98 | |
| 99 | /// SUM of a geometric progression |
| 100 | /// SUM a^i = (1 - a^n) / (1 - a) = -(1-a^n)/-(1-a) |
no outgoing calls