From 17c9066f454204ac2f54faa391f779bd0ef73d45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Garillot?= Date: Sat, 7 May 2022 18:26:36 -0400 Subject: [PATCH] refactor: rename UV/MVPolynomial to DenseUV/MVPolynomial --- CHANGELOG.md | 1 + ec/src/hashing/curve_maps/wb/mod.rs | 2 +- poly-benches/benches/dense_uv_polynomial.rs | 2 +- poly-benches/benches/fft.rs | 2 +- poly/README.md | 8 ++++---- poly/src/domain/radix2/mod.rs | 2 +- poly/src/evaluations/univariate/mod.rs | 4 +++- poly/src/lib.rs | 2 +- poly/src/polynomial/mod.rs | 4 ++-- poly/src/polynomial/multivariate/sparse.rs | 4 ++-- poly/src/polynomial/univariate/dense.rs | 4 ++-- poly/src/polynomial/univariate/mod.rs | 2 +- poly/src/polynomial/univariate/sparse.rs | 2 +- 13 files changed, 21 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a44f2bf32..9cf42c8cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ - [\#393](https://github.com/arkworks-rs/algebra/pull/393) (`ark-ec`, `ark-ff`) Rename `FpXParams` to `FpXConfig` and `FpXParamsWrapper` to `FpXConfigWrapper`. - [\#396](https://github.com/arkworks-rs/algebra/pull/396) (`ark-ec`) Remove `mul_bits` feature, and remove default implementations of `mul` and `mul_by_cofactor_to_projective`. - [\#408](https://github.com/arkworks-rs/algebra/pull/408) (`ark-ff`) Change the output of `Display` formatting for BigInt & Fp from hex to decimal. +- [\#412](https://github.com/arkworks-rs/algebra/pull/412) (`ark-poly`) rename UV/MVPolynomial to DenseUV/MVPolynomial ### Features diff --git a/ec/src/hashing/curve_maps/wb/mod.rs b/ec/src/hashing/curve_maps/wb/mod.rs index ff002a3b8..825f5ec2d 100644 --- a/ec/src/hashing/curve_maps/wb/mod.rs +++ b/ec/src/hashing/curve_maps/wb/mod.rs @@ -2,7 +2,7 @@ use core::marker::PhantomData; use crate::{models::SWModelParameters, ModelParameters}; use ark_ff::batch_inversion; -use ark_poly::{univariate::DensePolynomial, Polynomial, UVPolynomial}; +use ark_poly::{univariate::DensePolynomial, DenseUVPolynomial, Polynomial}; use crate::{ hashing::{map_to_curve_hasher::MapToCurve, HashToCurveError}, diff --git a/poly-benches/benches/dense_uv_polynomial.rs b/poly-benches/benches/dense_uv_polynomial.rs index cfc6fb08e..fe861440a 100644 --- a/poly-benches/benches/dense_uv_polynomial.rs +++ b/poly-benches/benches/dense_uv_polynomial.rs @@ -3,7 +3,7 @@ extern crate criterion; use ark_ff::{FftField, Field}; use ark_poly::{ polynomial::univariate::{DensePolynomial, SparsePolynomial}, - EvaluationDomain, GeneralEvaluationDomain, Polynomial, UVPolynomial, + DenseUVPolynomial, EvaluationDomain, GeneralEvaluationDomain, Polynomial, }; use ark_poly_benches::size_range; use ark_std::rand::Rng; diff --git a/poly-benches/benches/fft.rs b/poly-benches/benches/fft.rs index 1d00e4993..5f6617540 100644 --- a/poly-benches/benches/fft.rs +++ b/poly-benches/benches/fft.rs @@ -2,7 +2,7 @@ extern crate criterion; use ark_ff::FftField; use ark_poly::{ - polynomial::{univariate::DensePolynomial, UVPolynomial}, + polynomial::{univariate::DensePolynomial, DenseUVPolynomial}, EvaluationDomain, MixedRadixEvaluationDomain, Radix2EvaluationDomain, }; use ark_poly_benches::size_range; diff --git a/poly/README.md b/poly/README.md index 171a816fe..d875c61cb 100644 --- a/poly/README.md +++ b/poly/README.md @@ -16,21 +16,21 @@ The `polynomial` module provides the following traits for defining polynomials i Requires implementors to support common operations on polynomials, such as `Add`, `Sub`, `Zero`, evaluation at a point, degree, etc, and defines methods to serialize to and from the coefficient representation of the polynomial. -- [`UVPolynomial`](./src/polynomial/mod.rs#L43) : +- [`DenseUVPolynomial`](./src/polynomial/mod.rs#L43) : Specifies that a `Polynomial` is actually a *univariate* polynomial. -- [`MVPolynomial`](./src/polynomial/mod.rs#L59): +- [`DenseMVPolynomial`](./src/polynomial/mod.rs#L59): Specifies that a `Polynomial` is actually a *multivariate* polynomial. This crate also provides the following data structures that implement these traits: - [`univariate/DensePolynomial`](./src/polynomial/univariate/dense.rs#L22): Represents degree `d` univariate polynomials via a list of `d + 1` coefficients. -This struct implements the [`UVPolynomial`](./src/polynomial/mod.rs#L43) trait. +This struct implements the [`DenseUVPolynomial`](./src/polynomial/mod.rs#L43) trait. - [`univariate/SparsePolynomial`](./src/polynomial/univariate/sparse.rs#L15): Represents degree `d` univariate polynomials via a list containing all non-zero monomials. This should only be used when most coefficients of the polynomial are zero. This struct implements the [`Polynomial`](./src/polynomial/mod.rs#L16) trait -(but *not* the `UVPolynomial` trait). +(but *not* the `DenseUVPolynomial` trait). - [`multivariate/SparsePolynomial`](./src/polynomial/multivariate/sparse.rs#L21): Represents multivariate polynomials via a list containing all non-zero monomials. diff --git a/poly/src/domain/radix2/mod.rs b/poly/src/domain/radix2/mod.rs index eda5d5590..e09ed67d8 100644 --- a/poly/src/domain/radix2/mod.rs +++ b/poly/src/domain/radix2/mod.rs @@ -239,7 +239,7 @@ impl EvaluationDomain for Radix2EvaluationDomain { mod tests { use crate::{ domain::Vec, - polynomial::{univariate::*, Polynomial, UVPolynomial}, + polynomial::{univariate::*, DenseUVPolynomial, Polynomial}, EvaluationDomain, Radix2EvaluationDomain, }; use ark_ff::{FftField, Field, One, UniformRand, Zero}; diff --git a/poly/src/evaluations/univariate/mod.rs b/poly/src/evaluations/univariate/mod.rs index 4619d1bf1..35d29d4f1 100644 --- a/poly/src/evaluations/univariate/mod.rs +++ b/poly/src/evaluations/univariate/mod.rs @@ -1,6 +1,8 @@ //! A univariate polynomial represented in evaluations form. -use crate::{univariate::DensePolynomial, EvaluationDomain, GeneralEvaluationDomain, UVPolynomial}; +use crate::{ + univariate::DensePolynomial, DenseUVPolynomial, EvaluationDomain, GeneralEvaluationDomain, +}; use ark_ff::{batch_inversion, FftField}; use ark_serialize::{CanonicalDeserialize, CanonicalSerialize, SerializationError}; use ark_std::{ diff --git a/poly/src/lib.rs b/poly/src/lib.rs index 0b1718bbf..1aa361325 100644 --- a/poly/src/lib.rs +++ b/poly/src/lib.rs @@ -35,7 +35,7 @@ pub use evaluations::{ }, univariate::Evaluations, }; -pub use polynomial::{multivariate, univariate, MVPolynomial, Polynomial, UVPolynomial}; +pub use polynomial::{multivariate, univariate, DenseMVPolynomial, DenseUVPolynomial, Polynomial}; #[cfg(test)] mod test; diff --git a/poly/src/polynomial/mod.rs b/poly/src/polynomial/mod.rs index 197603dc7..cad4d34b5 100644 --- a/poly/src/polynomial/mod.rs +++ b/poly/src/polynomial/mod.rs @@ -40,7 +40,7 @@ pub trait Polynomial: } /// Describes the interface for univariate polynomials -pub trait UVPolynomial: Polynomial { +pub trait DenseUVPolynomial: Polynomial { /// Constructs a new polynomial from a list of coefficients. fn from_coefficients_slice(coeffs: &[F]) -> Self; @@ -56,7 +56,7 @@ pub trait UVPolynomial: Polynomial { } /// Describes the interface for multivariate polynomials -pub trait MVPolynomial: Polynomial { +pub trait DenseMVPolynomial: Polynomial { /// The type of the terms of `self` type Term: multivariate::Term; diff --git a/poly/src/polynomial/multivariate/sparse.rs b/poly/src/polynomial/multivariate/sparse.rs index c7fc690da..53b988507 100644 --- a/poly/src/polynomial/multivariate/sparse.rs +++ b/poly/src/polynomial/multivariate/sparse.rs @@ -1,7 +1,7 @@ //! A sparse multivariate polynomial represented in coefficient form. use crate::{ multivariate::{SparseTerm, Term}, - MVPolynomial, Polynomial, + DenseMVPolynomial, Polynomial, }; use ark_ff::{Field, Zero}; use ark_serialize::{CanonicalDeserialize, CanonicalSerialize, SerializationError}; @@ -58,7 +58,7 @@ impl Polynomial for SparsePolynomial { } } -impl MVPolynomial for SparsePolynomial { +impl DenseMVPolynomial for SparsePolynomial { /// Returns the number of variables in `self` fn num_vars(&self) -> usize { self.num_vars diff --git a/poly/src/polynomial/univariate/dense.rs b/poly/src/polynomial/univariate/dense.rs index e69c08829..db7cfdf11 100644 --- a/poly/src/polynomial/univariate/dense.rs +++ b/poly/src/polynomial/univariate/dense.rs @@ -1,7 +1,7 @@ //! A dense univariate polynomial represented in coefficient form. use crate::{ univariate::{DenseOrSparsePolynomial, SparsePolynomial}, - EvaluationDomain, Evaluations, GeneralEvaluationDomain, Polynomial, UVPolynomial, + DenseUVPolynomial, EvaluationDomain, Evaluations, GeneralEvaluationDomain, Polynomial, }; use ark_ff::{FftField, Field, Zero}; use ark_serialize::*; @@ -94,7 +94,7 @@ impl DensePolynomial { } } -impl UVPolynomial for DensePolynomial { +impl DenseUVPolynomial for DensePolynomial { /// Constructs a new polynomial from a list of coefficients. fn from_coefficients_slice(coeffs: &[F]) -> Self { Self::from_coefficients_vec(coeffs.to_vec()) diff --git a/poly/src/polynomial/univariate/mod.rs b/poly/src/polynomial/univariate/mod.rs index d30ce0ac6..974f939d5 100644 --- a/poly/src/polynomial/univariate/mod.rs +++ b/poly/src/polynomial/univariate/mod.rs @@ -1,6 +1,6 @@ //! Work with sparse and dense polynomials. -use crate::{EvaluationDomain, Evaluations, Polynomial, UVPolynomial}; +use crate::{DenseUVPolynomial, EvaluationDomain, Evaluations, Polynomial}; use ark_ff::{FftField, Field, Zero}; use ark_std::{borrow::Cow, convert::TryInto, vec::Vec}; use DenseOrSparsePolynomial::*; diff --git a/poly/src/polynomial/univariate/sparse.rs b/poly/src/polynomial/univariate/sparse.rs index 846d1b05f..88943e838 100644 --- a/poly/src/polynomial/univariate/sparse.rs +++ b/poly/src/polynomial/univariate/sparse.rs @@ -2,7 +2,7 @@ use crate::{ polynomial::Polynomial, univariate::{DenseOrSparsePolynomial, DensePolynomial}, - EvaluationDomain, Evaluations, UVPolynomial, + DenseUVPolynomial, EvaluationDomain, Evaluations, }; use ark_ff::{FftField, Field, Zero}; use ark_serialize::{CanonicalDeserialize, CanonicalSerialize, SerializationError};