fix fpDbl_add

dev
MITSUNARI Shigeo 9 years ago
parent 26f31a71aa
commit 3916ecf603
  1. 5
      include/mcl/fp_tower.hpp
  2. 1
      src/fp.cpp
  3. 3
      src/short.txt
  4. 5
      test/fp_tower_test.cpp

@ -19,8 +19,9 @@ struct BnT {
static inline size_t getUnitSize() { return Fp::op_.N * 2; } static inline size_t getUnitSize() { return Fp::op_.N * 2; }
void dump() const void dump() const
{ {
for (size_t i = 0; i < getUnitSize(); i++) { const size_t n = getUnitSize();
printf("%016llx ", (long long)v_[i]); for (size_t i = 0; i < n; i++) {
printf("%016llx ", (long long)v_[n - 1 - i]);
} }
printf("\n"); printf("\n");
} }

@ -138,7 +138,6 @@ struct OpeFunc {
*/ */
static inline void fpDbl_addPC(Unit *z, const Unit *x, const Unit *y, const Unit *p) static inline void fpDbl_addPC(Unit *z, const Unit *x, const Unit *y, const Unit *p)
{ {
puts("BBB");
Unit ret[N * 2 + 2]; // not N + 1 Unit ret[N * 2 + 2]; // not N + 1
Unit pDbl[N * 2]; Unit pDbl[N * 2];
mpz_t mz, mx, my, mp; mpz_t mz, mx, my, mp;

@ -56,7 +56,8 @@ entry:
%t0 = add i$(b2u) %x1, %y1 ; x + y = [H:L] %t0 = add i$(b2u) %x1, %y1 ; x + y = [H:L]
%t1 = trunc i$(b2u) %t0 to i$(bit) ; t1 = L %t1 = trunc i$(b2u) %t0 to i$(bit) ; t1 = L
store i$(bit) %t1, i$(bit)* %pz ; store L store i$(bit) %t1, i$(bit)* %pz ; store L
%t2 = shl i$(b2u) %t0, $(bit)
%t2 = lshr i$(b2u) %t0, $(bit)
%H = trunc i$(b2u) %t2 to i$(bu) %H = trunc i$(b2u) %t2 to i$(bu)
%p = load i$(bit)* %pp %p = load i$(bit)* %pp

@ -92,7 +92,6 @@ void testFpDbl()
mcl::Gmp::addMod(mo, mx, my, mp); mcl::Gmp::addMod(mo, mx, my, mp);
z.getMpz(mz); z.getMpz(mz);
CYBOZU_TEST_EQUAL(mz, mo); CYBOZU_TEST_EQUAL(mz, mo);
mcl::Gmp::subMod(mo, mx, my, mp); mcl::Gmp::subMod(mo, mx, my, mp);
FpDbl::sub(z, x, y); FpDbl::sub(z, x, y);
z.getMpz(mz); z.getMpz(mz);
@ -105,8 +104,8 @@ void testFpDbl()
void test(const char *p) void test(const char *p)
{ {
printf("prime=%s\n", p); printf("prime=%s\n", p);
// Fp::setModulo(p); Fp::setModulo(p);
Fp::setModulo(p, 0, mcl::fp::FP_LLVM); // QQQ // Fp::setModulo(p, 0, mcl::fp::FP_LLVM); // QQQ
testFp2(); testFp2();
if (Fp::getBitSize() <= 256) { if (Fp::getBitSize() <= 256) {
testFpDbl(); testFpDbl();

Loading…
Cancel
Save