Skip to content

Commit

Permalink
Merge pull request #2497 from o1-labs/dw/mvpoly-rename-into-mul-by-sc…
Browse files Browse the repository at this point in the history
…alar

MVPoly: rename mul_by_const into mul_by_scalar
  • Loading branch information
dannywillems authored Aug 27, 2024
2 parents 254a62a + 48a7de7 commit 44a7ee3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion mvpoly/src/prime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ impl<F: PrimeField, const N: usize, const D: usize> Dense<F, N, D> {
Self::from_coeffs(coeffs)
}

pub fn mul_by_const(&self, c: F) -> Self {
pub fn mul_by_scalar(&self, c: F) -> Self {
let coeffs = self.coeff.iter().map(|coef| *coef * c).collect();
Self::from_coeffs(coeffs)
}
Expand Down
18 changes: 9 additions & 9 deletions mvpoly/tests/prime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,42 +239,42 @@ fn test_neg_ref() {
}

#[test]
fn test_mul_by_const() {
fn test_mul_by_scalar() {
let mut rng = o1_utils::tests::make_test_rng(None);
let p1 = Dense::<Fp, 4, 5>::random(&mut rng);
let mut p2 = Dense::<Fp, 4, 5>::zero();
let c = Fp::rand(&mut rng);
p2[0] = c;
assert_eq!(p2 * p1.clone(), p1.clone().mul_by_const(c))
assert_eq!(p2 * p1.clone(), p1.clone().mul_by_scalar(c))
}

#[test]
fn test_mul_by_const_with_zero() {
fn test_mul_by_scalar_with_zero() {
let mut rng = o1_utils::tests::make_test_rng(None);
let p1 = Dense::<Fp, 4, 5>::random(&mut rng);
let c = Fp::zero();
assert_eq!(p1.mul_by_const(c), Dense::<Fp, 4, 5>::zero())
assert_eq!(p1.mul_by_scalar(c), Dense::<Fp, 4, 5>::zero())
}

#[test]
fn test_mul_by_const_with_one() {
fn test_mul_by_scalar_with_one() {
let mut rng = o1_utils::tests::make_test_rng(None);
let p1 = Dense::<Fp, 4, 5>::random(&mut rng);
let c = Fp::one();
assert_eq!(p1.mul_by_const(c), p1)
assert_eq!(p1.mul_by_scalar(c), p1)
}

#[test]
fn test_mul_by_const_with_from() {
fn test_mul_by_scalar_with_from() {
let mut rng = o1_utils::tests::make_test_rng(None);
let p = Dense::<Fp, 4, 5>::random(&mut rng);
let c = Fp::rand(&mut rng);

// Create a constant polynomial from the field element
let constant_poly = Dense::<Fp, 4, 5>::from(c);

// Multiply p by c using mul_by_const
let result1 = p.mul_by_const(c);
// Multiply p by c using mul_by_scalar
let result1 = p.mul_by_scalar(c);

// Multiply p by the constant polynomial
let result2 = p.clone() * constant_poly;
Expand Down

0 comments on commit 44a7ee3

Please sign in to comment.