use p3_field::extension::{BinomiallyExtendable, HasTwoAdicBionmialExtension};
use p3_field::{field_to_array, TwoAdicField};
use crate::{BinomialExtensionData, FieldParameters, MontyField31, TwoAdicData};
impl<const WIDTH: usize, FP> BinomiallyExtendable<WIDTH> for MontyField31<FP>
where
FP: BinomialExtensionData<WIDTH> + FieldParameters,
{
const W: Self = <FP as BinomialExtensionData<WIDTH>>::W;
const DTH_ROOT: Self = <FP as BinomialExtensionData<WIDTH>>::DTH_ROOT;
const EXT_GENERATOR: [Self; WIDTH] = FP::EXT_GENERATOR;
}
impl<const WIDTH: usize, FP> HasTwoAdicBionmialExtension<WIDTH> for MontyField31<FP>
where
FP: BinomialExtensionData<WIDTH> + TwoAdicData + FieldParameters,
{
const EXT_TWO_ADICITY: usize = <FP as BinomialExtensionData<WIDTH>>::EXT_TWO_ADICITY;
fn ext_two_adic_generator(bits: usize) -> [Self; WIDTH] {
assert!(bits <= Self::EXT_TWO_ADICITY);
if bits <= FP::TWO_ADICITY {
field_to_array(Self::two_adic_generator(bits))
} else {
FP::TWO_ADIC_EXTENSION_GENERATORS.as_ref()[bits - FP::TWO_ADICITY - 1]
}
}
}