Fix bounds on workspace for Karatsuba operations.
[u/mdw/catacomb] / mpx.h
diff --git a/mpx.h b/mpx.h
index 948e7dd..bc4b356 100644 (file)
--- a/mpx.h
+++ b/mpx.h
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: mpx.h,v 1.13 2002/10/06 22:52:50 mdw Exp $
+ * $Id: mpx.h,v 1.14 2002/10/09 00:36:03 mdw Exp $
  *
  * Low level multiprecision arithmetic
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: mpx.h,v $
+ * Revision 1.14  2002/10/09 00:36:03  mdw
+ * Fix bounds on workspace for Karatsuba operations.
+ *
  * Revision 1.13  2002/10/06 22:52:50  mdw
  * Pile of changes for supporting two's complement properly.
  *
@@ -733,20 +736,12 @@ extern mpw mpx_udivn(mpw */*qv*/, mpw */*qvl*/,
  *
  * This is the limiting length for using Karatsuba algorithms.  It's best to
  * use the simpler classical multiplication method on numbers smaller than
- * this.
+ * this.  It is unsafe to make this constant less than four (i.e., the
+ * algorithms will fail).
  */
 
 #define MPK_THRESH 16
 
-/* --- @MPK_SLOP@ --- *
- *
- * The extra number of words required as scratch space by the Karatsuba
- * routines.  This is a (generous) guess, since the actual amount of space
- * required is proportional to the recursion depth.
- */
-
-#define MPK_SLOP 64
-
 /* --- @mpx_kmul@ --- *
  *
  * Arguments:  @mpw *dv, *dvl@ = pointer to destination buffer
@@ -761,10 +756,9 @@ extern mpw mpx_udivn(mpw */*qv*/, mpw */*qvl*/,
  *             multiplication (e.g., @mpx_umul@) on large numbers, although
  *             more expensive on small ones.
  *
- *             The destination and scratch buffers must be twice as large as
- *             the larger argument.  The scratch space must be twice as
- *             large as the larger argument, plus the magic number
- *             @MPK_SLOP@.
+ *             The destination must be three times as large as the larger
+ *             argument.  The scratch space must be five times as large as
+ *             the larger argument.
  */
 
 extern void mpx_kmul(mpw */*dv*/, mpw */*dvl*/,
@@ -786,9 +780,9 @@ extern void mpx_kmul(mpw */*dv*/, mpw */*dvl*/,
  *             large numbers, although more expensive on small ones, and
  *             rather simpler than full-blown Karatsuba multiplication.
  *
- *             The destination must be twice as large as the argument.  The
- *             scratch space must be twice as large as the argument, plus
- *             the magic number @MPK_SLOP@.
+ *             The destination must be three times as large as the larger
+ *             argument.  The scratch space must be five times as large as
+ *             the larger argument.
  */
 
 extern void mpx_ksqr(mpw */*dv*/, mpw */*dvl*/,