Skip to content

Commit

Permalink
refac: rename DoDoubleXXX to DoubleImplXXX
Browse files Browse the repository at this point in the history
This keeps consistency with other operations that have `DoXXX` as
a private method.
  • Loading branch information
chokobole committed Apr 18, 2024
1 parent 4ae6575 commit 5c7a951
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions tachyon/math/base/rational_field.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ class RationalField : public Field<RationalField<F>> {
return *this;
}

constexpr RationalField DoDouble() const {
constexpr RationalField DoubleImpl() const {
return {numerator_.Double(), denominator_};
}

constexpr RationalField& DoDoubleInPlace() {
constexpr RationalField& DoubleImplInPlace() {
numerator_.DoubleInPlace();
return *this;
}
Expand Down
12 changes: 6 additions & 6 deletions tachyon/math/base/semigroups.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace internal {
SUPPORTS_BINARY_OPERATOR(Mul);
SUPPORTS_UNARY_OPERATOR(SquareImpl);
SUPPORTS_BINARY_OPERATOR(Add);
SUPPORTS_UNARY_OPERATOR(DoDouble);
SUPPORTS_UNARY_OPERATOR(DoubleImpl);

template <typename T, typename = void>
struct SupportsToBigInt : std::false_type {};
Expand Down Expand Up @@ -245,19 +245,19 @@ class AdditiveSemigroup {

// a.Double(): 2a
[[nodiscard]] constexpr auto Double() const {
if constexpr (internal::SupportsDoDouble<G>::value) {
if constexpr (internal::SupportsDoubleImpl<G>::value) {
const G* g = static_cast<const G*>(this);
return g->DoDouble();
return g->DoubleImpl();
} else {
return operator+(static_cast<const G&>(*this));
}
}

// a.DoubleInPlace(): a = 2a
constexpr G& DoubleInPlace() {
if constexpr (internal::SupportsDoDoubleInPlace<G>::value) {
if constexpr (internal::SupportsDoubleImplInPlace<G>::value) {
G* g = static_cast<G*>(this);
return g->DoDoubleInPlace();
return g->DoubleImplInPlace();
} else if constexpr (internal::SupportsAddInPlace<G, G>::value) {
return operator+=(static_cast<const G&>(*this));
} else {
Expand Down Expand Up @@ -416,7 +416,7 @@ class AdditiveSemigroup {
auto it = BitIteratorBE<BigInt<N>>::begin(&scalar, true);
auto end = BitIteratorBE<BigInt<N>>::end(&scalar);
while (it != end) {
if constexpr (internal::SupportsDoDoubleInPlace<G>::value ||
if constexpr (internal::SupportsDoubleImplInPlace<G>::value ||
internal::SupportsAddInPlace<G, G>::value) {
ret.DoubleInPlace();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ class JacobianPoint<
constexpr JacobianPoint& AddInPlace(const JacobianPoint& other);
constexpr JacobianPoint Add(const AffinePoint<Curve>& other) const;
constexpr JacobianPoint& AddInPlace(const AffinePoint<Curve>& other);
constexpr JacobianPoint DoDouble() const;
constexpr JacobianPoint& DoDoubleInPlace();
constexpr JacobianPoint DoubleImpl() const;
constexpr JacobianPoint& DoubleImplInPlace();

// AdditiveGroup methods
constexpr JacobianPoint Negate() const { return {x_, -y_, z_}; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ constexpr void CLASS::DoAdd(const JacobianPoint& a, const AffinePoint<Curve>& b,
}

template <typename Curve>
constexpr CLASS CLASS::DoDouble() const {
constexpr CLASS CLASS::DoubleImpl() const {
if (IsZero()) {
return JacobianPoint::Zero();
}
Expand All @@ -208,7 +208,7 @@ constexpr CLASS CLASS::DoDouble() const {
}

template <typename Curve>
constexpr CLASS& CLASS::DoDoubleInPlace() {
constexpr CLASS& CLASS::DoubleImplInPlace() {
if (IsZero()) {
return *this;
}
Expand Down
4 changes: 2 additions & 2 deletions tachyon/math/elliptic_curves/short_weierstrass/point_xyzz.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ class PointXYZZ<_Curve,
constexpr PointXYZZ& AddInPlace(const PointXYZZ& other);
constexpr PointXYZZ Add(const AffinePoint<Curve>& other) const;
constexpr PointXYZZ& AddInPlace(const AffinePoint<Curve>& other);
constexpr PointXYZZ DoDouble() const;
constexpr PointXYZZ& DoDoubleInPlace();
constexpr PointXYZZ DoubleImpl() const;
constexpr PointXYZZ& DoubleImplInPlace();

// AdditiveGroup methods
constexpr PointXYZZ Negate() const { return {x_, -y_, zz_, zzz_}; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ constexpr void CLASS::DoAdd(const PointXYZZ& a, const AffinePoint<Curve>& b,
}

template <typename Curve>
constexpr CLASS CLASS::DoDouble() const {
constexpr CLASS CLASS::DoubleImpl() const {
if (IsZero()) {
return PointXYZZ::Zero();
}
Expand All @@ -186,7 +186,7 @@ constexpr CLASS CLASS::DoDouble() const {
}

template <typename Curve>
constexpr CLASS& CLASS::DoDoubleInPlace() {
constexpr CLASS& CLASS::DoubleImplInPlace() {
if (IsZero()) {
return *this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ class ProjectivePoint<
constexpr ProjectivePoint& AddInPlace(const ProjectivePoint& other);
constexpr ProjectivePoint Add(const AffinePoint<Curve>& other) const;
constexpr ProjectivePoint& AddInPlace(const AffinePoint<Curve>& other);
constexpr ProjectivePoint DoDouble() const;
constexpr ProjectivePoint& DoDoubleInPlace();
constexpr ProjectivePoint DoubleImpl() const;
constexpr ProjectivePoint& DoubleImplInPlace();

// AdditiveGroup methods
constexpr ProjectivePoint Negate() const { return {x_, -y_, z_}; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ constexpr void CLASS::DoAdd(const ProjectivePoint& a,
}

template <typename Curve>
constexpr CLASS CLASS::DoDouble() const {
constexpr CLASS CLASS::DoubleImpl() const {
if (IsZero()) {
return ProjectivePoint::Zero();
}
Expand All @@ -187,7 +187,7 @@ constexpr CLASS CLASS::DoDouble() const {
}

template <typename Curve>
constexpr CLASS& CLASS::DoDoubleInPlace() {
constexpr CLASS& CLASS::DoubleImplInPlace() {
if (IsZero()) {
return *this;
}
Expand Down
4 changes: 2 additions & 2 deletions tachyon/math/finite_fields/cubic_extension_field.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,15 @@ class CubicExtensionField : public CyclotomicMultiplicativeSubgroup<Derived> {
return *static_cast<Derived*>(this);
}

constexpr Derived DoDouble() const {
constexpr Derived DoubleImpl() const {
return {
c0_.Double(),
c1_.Double(),
c2_.Double(),
};
}

constexpr Derived& DoDoubleInPlace() {
constexpr Derived& DoubleImplInPlace() {
c0_.DoubleInPlace();
c1_.DoubleInPlace();
c2_.DoubleInPlace();
Expand Down
4 changes: 2 additions & 2 deletions tachyon/math/finite_fields/prime_field_generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class PrimeField<_Config, std::enable_if_t<!_Config::kIsSpecialPrime>> final
return *this;
}

constexpr PrimeField DoDouble() const {
constexpr PrimeField DoubleImpl() const {
PrimeField ret;
uint64_t carry = 0;
ret.value_ = value_.MulBy2(carry);
Expand All @@ -195,7 +195,7 @@ class PrimeField<_Config, std::enable_if_t<!_Config::kIsSpecialPrime>> final
return ret;
}

constexpr PrimeField& DoDoubleInPlace() {
constexpr PrimeField& DoubleImplInPlace() {
uint64_t carry = 0;
value_.MulBy2InPlace(carry);
BigInt<N>::template Clamp<Config::kModulusHasSpareBit>(Config::kModulus,
Expand Down
4 changes: 2 additions & 2 deletions tachyon/math/finite_fields/quadratic_extension_field.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ class QuadraticExtensionField
return *static_cast<Derived*>(this);
}

constexpr Derived DoDouble() const {
constexpr Derived DoubleImpl() const {
return {
c0_.Double(),
c1_.Double(),
};
}

constexpr Derived& DoDoubleInPlace() {
constexpr Derived& DoubleImplInPlace() {
c0_.DoubleInPlace();
c1_.DoubleInPlace();
return *static_cast<Derived*>(this);
Expand Down
4 changes: 2 additions & 2 deletions tachyon/zk/base/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ class Value : public math::Field<Value<T>> {
return Value::Known(*value_ + other);
}

constexpr Value DoDouble() const {
constexpr Value DoubleImpl() const {
if (IsNone()) return Unknown();
return Value::Known(value_->Double());
}

constexpr Value& DoDoubleInPlace() {
constexpr Value& DoubleImplInPlace() {
if (IsNone()) return *this;
value_->DoubleInPlace();
return *this;
Expand Down

0 comments on commit 5c7a951

Please sign in to comment.