Closed huyuguang closed 6 years ago
I do not make EcT::operator* because the types of arguments of EcT::mul is not same.
I found the Operator
in operator.hpp:
template<class T, class E = Empty<T> >
struct Operator : public E {
template<class S> MCL_FORCE_INLINE T& operator+=(const S& rhs) { T::add(static_cast<T&>(*this), static_cast<const T&>(*this), rhs); return static_cast<T&>(*this); }
template<class S> MCL_FORCE_INLINE T& operator-=(const S& rhs) { T::sub(static_cast<T&>(*this), static_cast<const T&>(*this), rhs); return static_cast<T&>(*this); }
template<class S> friend MCL_FORCE_INLINE T operator+(const T& a, const S& b) { T c; T::add(c, a, b); return c; }
template<class S> friend MCL_FORCE_INLINE T operator-(const T& a, const S& b) { T c; T::sub(c, a, b); return c; }
template<class S> MCL_FORCE_INLINE T& operator*=(const S& rhs) { T::mul(static_cast<T&>(*this), static_cast<const T&>(*this), rhs)
The template<class S>
also not same with T.
Why not just use the same code in EcT?
The operator* does not need the same types of arguments
Of course, I know it, but Ec::mul overloads three kinds of integer type and I wait to decide whether to implement both E INT and INT E, and I do not think they are necessary functions.
I added E INT and E= INT. https://github.com/herumi/mcl/commit/bb4735dddc22458abacc4ac9714df79e3aff13ba
Why not just use the same code in EcT?
Operator
is for a field class and requires add, sub, mul and div so it can not be applied to EcT, which is an addtive group class.
I added E INT and E= INT. bb4735d
Also add E * Fr
and E *= Fr
, please.
Also add E Fr and E = Fr, please.
https://github.com/herumi/mcl/commit/bb4735dddc22458abacc4ac9714df79e3aff13ba has already supported it.
I found Fp has
operator+-*/,
and EcT hasoperator+-
, but does not haveoperator*
, why? Does here have any essential reasons?