From dd5178510951a58b9be7cc1517732f46ec12e6a3 Mon Sep 17 00:00:00 2001 From: mdw Date: Sat, 20 Nov 1999 22:23:27 +0000 Subject: [PATCH] Add function versions of some low-level macros with wider use. --- mpx.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- mpx.h | 51 ++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 99 insertions(+), 16 deletions(-) diff --git a/mpx.c b/mpx.c index e3600b7..80628b8 100644 --- a/mpx.c +++ b/mpx.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: mpx.c,v 1.4 1999/11/17 18:04:09 mdw Exp $ + * $Id: mpx.c,v 1.5 1999/11/20 22:23:27 mdw Exp $ * * Low-level multiprecision arithmetic * @@ -30,6 +30,9 @@ /*----- Revision history --------------------------------------------------* * * $Log: mpx.c,v $ + * Revision 1.5 1999/11/20 22:23:27 mdw + * Add function versions of some low-level macros with wider use. + * * Revision 1.4 1999/11/17 18:04:09 mdw * Add two's-complement functionality. Improve mpx_udiv a little by * performing the multiplication of the divisor by q with the subtraction @@ -477,6 +480,18 @@ void mpx_uadd(mpw *dv, mpw *dvl, const mpw *av, const mpw *avl, } } +/* --- @mpx_uaddn@ --- * + * + * Arguments: @mpw *dv, *dvl@ = source and destination base and limit + * @mpw n@ = other addend + * + * Returns: --- + * + * Use: Adds a small integer to a multiprecision number. + */ + +void mpx_uaddn(mpw *dv, mpw *dvl, mpw n) { MPX_UADDN(dv, dvl, n); } + /* --- @mpx_usub@ --- * * * Arguments: @mpw *dv, *dvl@ = destination vector base and limit @@ -519,6 +534,18 @@ void mpx_usub(mpw *dv, mpw *dvl, const mpw *av, const mpw *avl, *dv++ = c; } +/* --- @mpx_usubn@ --- * + * + * Arguments: @mpw *dv, *dvl@ = source and destination base and limit + * @n@ = subtrahend + * + * Returns: --- + * + * Use: Subtracts a small integer from a multiprecision number. + */ + +void mpx_usubn(mpw *dv, mpw *dvl, mpw n) { MPX_USUBN(dv, dvl, n); } + /* --- @mpx_umul@ --- * * * Arguments: @mpw *dv, *dvl@ = destination vector base and limit @@ -573,6 +600,41 @@ void mpx_umul(mpw *dv, mpw *dvl, const mpw *av, const mpw *avl, } } +/* --- @mpx_umuln@ --- * + * + * Arguments: @mpw *dv, *dvl@ = destination vector base and limit + * @const mpw *av, *avl@ = multiplicand vector base and limit + * @mpw m@ = multiplier + * + * Returns: --- + * + * Use: Multiplies a multiprecision integer by a single-word value. + * The destination and source may be equal. The destination + * is completely cleared after use. + */ + +void mpx_umuln(mpw *dv, mpw *dvl, const mpw *av, const mpw *avl, mpw m) +{ + MPX_UMULN(dv, dvl, av, avl, m); +} + +/* --- @mpx_umlan@ --- * + * + * Arguments: @mpw *dv, *dvl@ = destination/accumulator base and limit + * @const mpw *av, *avl@ = multiplicand vector base and limit + * @mpw m@ = multiplier + * + * Returns: --- + * + * Use: Multiplies a multiprecision integer by a single-word value + * and adds the result to an accumulator. + */ + +void mpx_umlan(mpw *dv, mpw *dvl, const mpw *av, const mpw *avl, mpw m) +{ + MPX_UMLAN(dv, dvl, av, avl, m); +} + /* --- @mpx_usqr@ --- * * * Arguments: @mpw *dv, *dvl@ = destination vector base and limit diff --git a/mpx.h b/mpx.h index 88f547c..96bb358 100644 --- a/mpx.h +++ b/mpx.h @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: mpx.h,v 1.4 1999/11/17 18:04:43 mdw Exp $ + * $Id: mpx.h,v 1.5 1999/11/20 22:23:27 mdw Exp $ * * Low level multiprecision arithmetic * @@ -30,6 +30,9 @@ /*----- Revision history --------------------------------------------------* * * $Log: mpx.h,v $ + * Revision 1.5 1999/11/20 22:23:27 mdw + * Add function versions of some low-level macros with wider use. + * * Revision 1.4 1999/11/17 18:04:43 mdw * Add two's complement support. Fix a bug in MPX_UMLAN. * @@ -336,10 +339,12 @@ extern void mpx_uadd(mpw */*dv*/, mpw */*dvl*/, const mpw */*av*/, const mpw */*avl*/, const mpw */*bv*/, const mpw */*bvl*/); -/* --- @MPX_UADDN@ --- * +/* --- @mpx_uaddn@ --- * + * + * Arguments: @mpw *dv, *dvl@ = source and destination base and limit + * @mpw n@ = other addend * - * Arguments: @dv, dvl@ = source and destination vector base and limit - * @n@ = other addend + * Returns: --- * * Use: Adds a small integer to a multiprecision number. */ @@ -355,6 +360,8 @@ extern void mpx_uadd(mpw */*dv*/, mpw */*dvl*/, } \ } while (0) +extern void mpx_uaddn(mpw */*dv*/, mpw */*dvl*/, mpw /*n*/); + /* --- @mpx_usub@ --- * * * Arguments: @mpw *dv, *dvl@ = destination vector base and limit @@ -376,10 +383,12 @@ extern void mpx_usub(mpw */*dv*/, mpw */*dvl*/, const mpw */*av*/, const mpw */*avl*/, const mpw */*bv*/, const mpw */*bvl*/); -/* --- @MPX_USUBN@ --- * +/* --- @mpx_usubn@ --- * * - * Arguments: @@dv, dvl@ = destination vector base and limit - * @n@ = other addend + * Arguments: @mpw *dv, *dvl@ = source and destination base and limit + * @n@ = subtrahend + * + * Returns: --- * * Use: Subtracts a small integer from a multiprecision number. */ @@ -398,6 +407,8 @@ extern void mpx_usub(mpw */*dv*/, mpw */*dvl*/, } \ } while (0) +extern void mpx_usubn(mpw */*dv*/, mpw */*dvl*/, mpw /*n*/); + /* --- @mpx_umul@ --- * * * Arguments: @mpw *dv, *dvl@ = destination vector base and limit @@ -416,11 +427,13 @@ extern void mpx_umul(mpw */*dv*/, mpw */*dvl*/, const mpw */*av*/, const mpw */*avl*/, const mpw */*bv*/, const mpw */*bvl*/); -/* --- @MPX_UMULN@ --- * +/* --- @mpx_umuln@ --- * * - * Arguments: @dv, dvl@ = destination vector base and limit - * @av, avl@ = multiplicand vector base and limit - * @m@ = multiplier + * Arguments: @mpw *dv, *dvl@ = destination vector base and limit + * @const mpw *av, *avl@ = multiplicand vector base and limit + * @mpw m@ = multiplier + * + * Returns: --- * * Use: Multiplies a multiprecision integer by a single-word value. * The destination and source may be equal. The destination @@ -447,11 +460,16 @@ extern void mpx_umul(mpw */*dv*/, mpw */*dvl*/, } \ } while (0) -/* --- @MPX_UMLAN@ --- * +extern void mpx_umuln(mpw */*dv*/, mpw */*dvl*/, + const mpw */*av*/, const mpw */*avl*/, mpw m); + +/* --- @mpx_umlan@ --- * * - * Arguments: @dv, dvl@ = destination/accumulator vector base and limit - * @av, avl@ = multiplicand vector base and limit - * @m@ = multiplier + * Arguments: @mpw *dv, *dvl@ = destination/accumulator base and limit + * @const mpw *av, *avl@ = multiplicand vector base and limit + * @mpw m@ = multiplier + * + * Returns: --- * * Use: Multiplies a multiprecision integer by a single-word value * and adds the result to an accumulator. @@ -474,6 +492,9 @@ extern void mpx_umul(mpw */*dv*/, mpw */*dvl*/, MPX_UADDN(_dv, _dvl, _cc); \ } while (0) +extern void mpx_umlan(mpw */*dv*/, mpw */*dvl*/, + const mpw */*av*/, const mpw */*avl*/, mpw m); + /* --- @mpx_usqr@ --- * * * Arguments: @mpw *dv, *dvl@ = destination vector base and limit -- 2.11.0