Skip to content

Commit

Permalink
add alloc
Browse files Browse the repository at this point in the history
  • Loading branch information
ColoCarletti committed Oct 4, 2024
1 parent 076b683 commit 0d7d89f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion math/src/circle/cfft.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
extern crate alloc;
use crate::field::{element::FieldElement, fields::mersenne31::field::Mersenne31Field};
use alloc::vec::Vec;

#[cfg(feature = "alloc")]
pub fn inplace_cfft(
input: &mut [FieldElement<Mersenne31Field>],
twiddles: Vec<Vec<FieldElement<Mersenne31Field>>>,
Expand Down
6 changes: 3 additions & 3 deletions math/src/circle/cosets.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
extern crate alloc;
use crate::circle::point::CirclePoint;
use crate::field::fields::mersenne31::field::Mersenne31Field;
use alloc::vec::Vec;
use std::iter::successors;

#[derive(Debug, Clone)]
pub struct Coset {
Expand Down Expand Up @@ -47,11 +46,12 @@ impl Coset {

/// Returns the vector of shift + g for every g in <g_n>.
/// where g = i * g_n for i = 0, ..., n-1.
#[cfg(feature = "alloc")]
pub fn get_coset_points(coset: &Self) -> Vec<CirclePoint<Mersenne31Field>> {
// g_n the generator of the subgroup of order n.
let generator_n = CirclePoint::get_generator_of_subgroup(coset.log_2_size);
let size: u8 = 1 << coset.log_2_size;
successors(Some(coset.shift.clone()), move |prev| {
core::iter::successors(Some(coset.shift.clone()), move |prev| {
Some(prev.clone() + generator_n.clone())
})
.take(size.into())
Expand Down
4 changes: 3 additions & 1 deletion math/src/circle/twiddles.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use super::{cosets::Coset, point::CirclePoint};
extern crate alloc;
use crate::{
circle::{cosets::Coset, point::CirclePoint},
fft::cpu::bit_reversing::in_place_bit_reverse_permute,
field::{element::FieldElement, fields::mersenne31::field::Mersenne31Field},
};

#[cfg(feature = "alloc")]
pub fn get_twiddles(domain: Coset) -> Vec<Vec<FieldElement<Mersenne31Field>>> {
let mut half_domain_points = Coset::get_coset_points(&Coset::half_coset(domain.clone()));
in_place_bit_reverse_permute::<CirclePoint<Mersenne31Field>>(&mut half_domain_points[..]);
Expand Down

0 comments on commit 0d7d89f

Please sign in to comment.