From 4c039b7bbe74fbce48c465d8988f73d2d0a6cafb Mon Sep 17 00:00:00 2001 From: "Wonyong Kim(Ryan Kim)" Date: Tue, 26 Sep 2023 14:58:22 +0900 Subject: [PATCH 1/2] refac(math): remove `Evaluate()` and `Degree()` from `Polynomial` A function definition in `Polynomial` doesn't help in any respects. It's just a code duplication. In addition, a function signature of `Evaluate()` is not matched to one in `MultivariatePolynomial`. --- .../multivariate/multivariate_polynomial.h | 24 +++++-------------- tachyon/math/polynomials/polynomial.h | 22 +---------------- .../univariate/univariate_polynomial.h | 20 +++++----------- 3 files changed, 13 insertions(+), 53 deletions(-) diff --git a/tachyon/math/polynomials/multivariate/multivariate_polynomial.h b/tachyon/math/polynomials/multivariate/multivariate_polynomial.h index f87a94efd..b3563f65e 100644 --- a/tachyon/math/polynomials/multivariate/multivariate_polynomial.h +++ b/tachyon/math/polynomials/multivariate/multivariate_polynomial.h @@ -25,10 +25,6 @@ class MultivariatePolynomial constexpr MultivariatePolynomial(Coefficients&& coefficients) : coefficients_(std::move(coefficients)) {} - constexpr Field Evaluate(const std::vector& points) const { - return DoEvaluate(points); - } - constexpr static MultivariatePolynomial Zero() { return MultivariatePolynomial(Coefficients::Zero()); } @@ -67,6 +63,12 @@ class MultivariatePolynomial return coefficients_.GetLeadingCoefficient(); } + constexpr size_t Degree() const { return coefficients_.Degree(); } + + constexpr Field Evaluate(const std::vector& points) const { + return coefficients_.Evaluate(points); + } + std::string ToString() const { return coefficients_.ToString(); } #define OPERATION_METHOD(Name) \ @@ -102,16 +104,8 @@ class MultivariatePolynomial #undef OPERATION_METHOD private: - friend class Polynomial>; friend class internal::MultivariatePolynomialOp; - // Polynomial methods - constexpr size_t DoDegree() const { return coefficients_.Degree(); } - - constexpr Field DoEvaluate(const std::vector& points) const { - return coefficients_.Evaluate(points); - } - Coefficients coefficients_; }; @@ -121,12 +115,6 @@ std::ostream& operator<<(std::ostream& os, return os << p.ToString(); } -template -class CoefficientsTraits> { - public: - using Field = typename Coefficients::Field; -}; - template using SparseMultivariatePolynomial = MultivariatePolynomial>; diff --git a/tachyon/math/polynomials/polynomial.h b/tachyon/math/polynomials/polynomial.h index c61bfc4c1..92c711af4 100644 --- a/tachyon/math/polynomials/polynomial.h +++ b/tachyon/math/polynomials/polynomial.h @@ -1,34 +1,14 @@ #ifndef TACHYON_MATH_POLYNOMIALS_POLYNOMIAL_H_ #define TACHYON_MATH_POLYNOMIALS_POLYNOMIAL_H_ -#include - #include "tachyon/base/no_destructor.h" #include "tachyon/math/base/identities.h" #include "tachyon/math/base/rings.h" namespace tachyon::math { -template -class CoefficientsTraits; - template -class Polynomial : public Ring { - public: - constexpr static const size_t kMaxDegree = Derived::kMaxDegree; - - using Field = typename CoefficientsTraits::Field; - - constexpr size_t Degree() const { - const Derived* derived = static_cast(this); - return derived->DoDegree(); - } - - constexpr Field Evaluate(const Field& point) const { - const Derived* derived = static_cast(this); - return derived->DoEvaluate(point); - } -}; +class Polynomial : public Ring {}; template class MultiplicativeIdentity> { diff --git a/tachyon/math/polynomials/univariate/univariate_polynomial.h b/tachyon/math/polynomials/univariate/univariate_polynomial.h index ef3991291..6dabf3ad4 100644 --- a/tachyon/math/polynomials/univariate/univariate_polynomial.h +++ b/tachyon/math/polynomials/univariate/univariate_polynomial.h @@ -62,6 +62,12 @@ class UnivariatePolynomial return coefficients_.GetLeadingCoefficient(); } + constexpr size_t Degree() const { return coefficients_.Degree(); } + + constexpr Field Evaluate(const Field& point) const { + return coefficients_.Evaluate(point); + } + auto ToSparse() const { return internal::UnivariatePolynomialOp::ToSparsePolynomial( *this); @@ -149,16 +155,8 @@ class UnivariatePolynomial } private: - friend class Polynomial>; friend class internal::UnivariatePolynomialOp; - // Polynomial methods - constexpr size_t DoDegree() const { return coefficients_.Degree(); } - - constexpr Field DoEvaluate(const Field& point) const { - return coefficients_.Evaluate(point); - } - Coefficients coefficients_; }; @@ -168,12 +166,6 @@ std::ostream& operator<<(std::ostream& os, return os << p.ToString(); } -template -class CoefficientsTraits> { - public: - using Field = typename Coefficients::Field; -}; - template using DenseUnivariatePolynomial = UnivariatePolynomial>; From 829209eb25c01c17a6db32fd8ef8355a4f8748ea Mon Sep 17 00:00:00 2001 From: "Wonyong Kim(Ryan Kim)" Date: Tue, 26 Sep 2023 15:04:33 +0900 Subject: [PATCH 2/2] refac(math): remove unused `Additive|MultiplicativeIdentity` They are added to support some features such as `Matrix::Identity()` in the past. But thanks to #23, we don't need this anymore. Without this, you can use `Eigen::Matrix::Identity()` for identity matrix. Related: #23 --- tachyon/math/base/BUILD.bazel | 5 --- tachyon/math/base/gmp/BUILD.bazel | 12 ------- tachyon/math/base/gmp/gmp_identities.h | 35 ------------------- .../math/base/gmp/gmp_identities_unittest.cc | 19 ---------- tachyon/math/base/identities.h | 34 ------------------ tachyon/math/elliptic_curves/BUILD.bazel | 5 +-- tachyon/math/elliptic_curves/affine_point.h | 26 -------------- tachyon/math/elliptic_curves/jacobian_point.h | 27 -------------- tachyon/math/elliptic_curves/msm/BUILD.bazel | 1 - tachyon/math/elliptic_curves/msm/glv.h | 1 - tachyon/math/elliptic_curves/point_xyzz.h | 27 -------------- .../math/elliptic_curves/projective_point.h | 27 -------------- tachyon/math/finite_fields/BUILD.bazel | 2 -- tachyon/math/finite_fields/prime_field.h | 27 -------------- tachyon/math/finite_fields/prime_field_gmp.h | 26 -------------- tachyon/math/finite_fields/prime_field_gpu.h | 27 -------------- .../finite_fields/prime_field_gpu_debug.h | 27 -------------- tachyon/math/polynomials/BUILD.bazel | 6 ++-- .../math/polynomials/multivariate/BUILD.bazel | 1 - tachyon/math/polynomials/polynomial.h | 28 --------------- .../math/polynomials/univariate/BUILD.bazel | 1 - 21 files changed, 3 insertions(+), 361 deletions(-) delete mode 100644 tachyon/math/base/gmp/gmp_identities.h delete mode 100644 tachyon/math/base/gmp/gmp_identities_unittest.cc delete mode 100644 tachyon/math/base/identities.h diff --git a/tachyon/math/base/BUILD.bazel b/tachyon/math/base/BUILD.bazel index 0e3725e58..33e170881 100644 --- a/tachyon/math/base/BUILD.bazel +++ b/tachyon/math/base/BUILD.bazel @@ -64,11 +64,6 @@ tachyon_cc_library( deps = [":semigroups"], ) -tachyon_cc_library( - name = "identities", - hdrs = ["identities.h"], -) - tachyon_cc_library( name = "rings", hdrs = ["rings.h"], diff --git a/tachyon/math/base/gmp/BUILD.bazel b/tachyon/math/base/gmp/BUILD.bazel index 8f3a631d2..260fd3c74 100644 --- a/tachyon/math/base/gmp/BUILD.bazel +++ b/tachyon/math/base/gmp/BUILD.bazel @@ -20,16 +20,6 @@ tachyon_cc_library( ], ) -tachyon_cc_library( - name = "gmp_identities", - hdrs = ["gmp_identities.h"], - deps = [ - "//tachyon/base:no_destructor", - "//tachyon/math/base:identities", - "@local_config_gmp//:gmp", - ], -) - tachyon_cc_library( name = "gmp_util", srcs = ["gmp_util.cc"], @@ -56,11 +46,9 @@ tachyon_cc_test( name = "gmp_unittests", size = "small", srcs = [ - "gmp_identities_unittest.cc", "gmp_util_unittest.cc", ], deps = [ - ":gmp_identities", ":gmp_util", "//tachyon/build:build_config", ], diff --git a/tachyon/math/base/gmp/gmp_identities.h b/tachyon/math/base/gmp/gmp_identities.h deleted file mode 100644 index 22ca07ad0..000000000 --- a/tachyon/math/base/gmp/gmp_identities.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef TACHYON_MATH_BASE_GMP_GMP_IDENTITIES_H_ -#define TACHYON_MATH_BASE_GMP_GMP_IDENTITIES_H_ - -#include "third_party/gmp/include/gmpxx.h" - -#include "tachyon/base/no_destructor.h" -#include "tachyon/math/base/identities.h" - -namespace tachyon::math { - -template <> -class MultiplicativeIdentity { - public: - static const mpz_class& One() { - static base::NoDestructor one(1); - return *one; - } - - static bool IsOne(const mpz_class& value) { return value == One(); } -}; - -template <> -class AdditiveIdentity { - public: - static const mpz_class& Zero() { - static base::NoDestructor zero(0); - return *zero; - } - - static bool IsZero(const mpz_class& value) { return value == Zero(); } -}; - -} // namespace tachyon::math - -#endif // TACHYON_MATH_BASE_GMP_GMP_IDENTITIES_H_ diff --git a/tachyon/math/base/gmp/gmp_identities_unittest.cc b/tachyon/math/base/gmp/gmp_identities_unittest.cc deleted file mode 100644 index 2695921cd..000000000 --- a/tachyon/math/base/gmp/gmp_identities_unittest.cc +++ /dev/null @@ -1,19 +0,0 @@ -#include "tachyon/math/base/gmp/gmp_identities.h" - -#include "gtest/gtest.h" - -namespace tachyon::math { - -TEST(GmpIdentities, MultiplicativeIdentity) { - EXPECT_EQ(One(), mpz_class(1)); - EXPECT_TRUE(IsOne(mpz_class(1))); - EXPECT_FALSE(IsOne(mpz_class(0))); -} - -TEST(GmpIdentities, AdditiveIdentity) { - EXPECT_EQ(Zero(), mpz_class(0)); - EXPECT_TRUE(IsZero(mpz_class(0))); - EXPECT_FALSE(IsZero(mpz_class(1))); -} - -} // namespace tachyon::math diff --git a/tachyon/math/base/identities.h b/tachyon/math/base/identities.h deleted file mode 100644 index b5fc345fb..000000000 --- a/tachyon/math/base/identities.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef TACHYON_MATH_BASE_IDENTITIES_H_ -#define TACHYON_MATH_BASE_IDENTITIES_H_ - -namespace tachyon::math { - -template -class MultiplicativeIdentity; - -template -const T& One() { - return MultiplicativeIdentity::One(); -} - -template -constexpr bool IsOne(const T& value) { - return MultiplicativeIdentity::IsOne(value); -} - -template -class AdditiveIdentity; - -template -const T& Zero() { - return AdditiveIdentity::Zero(); -} - -template -constexpr bool IsZero(const T& value) { - return AdditiveIdentity::IsZero(value); -} - -} // namespace tachyon::math - -#endif // TACHYON_MATH_BASE_IDENTITIES_H_ diff --git a/tachyon/math/elliptic_curves/BUILD.bazel b/tachyon/math/elliptic_curves/BUILD.bazel index 2400cc8d7..0eedb6096 100644 --- a/tachyon/math/elliptic_curves/BUILD.bazel +++ b/tachyon/math/elliptic_curves/BUILD.bazel @@ -14,8 +14,5 @@ tachyon_cc_library( "projective_point.h", "semigroups.h", ], - deps = [ - "//tachyon/base:no_destructor", - "//tachyon/math/base:identities", - ], + deps = ["//tachyon/base:no_destructor"], ) diff --git a/tachyon/math/elliptic_curves/affine_point.h b/tachyon/math/elliptic_curves/affine_point.h index 59e703506..ec7080468 100644 --- a/tachyon/math/elliptic_curves/affine_point.h +++ b/tachyon/math/elliptic_curves/affine_point.h @@ -20,32 +20,6 @@ JacobianPoint operator*(const ScalarField& v, return point * v; } -template -class MultiplicativeIdentity> { - public: - using P = AffinePoint; - - static const P& One() { - static base::NoDestructor

one(P::One()); - return *one; - } - - constexpr static bool IsOne(const P& value) { return value.IsOne(); } -}; - -template -class AdditiveIdentity> { - public: - using P = AffinePoint; - - static const P& Zero() { - static base::NoDestructor

zero(P::Zero()); - return *zero; - } - - constexpr static bool IsZero(const P& value) { return value.IsZero(); } -}; - template struct PointConversions, AffinePoint> { constexpr static const AffinePoint& Convert( diff --git a/tachyon/math/elliptic_curves/jacobian_point.h b/tachyon/math/elliptic_curves/jacobian_point.h index 6477f3489..2542df0c9 100644 --- a/tachyon/math/elliptic_curves/jacobian_point.h +++ b/tachyon/math/elliptic_curves/jacobian_point.h @@ -4,7 +4,6 @@ #include #include "tachyon/base/no_destructor.h" -#include "tachyon/math/base/identities.h" #include "tachyon/math/elliptic_curves/point_conversions_forward.h" namespace tachyon::math { @@ -23,32 +22,6 @@ JacobianPoint operator*(const ScalarField& v, return point * v; } -template -class MultiplicativeIdentity> { - public: - using P = JacobianPoint; - - static const P& One() { - static base::NoDestructor

one(P::One()); - return *one; - } - - constexpr static bool IsOne(const P& value) { return value.IsOne(); } -}; - -template -class AdditiveIdentity> { - public: - using P = JacobianPoint; - - static const P& Zero() { - static base::NoDestructor

zero(P::Zero()); - return *zero; - } - - constexpr static bool IsZero(const P& value) { return value.IsZero(); } -}; - template struct PointConversions, JacobianPoint> { constexpr static const JacobianPoint& Convert( diff --git a/tachyon/math/elliptic_curves/msm/BUILD.bazel b/tachyon/math/elliptic_curves/msm/BUILD.bazel index 1c3d8eaec..532df805a 100644 --- a/tachyon/math/elliptic_curves/msm/BUILD.bazel +++ b/tachyon/math/elliptic_curves/msm/BUILD.bazel @@ -15,7 +15,6 @@ tachyon_cc_library( "//tachyon/base:static_storage", "//tachyon/math/base:bit_iterator", "//tachyon/math/base/gmp:bit_traits", - "//tachyon/math/base/gmp:gmp_identities", "//tachyon/math/base/gmp:signed_value", "//tachyon/math/elliptic_curves:points", "//tachyon/math/matrix:gmp_num_traits", diff --git a/tachyon/math/elliptic_curves/msm/glv.h b/tachyon/math/elliptic_curves/msm/glv.h index 9ffe94e44..cc2802ba3 100644 --- a/tachyon/math/elliptic_curves/msm/glv.h +++ b/tachyon/math/elliptic_curves/msm/glv.h @@ -4,7 +4,6 @@ #include "tachyon/base/static_storage.h" #include "tachyon/math/base/bit_iterator.h" #include "tachyon/math/base/gmp/bit_traits.h" -#include "tachyon/math/base/gmp/gmp_identities.h" #include "tachyon/math/base/gmp/signed_value.h" #include "tachyon/math/elliptic_curves/affine_point.h" #include "tachyon/math/elliptic_curves/jacobian_point.h" diff --git a/tachyon/math/elliptic_curves/point_xyzz.h b/tachyon/math/elliptic_curves/point_xyzz.h index 2c8cde643..3ad34b384 100644 --- a/tachyon/math/elliptic_curves/point_xyzz.h +++ b/tachyon/math/elliptic_curves/point_xyzz.h @@ -4,7 +4,6 @@ #include #include "tachyon/base/no_destructor.h" -#include "tachyon/math/base/identities.h" #include "tachyon/math/elliptic_curves/point_conversions_forward.h" namespace tachyon::math { @@ -23,32 +22,6 @@ PointXYZZ operator*(const ScalarField& v, return point * v; } -template -class MultiplicativeIdentity> { - public: - using P = PointXYZZ; - - static const P& One() { - static base::NoDestructor

one(P::One()); - return *one; - } - - constexpr static bool IsOne(const P& value) { return value.IsOne(); } -}; - -template -class AdditiveIdentity> { - public: - using P = PointXYZZ; - - static const P& Zero() { - static base::NoDestructor

zero(P::Zero()); - return *zero; - } - - constexpr static bool IsZero(const P& value) { return value.IsZero(); } -}; - template struct PointConversions, PointXYZZ> { constexpr static const PointXYZZ& Convert( diff --git a/tachyon/math/elliptic_curves/projective_point.h b/tachyon/math/elliptic_curves/projective_point.h index e9696d926..ef7f5d339 100644 --- a/tachyon/math/elliptic_curves/projective_point.h +++ b/tachyon/math/elliptic_curves/projective_point.h @@ -4,7 +4,6 @@ #include #include "tachyon/base/no_destructor.h" -#include "tachyon/math/base/identities.h" #include "tachyon/math/elliptic_curves/point_conversions_forward.h" namespace tachyon::math { @@ -24,32 +23,6 @@ ProjectivePoint operator*(const ScalarField& v, return point * v; } -template -class MultiplicativeIdentity> { - public: - using P = ProjectivePoint; - - static const P& One() { - static base::NoDestructor

one(P::One()); - return *one; - } - - constexpr static bool IsOne(const P& value) { return value.IsOne(); } -}; - -template -class AdditiveIdentity> { - public: - using P = ProjectivePoint; - - static const P& Zero() { - static base::NoDestructor

zero(P::Zero()); - return *zero; - } - - constexpr static bool IsZero(const P& value) { return value.IsZero(); } -}; - template struct PointConversions, ProjectivePoint> { constexpr static const ProjectivePoint& Convert( diff --git a/tachyon/math/finite_fields/BUILD.bazel b/tachyon/math/finite_fields/BUILD.bazel index ac56d0cb9..b60671788 100644 --- a/tachyon/math/finite_fields/BUILD.bazel +++ b/tachyon/math/finite_fields/BUILD.bazel @@ -56,7 +56,6 @@ tachyon_cc_library( "//tachyon/base:no_destructor", "//tachyon/base/strings:string_util", "//tachyon/math/base:field", - "//tachyon/math/base:identities", "//tachyon/math/base/gmp:gmp_util", ], ) @@ -72,7 +71,6 @@ tachyon_cc_library( "//tachyon/base/containers:adapters", "//tachyon/base/strings:string_util", "//tachyon/math/base:arithmetics", - "//tachyon/math/base:identities", "//tachyon/math/base/gmp:gmp_util", "@com_google_googletest//:gtest_prod", ], diff --git a/tachyon/math/finite_fields/prime_field.h b/tachyon/math/finite_fields/prime_field.h index 0a0d5c709..3750f4085 100644 --- a/tachyon/math/finite_fields/prime_field.h +++ b/tachyon/math/finite_fields/prime_field.h @@ -12,7 +12,6 @@ #include "tachyon/math/base/arithmetics.h" #include "tachyon/math/base/big_int.h" #include "tachyon/math/base/gmp/gmp_util.h" -#include "tachyon/math/base/identities.h" #include "tachyon/math/finite_fields/modulus.h" #include "tachyon/math/finite_fields/prime_field_base.h" #include "tachyon/math/finite_fields/prime_field_forward.h" @@ -297,32 +296,6 @@ std::ostream& operator<<(std::ostream& os, const PrimeField& f) { return os << f.ToString(); } -template -class MultiplicativeIdentity> { - public: - using F = PrimeField; - - static const F& One() { - static F one(F::One()); - return one; - } - - constexpr static bool IsOne(const F& value) { return value.IsOne(); } -}; - -template -class AdditiveIdentity> { - public: - using F = PrimeField; - - static const F& Zero() { - static F zero(F::Zero()); - return zero; - } - - constexpr static bool IsZero(const F& value) { return value.IsZero(); } -}; - } // namespace tachyon::math #endif // TACHYON_MATH_FINITE_FIELDS_PRIME_FIELD_H_ diff --git a/tachyon/math/finite_fields/prime_field_gmp.h b/tachyon/math/finite_fields/prime_field_gmp.h index acc3c7123..e53f30b8e 100644 --- a/tachyon/math/finite_fields/prime_field_gmp.h +++ b/tachyon/math/finite_fields/prime_field_gmp.h @@ -241,32 +241,6 @@ std::ostream& operator<<(std::ostream& os, const PrimeFieldGmp& f) { return os << f.ToString(); } -template -class MultiplicativeIdentity> { - public: - using F = PrimeFieldGmp; - - static const F& One() { - static base::NoDestructor one(F::One()); - return *one; - } - - constexpr static bool IsOne(const F& value) { return value.IsOne(); } -}; - -template -class AdditiveIdentity> { - public: - using F = PrimeFieldGmp; - - static const F& Zero() { - static base::NoDestructor zero(F::Zero()); - return *zero; - } - - constexpr static bool IsZero(const F& value) { return value.IsZero(); } -}; - } // namespace tachyon::math #endif // TACHYON_MATH_FINITE_FIELDS_PRIME_FIELD_GMP_H_ diff --git a/tachyon/math/finite_fields/prime_field_gpu.h b/tachyon/math/finite_fields/prime_field_gpu.h index e9bd71dd3..6082b7d63 100644 --- a/tachyon/math/finite_fields/prime_field_gpu.h +++ b/tachyon/math/finite_fields/prime_field_gpu.h @@ -14,7 +14,6 @@ #include "tachyon/math/base/arithmetics.h" #include "tachyon/math/base/big_int.h" #include "tachyon/math/base/gmp/gmp_util.h" -#include "tachyon/math/base/identities.h" #include "tachyon/math/finite_fields/kernels/carry_chain.h" #include "tachyon/math/finite_fields/modulus.h" #include "tachyon/math/finite_fields/prime_field.h" @@ -416,32 +415,6 @@ std::ostream& operator<<(std::ostream& os, const PrimeFieldGpu& f) { return os << f.ToString(); } -template -class MultiplicativeIdentity> { - public: - using F = PrimeFieldGpu; - - static const F& One() { - static F one(F::One()); - return one; - } - - constexpr static bool IsOne(const F& value) { return value.IsOne(); } -}; - -template -class AdditiveIdentity> { - public: - using F = PrimeFieldGpu; - - static const F& Zero() { - static F zero(F::Zero()); - return zero; - } - - constexpr static bool IsZero(const F& value) { return value.IsZero(); } -}; - } // namespace tachyon::math #endif // TACHYON_MATH_FINITE_FIELDS_PRIME_FIELD_CUDA_H_ diff --git a/tachyon/math/finite_fields/prime_field_gpu_debug.h b/tachyon/math/finite_fields/prime_field_gpu_debug.h index bafc0dd28..bd5925ad2 100644 --- a/tachyon/math/finite_fields/prime_field_gpu_debug.h +++ b/tachyon/math/finite_fields/prime_field_gpu_debug.h @@ -11,7 +11,6 @@ #include "tachyon/math/base/arithmetics.h" #include "tachyon/math/base/big_int.h" #include "tachyon/math/base/gmp/gmp_util.h" -#include "tachyon/math/base/identities.h" #include "tachyon/math/finite_fields/carry_chain.h" #include "tachyon/math/finite_fields/modulus.h" #include "tachyon/math/finite_fields/prime_field.h" @@ -377,32 +376,6 @@ std::ostream& operator<<(std::ostream& os, return os << f.ToString(); } -template -class MultiplicativeIdentity> { - public: - using F = PrimeFieldGpuDebug; - - static const F& One() { - static F one(F::One()); - return one; - } - - constexpr static bool IsOne(const F& value) { return value.IsOne(); } -}; - -template -class AdditiveIdentity> { - public: - using F = PrimeFieldGpuDebug; - - static const F& Zero() { - static F zero(F::Zero()); - return zero; - } - - constexpr static bool IsZero(const F& value) { return value.IsZero(); } -}; - } // namespace tachyon::math #endif // TACHYON_MATH_FINITE_FIELDS_PRIME_FIELD_GPU_DEBUG_H_ diff --git a/tachyon/math/polynomials/BUILD.bazel b/tachyon/math/polynomials/BUILD.bazel index 5816074c1..22868c9f6 100644 --- a/tachyon/math/polynomials/BUILD.bazel +++ b/tachyon/math/polynomials/BUILD.bazel @@ -1,11 +1,9 @@ -load("//bazel:tachyon_cc.bzl", "tachyon_cc_library", "tachyon_cc_test") +load("//bazel:tachyon_cc.bzl", "tachyon_cc_library") package(default_visibility = ["//visibility:public"]) tachyon_cc_library( name = "polynomial", hdrs = ["polynomial.h"], - deps = [ - "//tachyon/math/base:rings", - ], + deps = ["//tachyon/math/base:rings"], ) diff --git a/tachyon/math/polynomials/multivariate/BUILD.bazel b/tachyon/math/polynomials/multivariate/BUILD.bazel index 48d36e5ee..1bf04bcd1 100644 --- a/tachyon/math/polynomials/multivariate/BUILD.bazel +++ b/tachyon/math/polynomials/multivariate/BUILD.bazel @@ -16,7 +16,6 @@ tachyon_cc_library( "//tachyon/base/containers:cxx20_erase", "//tachyon/base/ranges:algorithm", "//tachyon/base/strings:string_util", - "//tachyon/math/base:identities", "//tachyon/math/polynomials:polynomial", "@com_google_absl//absl/numeric:bits", "@com_google_absl//absl/types:span", diff --git a/tachyon/math/polynomials/polynomial.h b/tachyon/math/polynomials/polynomial.h index 92c711af4..a443f30aa 100644 --- a/tachyon/math/polynomials/polynomial.h +++ b/tachyon/math/polynomials/polynomial.h @@ -1,8 +1,6 @@ #ifndef TACHYON_MATH_POLYNOMIALS_POLYNOMIAL_H_ #define TACHYON_MATH_POLYNOMIALS_POLYNOMIAL_H_ -#include "tachyon/base/no_destructor.h" -#include "tachyon/math/base/identities.h" #include "tachyon/math/base/rings.h" namespace tachyon::math { @@ -10,32 +8,6 @@ namespace tachyon::math { template class Polynomial : public Ring {}; -template -class MultiplicativeIdentity> { - public: - using P = Polynomial; - - static const P& One() { - static base::NoDestructor

one(P::One()); - return *one; - } - - constexpr static bool IsOne(const P& value) { return value.IsOne(); } -}; - -template -class AdditiveIdentity> { - public: - using P = Polynomial; - - static const P& Zero() { - static base::NoDestructor

zero(P::Zero()); - return *zero; - } - - constexpr static bool IsZero(const P& value) { return value.IsZero(); } -}; - } // namespace tachyon::math #endif // TACHYON_MATH_POLYNOMIALS_POLYNOMIAL_H_ diff --git a/tachyon/math/polynomials/univariate/BUILD.bazel b/tachyon/math/polynomials/univariate/BUILD.bazel index 194a912a0..57b6af5db 100644 --- a/tachyon/math/polynomials/univariate/BUILD.bazel +++ b/tachyon/math/polynomials/univariate/BUILD.bazel @@ -17,7 +17,6 @@ tachyon_cc_library( "//tachyon/base/ranges:algorithm", "//tachyon/base/strings:string_util", "//tachyon/math/base:arithmetics_results", - "//tachyon/math/base:identities", "//tachyon/math/polynomials:polynomial", "@com_google_absl//absl/numeric:bits", "@com_google_absl//absl/types:span",