Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
6589fd3
WIP with const alignment and transparent repr
JoeyBF Nov 30, 2025
9f99315
Simple docs
JoeyBF Nov 30, 2025
8dba66e
Factor out `FqVector::is_empty`
JoeyBF Nov 26, 2025
e522e20
Factor out `FpVector::prime`
JoeyBF Nov 26, 2025
5346d1b
Factor out `FqVector::slice`
JoeyBF Nov 26, 2025
1040d50
Factor out `FqVector::slice_mut`
JoeyBF Nov 26, 2025
8123f57
Factor out `FqVector::entry`
JoeyBF Nov 26, 2025
24c2982
Factor out `FqVector::set_entry`
JoeyBF Nov 26, 2025
5562400
Factor out `FqVector::add_basis_element`
JoeyBF Nov 26, 2025
6544719
Move limb methods to `FqVectorBase`
JoeyBF Nov 26, 2025
311361f
Factor out `FqVector::set_to_zero`
JoeyBF Nov 26, 2025
425c265
Factor out `FqVector::is_zero`
JoeyBF Nov 26, 2025
683afa8
Factor out `FqSliceMut::reduce_limbs`
JoeyBF Nov 26, 2025
1cc8ebb
Factor out `FqVector::scale`
JoeyBF Nov 26, 2025
dc33abf
Remove unnecessary `.as_slice`s
JoeyBF Nov 26, 2025
af70dda
Factor out `FqVector::as_slice`
JoeyBF Nov 26, 2025
a0f85e2
Factor out `FqVector::as_slice_mut`
JoeyBF Nov 26, 2025
777af2d
Factor out `FqVector::iter`
JoeyBF Nov 26, 2025
9a9a1a4
Factor out `FqVector::iter_nonzero`
JoeyBF Nov 26, 2025
74a6aee
Factor out `Display` impl for vectors
JoeyBF Nov 26, 2025
73abf6a
Implement `From<&'a FqVectorBase>` for `FqSlice<'a>`
JoeyBF Nov 26, 2025
53ccccf
Implement `From<&'a mut FqVectorBase>` for `FqSliceMut<'a>`
JoeyBF Nov 26, 2025
b2937cd
Use `Repr` in `fp_wrapper` too
JoeyBF Nov 28, 2025
e5f6c1c
Factor out immutable methods to `FpVectorBase`
JoeyBF Nov 28, 2025
45df2ba
Factor out mutable methods
JoeyBF Nov 28, 2025
3d8ff61
Unify `From` implementations for slice types
JoeyBF Nov 28, 2025
547691e
Unify `Display` implementations
JoeyBF Nov 29, 2025
279e516
Extend `Vec`'s `From<&FpVector>` implementation
JoeyBF Nov 30, 2025
4e84c3f
Relax requirements of `FqVectorBase` definition
JoeyBF Dec 10, 2025
15e0b6b
Make `FpVectorBase` an enum in all feature combinations
JoeyBF Dec 10, 2025
8f7a735
Fix lint
JoeyBF Dec 26, 2025
9ffc263
Clean up
JoeyBF Dec 26, 2025
ce3dcc0
Add early return to `set_to_zero`
JoeyBF Mar 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions ext/crates/fp/src/matrix/matrix_inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,12 @@ impl Matrix {

pub fn row(&self, row: usize) -> FpSlice<'_> {
let limb_range = row_to_limb_range(row, self.stride);
FpSlice::new(self.prime(), &self.data[limb_range], 0, self.columns)
FpSlice::_new(self.prime(), &self.data[limb_range], 0, self.columns)
}

pub fn row_mut(&mut self, row: usize) -> FpSliceMut<'_> {
let limb_range = row_to_limb_range(row, self.stride);
FpSliceMut::new(self.prime(), &mut self.data[limb_range], 0, self.columns)
FpSliceMut::_new(self.prime(), &mut self.data[limb_range], 0, self.columns)
}
}

Expand All @@ -393,7 +393,7 @@ impl Matrix {
.data
.chunks_mut(self.stride)
.take(logical_rows) // Only iterate over logical rows
.map(move |row| FpSliceMut::new(p, row, 0, columns));
.map(move |row| FpSliceMut::_new(p, row, 0, columns));
Either::Right(rows)
}
}
Expand All @@ -412,7 +412,7 @@ impl Matrix {
.data
.maybe_par_chunks_mut(self.stride)
.take(logical_rows) // Only iterate over logical rows
.map(move |row| FpSliceMut::new(p, row, 0, columns));
.map(move |row| FpSliceMut::_new(p, row, 0, columns));
Either::Right(rows)
}
}
Expand Down Expand Up @@ -516,8 +516,8 @@ impl Matrix {
let row1 = unsafe { std::slice::from_raw_parts_mut(ptr.add(i * self.stride), self.stride) };
let row2 = unsafe { std::slice::from_raw_parts_mut(ptr.add(j * self.stride), self.stride) };
(
FpSliceMut::new(self.prime(), row1, 0, self.columns),
FpSliceMut::new(self.prime(), row2, 0, self.columns),
FpSliceMut::_new(self.prime(), row1, 0, self.columns),
FpSliceMut::_new(self.prime(), row2, 0, self.columns),
)
}

Expand Down Expand Up @@ -1263,7 +1263,7 @@ impl<const N: usize> AugmentedMatrix<N> {
let start_idx = self.start[start];
let end_idx = self.end[end];
let limb_range = row_to_limb_range(i, self.stride);
FpSliceMut::new(self.prime(), &mut self.data[limb_range], start_idx, end_idx)
FpSliceMut::_new(self.prime(), &mut self.data[limb_range], start_idx, end_idx)
}

pub fn row_segment(&self, i: usize, start: usize, end: usize) -> FpSlice<'_> {
Expand Down Expand Up @@ -1414,7 +1414,7 @@ impl<'a> MatrixSliceMut<'a> {
let end = self.col_end;
(0..self.rows).map(move |row_idx| {
let limb_range = row_to_limb_range(row_idx, self.stride);
FpSlice::new(self.prime(), &self.data[limb_range], start, end)
FpSlice::_new(self.prime(), &self.data[limb_range], start, end)
})
}

Expand All @@ -1429,7 +1429,7 @@ impl<'a> MatrixSliceMut<'a> {
let rows = self
.data
.chunks_mut(self.stride)
.map(move |row| FpSliceMut::new(p, row, start, end));
.map(move |row| FpSliceMut::_new(p, row, start, end));
Either::Right(rows)
}
}
Expand All @@ -1447,14 +1447,14 @@ impl<'a> MatrixSliceMut<'a> {
let rows = self
.data
.maybe_par_chunks_mut(self.stride)
.map(move |row| FpSliceMut::new(p, row, start, end));
.map(move |row| FpSliceMut::_new(p, row, start, end));
Either::Right(rows)
}
}

pub fn row(&mut self, row: usize) -> FpSlice<'_> {
let limb_range = row_to_limb_range(row, self.stride);
FpSlice::new(
FpSlice::_new(
self.prime(),
&self.data[limb_range],
self.col_start,
Expand All @@ -1464,7 +1464,7 @@ impl<'a> MatrixSliceMut<'a> {

pub fn row_mut(&mut self, row: usize) -> FpSliceMut<'_> {
let limb_range = row_to_limb_range(row, self.stride);
FpSliceMut::new(
FpSliceMut::_new(
self.prime(),
&mut self.data[limb_range],
self.col_start,
Expand Down
61 changes: 26 additions & 35 deletions ext/crates/fp/src/vector/fp_wrapper/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,36 @@

use itertools::Itertools;

use super::{FqSlice, FqSliceMut, FqVector, FqVectorIterator, FqVectorNonZeroIterator};
use super::{
FqSlice, FqSliceMut, FqVector, FqVectorBase, FqVectorIterator, FqVectorNonZeroIterator, Repr,
ReprMut,
};
use crate::field::Field;

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

impl<const A: bool, R: Repr, F: Field> FqVectorBase<A, R, F> {
pub(super) fn entry_helper(&self, index: usize) -> F::ElementContainer {
self.entry(index).val()
}
}

pub(super) fn set_entry_helper(&mut self, index: usize, value: F::ElementContainer) {
self.set_entry(index, self.fq().el(value))
}

pub(super) fn add_helper(&mut self, other: &Self, c: F::ElementContainer) {
self.add(other, self.fq().el(c))
impl<const A: bool, R: ReprMut, F: Field> FqVectorBase<A, R, F> {
pub(super) fn scale_helper(&mut self, c: F::ElementContainer) {
self.scale(self.fq().el(c))
}

pub(super) fn add_offset_helper(
&mut self,
other: &Self,
c: F::ElementContainer,
offset: usize,
) {
self.add_offset(other, self.fq().el(c), offset)
pub(super) fn set_entry_helper(&mut self, index: usize, value: F::ElementContainer) {
self.set_entry(index, self.fq().el(value))
}

pub(super) fn add_basis_element_helper(&mut self, index: usize, value: F::ElementContainer) {
self.add_basis_element(index, self.fq().el(value))
}
}

impl<F: Field> FqVector<F> {
pub(super) fn add_helper(&mut self, other: &Self, c: F::ElementContainer) {
self.add(other, self.fq().el(c))
}

pub(super) fn copy_from_slice_helper(&mut self, other: &[F::ElementContainer]) {
self.copy_from_slice(&other.iter().map(|x| self.fq().el(x.clone())).collect_vec())
Expand All @@ -71,26 +69,27 @@ impl<F: Field> FqVector<F> {
self.add_carry(other, self.fq().el(c), rest)
}

pub(super) fn add_offset_helper(
&mut self,
other: &Self,
c: F::ElementContainer,
offset: usize,
) {
self.add_offset(other, self.fq().el(c), offset)
}

pub(super) fn first_nonzero_helper(&self) -> Option<(usize, F::ElementContainer)> {
self.first_nonzero().map(|(idx, c)| (idx, c.val()))
}
}

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

pub(super) fn first_nonzero_helper(&self) -> Option<(usize, F::ElementContainer)> {
self.first_nonzero().map(|(idx, c)| (idx, c.val()))
}
}

impl<F: Field> FqSliceMut<'_, 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: FqSlice<F>, c: F::ElementContainer) {
self.add(other, self.fq().el(c))
}
Expand All @@ -104,14 +103,6 @@ impl<F: Field> FqSliceMut<'_, F> {
self.add_offset(other, self.fq().el(c), offset)
}

pub(super) fn set_entry_helper(&mut self, index: usize, value: F::ElementContainer) {
self.set_entry(index, self.fq().el(value))
}

pub(super) fn add_basis_element_helper(&mut self, index: usize, value: F::ElementContainer) {
self.add_basis_element(index, self.fq().el(value))
}

pub(super) fn add_masked_helper(
&mut self,
other: FqSlice<F>,
Expand Down
Loading