rename Fp::Dbl to FpDbl

dev
MITSUNARI Shigeo 9 years ago
parent 0c974dc82e
commit 7b2d72d4b5
  1. 3
      include/mcl/fp.hpp
  2. 25
      include/mcl/fp_tower.hpp
  3. 2
      test/fp_tower_test.cpp

@ -60,11 +60,10 @@ class FpT : public fp::Operator<FpT<tag, maxBitSize> > {
static fp::Op op_;
template<class tag2, size_t maxBitSize2> friend class FpT;
Unit v_[maxSize];
public:
template<class Fp> friend class FpDblT;
template<class Fp> friend class Fp2T;
template<class Fp> friend struct Fp6T;
public:
class Dbl;
// return pointer to array v_[]
const Unit *getUnit() const { return v_; }
static inline size_t getUnitSize() { return op_.N; }

@ -10,10 +10,9 @@
namespace mcl {
template<class tag, size_t maxBitSize>
class FpT<tag, maxBitSize>::Dbl {
template<class Fp>
class FpDblT {
typedef fp::Unit Unit;
typedef FpT<tag, maxBitSize> Fp;
Unit v_[Fp::maxSize * 2];
public:
static inline size_t getUnitSize() { return Fp::op_.N * 2; }
@ -28,11 +27,11 @@ public:
// QQQ : does not check range of x strictly(use for debug)
void setMpz(const mpz_class& x)
{
if (x < 0) throw cybozu::Exception("Dbl:_setMpz:negative is not supported") << x;
if (x < 0) throw cybozu::Exception("FpDblT:_setMpz:negative is not supported") << x;
const size_t xn = gmp::getUnitSize(x);
const size_t N2 = getUnitSize();
if (xn > N2) {
throw cybozu::Exception("Dbl:setMpz:too large") << x;
throw cybozu::Exception("FpDblT:setMpz:too large") << x;
}
memcpy(v_, gmp::getUnit(x), xn * sizeof(Unit));
memset(v_ + xn, 0, (N2 - xn) * sizeof(Unit));
@ -41,16 +40,16 @@ public:
{
gmp::setArray(x, v_, Fp::op_.N * 2);
}
static inline void add(Dbl& z, const Dbl& x, const Dbl& y) { Fp::op_.fpDbl_add(z.v_, x.v_, y.v_); }
static inline void sub(Dbl& z, const Dbl& x, const Dbl& y) { Fp::op_.fpDbl_sub(z.v_, x.v_, y.v_); }
static inline void addNC(Dbl& z, const Dbl& x, const Dbl& y) { Fp::op_.fpDbl_addNC(z.v_, x.v_, y.v_); }
static inline void subNC(Dbl& z, const Dbl& x, const Dbl& y) { Fp::op_.fpDbl_subNC(z.v_, x.v_, y.v_); }
static inline void add(FpDblT& z, const FpDblT& x, const FpDblT& y) { Fp::op_.fpDbl_add(z.v_, x.v_, y.v_); }
static inline void sub(FpDblT& z, const FpDblT& x, const FpDblT& y) { Fp::op_.fpDbl_sub(z.v_, x.v_, y.v_); }
static inline void addNC(FpDblT& z, const FpDblT& x, const FpDblT& y) { Fp::op_.fpDbl_addNC(z.v_, x.v_, y.v_); }
static inline void subNC(FpDblT& z, const FpDblT& x, const FpDblT& y) { Fp::op_.fpDbl_subNC(z.v_, x.v_, y.v_); }
/*
mul(z, x, y) = mulPre(xy, x, y) + mod(z, xy)
*/
static inline void mulPre(Dbl& xy, const Fp& x, const Fp& y) { Fp::op_.fpDbl_mulPre(xy.v_, x.v_, y.v_); }
static inline void sqrPre(Dbl& xx, const Fp& x) { Fp::op_.fpDbl_sqrPre(xx.v_, x.v_); }
static inline void mod(Fp& z, const Dbl& xy) { Fp::op_.fpDbl_mod(z.v_, xy.v_); }
static inline void mulPre(FpDblT& xy, const Fp& x, const Fp& y) { Fp::op_.fpDbl_mulPre(xy.v_, x.v_, y.v_); }
static inline void sqrPre(FpDblT& xx, const Fp& x) { Fp::op_.fpDbl_sqrPre(xx.v_, x.v_); }
static inline void mod(Fp& z, const FpDblT& xy) { Fp::op_.fpDbl_mod(z.v_, xy.v_); }
};
/*
@ -61,7 +60,7 @@ public:
template<class Fp>
class Fp2T : public fp::Operator<Fp2T<Fp> > {
typedef fp::Unit Unit;
typedef typename Fp::Dbl FpDbl;
typedef FpDblT<Fp> FpDbl;
static Fp xi_a_;
public:
Fp a, b;

@ -9,7 +9,7 @@
typedef mcl::FpT<mcl::FpTag, 256> Fp;
typedef mcl::Fp2T<Fp> Fp2;
typedef Fp::Dbl FpDbl;
typedef mcl::FpDblT<Fp> FpDbl;
typedef mcl::Fp6T<Fp> Fp6;
typedef mcl::Fp12T<Fp> Fp12;

Loading…
Cancel
Save