Improve error-checking.
[u/mdw/catacomb] / mp.h
diff --git a/mp.h b/mp.h
index 6f8959a..dce8128 100644 (file)
--- a/mp.h
+++ b/mp.h
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: mp.h,v 1.3 1999/11/19 13:19:14 mdw Exp $
+ * $Id: mp.h,v 1.5 1999/11/22 20:50:37 mdw Exp $
  *
  * Simple multiprecision arithmetic
  *
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: mp.h,v $
+ * Revision 1.5  1999/11/22 20:50:37  mdw
+ * Add support for computing Jacobi symbols.
+ *
+ * Revision 1.4  1999/11/21 22:13:02  mdw
+ * Add mp version of MPX_BITS.
+ *
  * Revision 1.3  1999/11/19 13:19:14  mdw
  * Fix const annotation.
  *
@@ -424,7 +430,19 @@ extern void mp_scan(mpscan */*sc*/, const mp */*m*/);
  *             integer.
  */
 
-extern size_t mp_octets(const mp *m);
+extern size_t mp_octets(const mp */*m*/);
+
+/* --- @mp_bits@ --- *
+ *
+ * Arguments:  @const mp *m@ = a multiprecision integer
+ *
+ * Returns:    The number of bits required to represent @m@.
+ *
+ * Use:                Calculates the external storage required for a multiprecision
+ *             integer.
+ */
+
+extern unsigned long mp_bits(const mp */*m*/);
 
 /* --- @mp_loadl@ --- *
  *
@@ -624,6 +642,21 @@ extern void mp_div(mp **/*qq*/, mp **/*rr*/,
 extern void mp_gcd(mp **/*gcd*/, mp **/*xx*/, mp **/*yy*/,
                   mp */*a*/, mp */*b*/);
 
+/* --- @mp_jacobi@ --- *
+ *
+ * Arguments:  @mp *a@ = an integer less than @n@
+ *             @mp *n@ = an odd integer
+ *
+ * Returns:    @-1@, @0@ or @1@ -- the Jacobi symbol %$J(a, n)$%.
+ *
+ * Use:                Computes the Jacobi symbol.  If @n@ is prime, this is the
+ *             Legendre symbol and is equal to 1 if and only if @a@ is a
+ *             quadratic residue mod @n@.  The result is zero if and only if
+ *             @a@ and @n@ have a common factor greater than one.
+ */
+
+int mp_jacobi(mp */*a*/, mp */*n*/);
+
 /*----- Test harness support ----------------------------------------------*/
 
 #include <mLib/testrig.h>