Add an internal-representation no-op function.
[u/mdw/catacomb] / mpx.h
diff --git a/mpx.h b/mpx.h
index 509da02..b633e43 100644 (file)
--- a/mpx.h
+++ b/mpx.h
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: mpx.h,v 1.8 1999/12/11 10:57:43 mdw Exp $
+ * $Id: mpx.h,v 1.12 2001/04/03 19:36:05 mdw Exp $
  *
  * Low level multiprecision arithmetic
  *
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: mpx.h,v $
+ * Revision 1.12  2001/04/03 19:36:05  mdw
+ * Add some simple bitwise operations so that Perl can use them.
+ *
+ * Revision 1.11  2000/10/08 15:48:35  mdw
+ * Rename Karatsuba constants now that we have @gfx_kmul@ too.
+ *
+ * Revision 1.10  2000/10/08 12:06:12  mdw
+ * Provide @mpx_ueq@ for rapidly testing equality of two integers.
+ *
+ * Revision 1.9  1999/12/22 15:49:07  mdw
+ * New function for division by a small integer.
+ *
  * Revision 1.8  1999/12/11 10:57:43  mdw
  * Karatsuba squaring algorithm.
  *
@@ -295,6 +307,34 @@ extern void mpx_lsr(mpw */*dv*/, mpw */*dvl*/,
                    const mpw */*av*/, const mpw */*avl*/,
                    size_t /*n*/);
 
+/*----- Bitwise operations ------------------------------------------------*/
+
+/* --- @mpx_and@, @mpx_or@, @mpx_xor@, @mpx_not@ --- *
+ *
+ * Arguments:  @mpw *dv, *dvl@ = destination vector
+ *             @const mpw *av, *avl@ = first source vector
+ *             @const mpw *bv, *bvl@ = second source vector
+ *
+ * Returns:    ---
+ *
+ * Use;                Does the obvious bitwise operations.
+ */
+
+extern void mpx_and(mpw */*dv*/, mpw */*dvl*/,
+                   const mpw */*av*/, const mpw */*avl*/,
+                   const mpw */*bv*/, const mpw */*bvl*/);
+
+extern void mpx_or(mpw */*dv*/, mpw */*dvl*/,
+                  const mpw */*av*/, const mpw */*avl*/,
+                  const mpw */*bv*/, const mpw */*bvl*/);
+
+extern void mpx_xor(mpw */*dv*/, mpw */*dvl*/,
+                   const mpw */*av*/, const mpw */*avl*/,
+                   const mpw */*bv*/, const mpw */*bvl*/);
+
+extern void mpx_not(mpw */*dv*/, mpw */*dvl*/,
+                   const mpw */*av*/, const mpw */*avl*/);
+
 /*----- Unsigned arithmetic -----------------------------------------------*/
 
 /* --- @mpx_2c@ --- *
@@ -310,6 +350,19 @@ extern void mpx_lsr(mpw */*dv*/, mpw */*dvl*/,
 extern void mpx_2c(mpw */*dv*/, mpw */*dvl*/,
                   const mpw */*v*/, const mpw */*vl*/);
 
+/* --- @mpx_ueq@ --- *
+ *
+ * Arguments:  @const mpw *av, *avl@ = first argument vector base and limit
+ *             @const mpw *bv, *bvl@ = second argument vector base and limit
+ *
+ * Returns:    Nonzero if the two vectors are equal.
+ *
+ * Use:                Performs an unsigned integer test for equality.
+ */
+
+extern int mpx_ueq(const mpw */*av*/, const mpw */*avl*/,
+                  const mpw */*bv*/, const mpw */*bvl*/);
+
 /* --- @mpx_ucmp@ --- *
  *
  * Arguments:  @const mpw *av, *avl@ = first argument vector base and limit
@@ -539,25 +592,40 @@ extern void mpx_udiv(mpw */*qv*/, mpw */*qvl*/, mpw */*rv*/, mpw */*rvl*/,
                     const mpw */*dv*/, const mpw */*dvl*/,
                     mpw */*sv*/, mpw */*svl*/);
 
+/* --- @mpx_udivn@ --- *
+ *
+ * Arguments:  @mpw *qv, *qvl@ = storage for the quotient (may overlap
+ *                     dividend)
+ *             @const mpw *rv, *rvl@ = dividend
+ *             @mpw d@ = single-precision divisor
+ *
+ * Returns:    Remainder after divison.
+ *
+ * Use:                Performs a single-precision division operation.
+ */
+
+extern mpw mpx_udivn(mpw */*qv*/, mpw */*qvl*/,
+                    const mpw */*rv*/, const mpw */*rvl*/, mpw /*d*/);
+
 /*----- Karatsuba multiplication algorithms -------------------------------*/
 
-/* --- @KARATSUBA_CUTOFF@ --- *
+/* --- @MPK_THRESH@ --- *
  *
  * This is the limiting length for using Karatsuba algorithms.  It's best to
  * use the simpler classical multiplication method on numbers smaller than
  * this.
  */
 
-#define KARATSUBA_CUTOFF 16
+#define MPK_THRESH 16
 
-/* --- @KARATSUBA_SLOP@ --- *
+/* --- @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 KARATSUBA_SLOP 32
+#define MPK_SLOP 64
 
 /* --- @mpx_kmul@ --- *
  *
@@ -576,7 +644,7 @@ extern void mpx_udiv(mpw */*qv*/, mpw */*qvl*/, mpw */*rv*/, mpw */*rvl*/,
  *             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
- *             @KARATSUBA_SLOP@.
+ *             @MPK_SLOP@.
  */
 
 extern void mpx_kmul(mpw */*dv*/, mpw */*dvl*/,
@@ -600,7 +668,7 @@ extern void mpx_kmul(mpw */*dv*/, mpw */*dvl*/,
  *
  *             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 @KARATSUBA_SLOP@.
+ *             the magic number @MPK_SLOP@.
  */
 
 extern void mpx_ksqr(mpw */*dv*/, mpw */*dvl*/,