From d10bc201579548bc4f24d3f474c55e4a0c461e58 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Sat, 23 Apr 2016 20:24:42 +0900 Subject: [PATCH] start to add Fp2::Dbl --- include/mcl/fp_tower.hpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/include/mcl/fp_tower.hpp b/include/mcl/fp_tower.hpp index ec28d76..e53c8b4 100644 --- a/include/mcl/fp_tower.hpp +++ b/include/mcl/fp_tower.hpp @@ -259,6 +259,39 @@ private: py[1] *= aa; Fp::neg(py[1], py[1]); } + struct Dbl; +}; + +template +struct Fp2T::Dbl { + typedef fp::Unit Unit; + typedef typename Fp::Dbl FpDbl; + FpDbl a, b; + static inline void add(Dbl& z, const Dbl& x, const Dbl& y) + { + FpDbl::add(z.a, x.a, y.a); + FpDbl::add(z.b, x.b, y.b); + } + static inline void addNC(Dbl& z, const Dbl& x, const Dbl& y) + { + FpDbl::addNC(z.a, x.a, y.a); + FpDbl::addNC(z.b, x.b, y.b); + } + static inline void sub(Dbl& z, const Dbl& x, const Dbl& y) + { + FpDbl::sub(z.a, x.a, y.a); + FpDbl::sub(z.b, x.b, y.b); + } + static inline void subNC(Dbl& z, const Dbl& x, const Dbl& y) + { + FpDbl::subNC(z.a, x.a, y.a); + FpDbl::subNC(z.b, x.b, y.b); + } + static inline void neg(Dbl& y, const Dbl& x) + { + FpDbl::neg(y.a, x.a); + FpDbl::neg(y.b, x.b); + } }; template Fp Fp2T::xi_a_;