diff --git a/include/mcl/fp_tower.hpp b/include/mcl/fp_tower.hpp index 3acff3f..31f97c8 100644 --- a/include/mcl/fp_tower.hpp +++ b/include/mcl/fp_tower.hpp @@ -141,27 +141,14 @@ public: static void addA(Unit *z, const Unit *x, const Unit *y) { Fp::op_.fpDbl_add(z, x, y, Fp::op_.p); } static void subA(Unit *z, const Unit *x, const Unit *y) { Fp::op_.fpDbl_sub(z, x, y, Fp::op_.p); } static void modA(Unit *z, const Unit *xy) { Fp::op_.fpDbl_mod(z, xy, Fp::op_.p); } - static void (*addPre)(FpDblT& z, const FpDblT& x, const FpDblT& y); - static void (*subPre)(FpDblT& z, const FpDblT& x, const FpDblT& y); - static void addPreC(FpDblT& z, const FpDblT& x, const FpDblT& y) { Fp::op_.fpDbl_addPre(z.v_, x.v_, y.v_); } - static void subPreC(FpDblT& z, const FpDblT& x, const FpDblT& y) { Fp::op_.fpDbl_subPre(z.v_, x.v_, y.v_); } -#else +#endif static void addPre(FpDblT& z, const FpDblT& x, const FpDblT& y) { Fp::op_.fpDbl_addPre(z.v_, x.v_, y.v_); } static void subPre(FpDblT& z, const FpDblT& x, const FpDblT& y) { Fp::op_.fpDbl_subPre(z.v_, x.v_, y.v_); } -#endif /* mul(z, x, y) = mulPre(xy, x, y) + mod(z, xy) */ - static void mulPre(FpDblT& xy, const Fp& x, const Fp& y) - { - const mcl::fp::Op& op = Fp::getOp(); - op.fpDbl_mulPre(xy.v_, x.v_, y.v_); - } - static void sqrPre(FpDblT& xx, const Fp& x) - { - const mcl::fp::Op& op = Fp::getOp(); - op.fpDbl_sqrPre(xx.v_, x.v_); - } + static void mulPre(FpDblT& xy, const Fp& x, const Fp& y) { Fp::op_.fpDbl_mulPre(xy.v_, x.v_, y.v_); } + static void sqrPre(FpDblT& xx, const Fp& x) { Fp::op_.fpDbl_sqrPre(xx.v_, x.v_); } static void mulUnit(FpDblT& z, const FpDblT& x, Unit y) { if (mulSmallUnit(z, x, y)) return; @@ -170,7 +157,7 @@ public: static void init() { #ifdef MCL_XBYAK_DIRECT_CALL - mcl::fp::Op& op = Fp::getOpNonConst(); + mcl::fp::Op& op = Fp::op_; if (op.fpDbl_addA_ == 0) { op.fpDbl_addA_ = addA; } @@ -180,21 +167,12 @@ public: if (op.fpDbl_modA_ == 0) { op.fpDbl_modA_ = modA; } - addPre = fp::func_ptr_cast(op.fpDbl_addPre); - if (addPre == 0) addPre = addPreC; - subPre = fp::func_ptr_cast(op.fpDbl_subPre); - if (subPre == 0) subPre = subPreC; #endif } void operator+=(const FpDblT& x) { add(*this, *this, x); } void operator-=(const FpDblT& x) { sub(*this, *this, x); } }; -#ifdef MCL_XBYAK_DIRECT_CALL -template void (*FpDblT::addPre)(FpDblT&, const FpDblT&, const FpDblT&); -template void (*FpDblT::subPre)(FpDblT&, const FpDblT&, const FpDblT&); -#endif - /* beta = -1 Fp2 = F[i] / (i^2 + 1)