Skip to content

Commit

Permalink
Give better names to Fq structures
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeyBF committed Aug 23, 2024
1 parent 90a26ea commit ae76a5e
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 89 deletions.
20 changes: 10 additions & 10 deletions ext/crates/fp/src/vector/fp_wrapper/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use itertools::Itertools;

use super::{FpSliceMutP, FpSliceP, FqVector, FqVectorIteratorP, FqVectorNonZeroIteratorP};
use super::{FqSlice, FqSliceMut, FqVector, FqVectorIterator, FqVectorNonZeroIterator};
use crate::field::Field;

impl<F: Field> FqVector<F> {
Expand Down Expand Up @@ -76,18 +76,18 @@ impl<F: Field> FqVector<F> {
}
}

impl<'a, F: Field> FpSliceP<'a, F> {
impl<'a, F: Field> FqSlice<'a, F> {
pub(super) fn entry_helper(&self, index: usize) -> F::ElementContainer {
self.entry(index).val()
}
}

impl<'a, F: Field> FpSliceMutP<'a, F> {
impl<'a, F: Field> FqSliceMut<'a, F> {
pub(super) fn scale_helper(&mut self, c: F::ElementContainer) {
self.scale(self.fq.el(c))
}

pub(super) fn add_helper(&mut self, other: FpSliceP<F>, c: F::ElementContainer) {
pub(super) fn add_helper(&mut self, other: FqSlice<F>, c: F::ElementContainer) {
self.add(other, self.fq.el(c))
}

Expand All @@ -101,7 +101,7 @@ impl<'a, F: Field> FpSliceMutP<'a, F> {

pub(super) fn add_masked_helper(
&mut self,
other: FpSliceP<F>,
other: FqSlice<F>,
c: F::ElementContainer,
mask: &[usize],
) {
Expand All @@ -110,7 +110,7 @@ impl<'a, F: Field> FpSliceMutP<'a, F> {

pub(super) fn add_unmasked_helper(
&mut self,
other: FpSliceP<F>,
other: FqSlice<F>,
c: F::ElementContainer,
mask: &[usize],
) {
Expand All @@ -121,20 +121,20 @@ impl<'a, F: Field> FpSliceMutP<'a, F> {
&mut self,
offset: usize,
coeff: F::ElementContainer,
left: FpSliceP<F>,
right: FpSliceP<F>,
left: FqSlice<F>,
right: FqSlice<F>,
) {
self.add_tensor(offset, self.fq.el(coeff), left, right)
}
}

impl<'a, F: Field> FqVectorIteratorP<'a, F> {
impl<'a, F: Field> FqVectorIterator<'a, F> {
pub(super) fn next_helper(&mut self) -> Option<F::ElementContainer> {
self.next().map(|x| x.val())
}
}

impl<'a, F: Field> FqVectorNonZeroIteratorP<'a, F> {
impl<'a, F: Field> FqVectorNonZeroIterator<'a, F> {
pub(super) fn next_helper(&mut self) -> Option<(usize, F::ElementContainer)> {
self.next().map(|x| (x.0, x.1.val()))
}
Expand Down
12 changes: 6 additions & 6 deletions ext/crates/fp/src/vector/fp_wrapper/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ use std::{
use itertools::Itertools;
use serde::{Deserialize, Deserializer, Serialize, Serializer};

use super::iter::{FqVectorIteratorP, FqVectorNonZeroIteratorP};
use super::iter::{FqVectorIterator, FqVectorNonZeroIterator};
use crate::{
field::{field_internal::FieldInternal, Fp},
limb::Limb,
prime::Prime,
vector::inner::{FpSliceMutP, FpSliceP, FqVector},
vector::inner::{FqSlice, FqSliceMut, FqVector},
};

mod helpers;
Expand All @@ -52,20 +52,20 @@ dispatch_struct! {

dispatch_struct! {
#[derive(Debug, Copy, Clone)]
pub FpSlice<'a> from FpSliceP
pub FpSlice<'a> from FqSlice
}

dispatch_struct! {
#[derive(Debug)]
pub FpSliceMut<'a> from FpSliceMutP
pub FpSliceMut<'a> from FqSliceMut
}

dispatch_struct! {
pub FpVectorIterator<'a> from FqVectorIteratorP
pub FpVectorIterator<'a> from FqVectorIterator
}

dispatch_struct! {
pub FpVectorNonZeroIterator<'a> from FqVectorNonZeroIteratorP
pub FpVectorNonZeroIterator<'a> from FqVectorNonZeroIterator
}

impl FpVector {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use itertools::Itertools;

use super::{
inner::{FpSliceP, FqVector},
iter::{FqVectorIteratorP, FqVectorNonZeroIteratorP},
inner::{FqSlice, FqVector},
iter::{FqVectorIterator, FqVectorNonZeroIterator},
};
use crate::{
constants,
Expand All @@ -13,7 +13,7 @@ use crate::{

// Public methods

impl<'a, F: Field> FpSliceP<'a, F> {
impl<'a, F: Field> FqSlice<'a, F> {
pub fn prime(&self) -> ValidPrime {
self.fq.characteristic().to_dyn()
}
Expand Down Expand Up @@ -42,12 +42,12 @@ impl<'a, F: Field> FpSliceP<'a, F> {
}

/// TODO: implement prime 2 version
pub fn iter(self) -> FqVectorIteratorP<'a, F> {
FqVectorIteratorP::new(self)
pub fn iter(self) -> FqVectorIterator<'a, F> {
FqVectorIterator::new(self)
}

pub fn iter_nonzero(self) -> FqVectorNonZeroIteratorP<'a, F> {
FqVectorNonZeroIteratorP::new(self)
pub fn iter_nonzero(self) -> FqVectorNonZeroIterator<'a, F> {
FqVectorNonZeroIterator::new(self)
}

pub fn is_zero(&self) -> bool {
Expand All @@ -74,7 +74,7 @@ impl<'a, F: Field> FpSliceP<'a, F> {
pub fn slice(self, start: usize, end: usize) -> Self {
assert!(start <= end && end <= self.len());

FpSliceP {
FqSlice {
fq: self.fq,
limbs: self.limbs,
start: self.start + start,
Expand All @@ -101,7 +101,7 @@ impl<'a, F: Field> FpSliceP<'a, F> {
}

// Limb methods
impl<'a, F: Field> FpSliceP<'a, F> {
impl<'a, F: Field> FqSlice<'a, F> {
#[inline]
pub(super) fn offset(&self) -> usize {
let bit_length = self.fq.bit_length();
Expand Down Expand Up @@ -150,13 +150,13 @@ impl<'a, F: Field> FpSliceP<'a, F> {
}
}

impl<'a, F: Field> From<&'a FqVector<F>> for FpSliceP<'a, F> {
impl<'a, F: Field> From<&'a FqVector<F>> for FqSlice<'a, F> {
fn from(v: &'a FqVector<F>) -> Self {
v.slice(0, v.len)
}
}

impl<'a, F: Field> std::fmt::Display for FpSliceP<'a, F> {
impl<'a, F: Field> std::fmt::Display for FqSlice<'a, F> {
/// # Example
/// ```
/// # use fp::field::{Field, SmallFq};
Expand Down
Loading

0 comments on commit ae76a5e

Please sign in to comment.