aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-05-18 23:51:08 +0000
committerlloyd <[email protected]>2006-05-18 23:51:08 +0000
commit6e18c81467e5defd2dbed2873fd367feb90312e0 (patch)
tree84292b4c8c23229fffd995bb5e90bc31200e5c9b /src
parentc16f5d17337fe2ca05250812c949576be4860266 (diff)
Clean up algorithm dispatch in mp_mul.cpp
Diffstat (limited to 'src')
-rw-r--r--src/mp_mul.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/mp_mul.cpp b/src/mp_mul.cpp
index f020dff64..ecebf823a 100644
--- a/src/mp_mul.cpp
+++ b/src/mp_mul.cpp
@@ -76,8 +76,9 @@ u32bit karatsuba_size(u32bit z_size,
u32bit x_size, u32bit x_sw,
u32bit y_size, u32bit y_sw)
{
- if(x_sw > y_size || y_sw > x_size)
+ if(x_sw > x_size || x_sw > y_size || y_sw > x_size || y_sw > y_size)
return 0;
+
if(((x_size == x_sw) && (x_size % 2)) ||
((y_size == y_sw) && (y_size % 2)))
return 0;
@@ -85,9 +86,6 @@ u32bit karatsuba_size(u32bit z_size,
u32bit start = (x_sw > y_sw) ? x_sw : y_sw;
u32bit end = (x_size < y_size) ? x_size : y_size;
- if(end < start)
- return 0;
-
if(start == end)
{
if(start % 2)
@@ -125,16 +123,16 @@ void handle_small_mul(word z[], u32bit z_size,
if(x_sw == 1) bigint_linmul3(z, y, y_sw, x[0]);
else if(y_sw == 1) bigint_linmul3(z, x, x_sw, y[0]);
- else if(x_sw <= 4 && y_sw <= 4 &&
- x_size >= 4 && y_size >= 4 && z_size >= 8)
+ else if(x_sw <= 4 && x_size >= 4 &&
+ y_sw <= 4 && y_size >= 4 && z_size >= 8)
bigint_comba_mul4(z, x, y);
- else if(x_sw <= 6 && y_sw <= 6 &&
- x_size >= 6 && y_size >= 6 && z_size >= 12)
+ else if(x_sw <= 6 && x_size >= 6 &&
+ y_sw <= 6 && y_size >= 6 && z_size >= 12)
bigint_comba_mul6(z, x, y);
- else if(x_sw <= 8 && y_sw <= 8 &&
- x_size >= 8 && y_size >= 8 && z_size >= 16)
+ else if(x_sw <= 8 && x_size >= 8 &&
+ y_sw <= 8 && y_size >= 8 && z_size >= 16)
bigint_comba_mul8(z, x, y);
else