aboutsummaryrefslogtreecommitdiffstats
path: root/include/mcl/fp_tower.hpp
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2018-05-22 03:44:41 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2018-05-22 03:44:41 +0800
commit0379173f5a1712595a74d7ad6e80213aeb93e151 (patch)
tree3b3cefe280b1dfb328ba873c517af228c7843412 /include/mcl/fp_tower.hpp
parentdc2a87192680a4cb01dbe8f9e150a8ea3370efb2 (diff)
downloadtangerine-mcl-0379173f5a1712595a74d7ad6e80213aeb93e151.tar.gz
tangerine-mcl-0379173f5a1712595a74d7ad6e80213aeb93e151.tar.zst
tangerine-mcl-0379173f5a1712595a74d7ad6e80213aeb93e151.zip
remove throw in fp.hpp
Diffstat (limited to 'include/mcl/fp_tower.hpp')
-rw-r--r--include/mcl/fp_tower.hpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/include/mcl/fp_tower.hpp b/include/mcl/fp_tower.hpp
index 052d743..f65e973 100644
--- a/include/mcl/fp_tower.hpp
+++ b/include/mcl/fp_tower.hpp
@@ -89,11 +89,12 @@ public:
// QQQ : does not check range of x strictly(use for debug)
void setMpz(const mpz_class& x)
{
- if (x < 0) throw cybozu::Exception("FpDblT:_setMpz:negative is not supported") << x;
+ assert(x >= 0);
const size_t xn = gmp::getUnitSize(x);
const size_t N2 = getUnitSize();
if (xn > N2) {
- throw cybozu::Exception("FpDblT:setMpz:too large") << x;
+ assert(0);
+ return;
}
memcpy(v_, gmp::getUnit(x), xn * sizeof(Unit));
memset(v_ + xn, 0, (N2 - xn) * sizeof(Unit));
@@ -121,7 +122,7 @@ public:
static void mulUnit(FpDblT& z, const FpDblT& x, Unit y)
{
if (mulSmallUnit(z, x, y)) return;
- throw cybozu::Exception("mulUnit:not supported") << y;
+ assert(0); // not supported y
}
void operator+=(const FpDblT& x) { add(*this, *this, x); }
void operator-=(const FpDblT& x) { sub(*this, *this, x); }
@@ -206,7 +207,7 @@ public:
template<class S>
void setArray(const S *buf, size_t n)
{
- if ((n & 1) != 0) throw cybozu::Exception("Fp2T:setArray:bad size") << n;
+ assert((n & 1) == 0);
n /= 2;
a.setArray(buf, n);
b.setArray(buf + n, n);
@@ -263,7 +264,8 @@ public:
y.a = t1;
y.b.clear();
} else {
- if (!Fp::squareRoot(t1, -x.a)) throw cybozu::Exception("Fp2T:squareRoot:internal error1") << x;
+ bool b = Fp::squareRoot(t1, -x.a);
+ assert(b); (void)b;
y.a.clear();
y.b = t1;
}
@@ -278,7 +280,8 @@ public:
if (!Fp::squareRoot(t2, t2)) {
Fp::sub(t2, x.a, t1);
Fp::divBy2(t2, t2);
- if (!Fp::squareRoot(t2, t2)) throw cybozu::Exception("Fp2T:squareRoot:internal error2") << x;
+ bool b = Fp::squareRoot(t2, t2);
+ assert(b); (void)b;
}
y.a = t2;
t2 += t2;