BSD 4_4 release
[unix-history] / usr / src / lib / libmp / mp.3
index 0b6c572..a253c13 100644 (file)
-.\" Copyright (c) 1986 Regents of the University of California.
-.\" All rights reserved.  The Berkeley software License Agreement
-.\" specifies the terms and conditions for redistribution.
+.\" Copyright (c) 1986, 1991 The Regents of the University of California.
+.\" All rights reserved.
 .\"
 .\"
-.\"    @(#)mp.3        6.4 (Berkeley) 6/4/86
+.\" This module is believed to contain source code proprietary to AT&T.
+.\" Use and redistribution is subject to the Berkeley Software License
+.\" Agreement and your Software Agreement with AT&T (Western Electric).
 .\"
 .\"
-.TH MP 3X "June 4, 1986"
-.UC 6
-.SH NAME
-madd, msub, mult, mdiv, pow, gcd, invert, rpow, msqrt, mcmp,
-move, min, omin, fmin, m_in, mout, omout, fmout, m_out, sdiv, itom
-\- multiple precision integer arithmetic
-.SH SYNOPSIS
-.nf
-.B #include <mp.h>
-.B #include <stdio.h>
-.PP
-.B "typedef struct mint { int len; short *val; } MINT;"
-.PP
-.B madd(a, b, c)
-.B msub(a, b, c)
-.B mult(a, b, c)
-.B mdiv(a, b, q, r)
-.B pow(a, b, m, c)
-.B gcd(a, b, c)
-.B invert(a, b, c)
-.B rpow(a, n, c)
-.B msqrt(a, b, r)
-.B mcmp(a, b)
-.B move(a, b)
-.B min(a)
-.B omin(a)
-.B fmin(a, f)
-.B m_in(a, n, f)
-.B mout(a)
-.B omout(a)
-.B fmout(a, f)
-.B m_out(a, n, f)
-.B MINT *a, *b, *c, *m, "*q, *r;"
-.B FILE *f;
-.B int n;
-.PP
-.B sdiv(a, n, q, r)
-.B MINT *a, *q;
-.B short n;
-.B short *r;
-.PP
-.B MINT *itom(n)
-.SH DESCRIPTION
-These routines perform arithmetic on integers of
-arbitrary length.
-The integers are stored using the defined type
-.IR MINT .
-Pointers to a
-.I MINT
-can be initialized using the function
-.I itom
-which sets the initial value to
-.IR n .
-After that, space is managed automatically by the routines.
-.PP
-.IR madd , " msub " and " mult"
-assign to
-.I c
-the sum, difference and
-product, respectively, of
-.IR a " and " b .
-.I mdiv
-assigns to
-.IR q " and " r
-the quotient and remainder obtained
-from dividing
-.IR a " by " b.
-.I sdiv
-is like
-.I mdiv
-except that the divisor is a short integer
-.I n
-and the remainder is placed in a short
-whose address is given as
-.IR r .
-.I msqrt
-produces the integer square root of
-.IR a " in " b
-and places the remainder in
-.IR r .
-.I rpow
-calculates in
-.I c
-the value of
-.I a
-raised to the (``regular'' integral) power
-.IR n ,
-while
-.I pow
-calculates this with a full multiple precision exponent
-.I b
-and the result is reduced modulo
-.IR m .
-.I gcd
-returns the greatest common denominator of
-.IR a " and " b " in " c ,
+.\"    @(#)mp.3        8.1 (Berkeley) 6/4/93
+.\"
+.Dd June 4, 1993
+.Dt MP 3
+.Os BSD 4.3
+.Sh NAME
+.Nm fmin ,
+.Nm fmout ,
+.Nm gcd ,
+.Nm invert ,
+.Nm itom
+.Nm m_in ,
+.Nm m_out ,
+.Nm madd ,
+.Nm mcmp,
+.Nm mdiv ,
+.Nm min ,
+.Nm mout ,
+.Nm move ,
+.Nm msqrt ,
+.Nm msub ,
+.Nm mult ,
+.Nm omin ,
+.Nm omout ,
+.Nm pow ,
+.Nm rpow ,
+.Nm sdiv ,
+.Nd multiple precision integer arithmetic
+.Sh SYNOPSIS
+.Fd #include <mp.h>
+.Fd #include <stdio.h>
+.Fd "typedef struct mint { int len; short *val; } MINT;"
+.Fn madd "MINT *a" "MINT *b" "MINT *c"
+.Fn msub "MINT *a" "MINT *b" "MINT *c"
+.Fn mult "MINT *a" "MINT *b" "MINT *c"
+.Fn mdiv "MINT *a" "MINT *b" "MINT *q" "short r"
+.Fn pow "MINT *a" "MINT *b" m "MINT *c"
+.Fn gcd "MINT *a" "MINT *b" "MINT *c"
+.Fn invert "MINT *a" "MINT *b" "MINT *c"
+.Fn rpow "MINT *a" "short n" "MINT *c"
+.Fn msqrt "MINT *a" "MINT *b" "short r"
+.Fn mcmp "MINT *a" "MINT *b"
+.Fn move "MINT *a" "MINT *b"
+.Fn min "MINT *a"
+.Fn omin "MINT *a"
+.Fn fmin "MINT *a" "FILE *f"
+.Fn m_in "MINT *a" "int n" "FILE *f"
+.Fn mout "MINT *a"
+.Fn omout "MINT *a"
+.Fn fmout "MINT *a" "FILE *f"
+.Fn m_out "MINT *a" "int n" "FILE *f"
+.Fn sdiv "MINT *a" "short n" "MINT *q" "short r"
+.Fn itom "short n"
+.Sh DESCRIPTION
+.Bf -symbolic
+The interface for this library is expected to change.
+.Ef
+.Pp
+These functions operate on integers of variable length.
+The function
+.Fn itom
+allocates space for an integer of length
+.Fa n
+which may be accessed via the returned
+.Fa MINT
+pointer.
+The underlying storage scheme is transparent to the user.
+.Pp
+.Bl -tag -width "mdivXXX" -compact
+.It Fn fmin
+.It Fn fmout
+Convert decimal input and output using file
+.Fa f .
+.Pp
+.It Fn gcd
+Finds the greatest common denominator of
+.Fa a
 and
 and
-.I invert
-computes
-.IR c " such that " a*c " mod " b " = 1,"
+.Fa b ,
+storing the result
+in
+.Fa c .
+.Pp
+.It Fn invert
+Computes
+.Fa c
+such that
+.Fa a Ns * Fa c No mod
+.Fa b
+= 1,
 for
 for
-.IR a " and " b
+.Fa a
+and
+.Fa b
 relatively prime.
 relatively prime.
-.I mcmp
-returns a negative, zero or positive integer value when
-.I a
+.Pp
+.It Fn m_in
+.It Fn m_out
+.Tn I/O
+with arbitrary radix
+.Fa n .
+.Pp
+.It Fn madd
+The sum of
+.Fa a
+and
+.Fa b
+is stored in
+.Fa c .
+.Pp
+.It Fn mcmp
+Returns a negative, zero or positive integer value when
+.Fa a
 is less than, equal to or greater than
 is less than, equal to or greater than
-.IR b ,
+.Fa b ,
 respectively.
 respectively.
-.I move
-copies
-.IR a " to " b .
-.IR min " and " mout
-do decimal input and output while
-.IR omin " and " omout
-do octal input and output.
-More generally,
-.IR fmin " and " fmout
-do decimal input and output using file
-.IR f ,
+.It Fn move
+Copies
+.Fa a
+to
+.Fa b .
+.Pp
+.It Fn min
+.It Fn mout
+Convert decimal input and output.
+.Pp
+.It Fn mdiv
+Divides
+.Fa a
+by
+.Fa b
+and stores the quotient in
+.Fa q
+and the remainder in
+.Fa r .
+.Pp
+.It Fn msqrt
+Calculates the integer square root of
+.Fa a
+in
+.Fa b
+and places the remainder in
+.Fa r .
+.Pp
+.It Fn msub
+The difference of
+.Fa a
+and
+.Fa b
+is stored in
+.Fa c .
+.Pp
+.It Fn mult
+The product of
+.Fa a
 and
 and
-.IR m_in " and " m_out
-do I/O with arbitrary radix
-.IR n .
+.Fa b
+is stored in
+.Fa c .
+.Pp
+.It Fn omin
+.It Fn omout
+Convert octal input and output.
+.Pp
+.It Fn pow
+Calculates
+the value of
+.Fa a
+raised to the
+full multiple precision exponent
+.Fa b ,
+the result is reduced modulo
+.Fa m
+and stored in
+.Fa c .
+.Pp
+.It Fn rpow
+Calculates
+the value of
+.Fa a
+raised to the (``regular'' integral) power
+.Fa n
+and stores the result in
+.Fa c .
+.Pp
+.It Fn sdiv
+(Short divisor.)
+Divides
+.Fa a
+by the short integer
+.Fa b
+and stores the quotient in
+.Fa q
+and the remainder in short integer
+.Fa r .
 On input, records should have the form of
 strings of digits terminated by a newline;
 output records have a similar form.
 On input, records should have the form of
 strings of digits terminated by a newline;
 output records have a similar form.
-.PP
-Programs which use the multiple-precision arithmetic library
-must be loaded using the loader flag
-.IR \-lmp .
-.SH FILES
-.ta 2i
-/usr/include/mp.h      include file
-.br
-/usr/lib/libmp.a       object code library
-.SH SEE ALSO
-dc(1), bc(1)
-.SH DIAGNOSTICS
-Illegal operations and running out of memory
-produce messages and core images.
-.SH BUGS
+.El
+.Sh FILES
+.Bl -tag -width /usr/include/mp.h -compact
+.It Pa /usr/lib/libmp.a
+object code library
+.It Pa /usr/include/mp.h
+include file
+.El
+.Sh SEE ALSO
+.Xr dc 1 ,
+.Xr bc 1
+.Sh HISTORY
+A
+.Fn gcd ,
+.Fn itom ,
+.Fn madd ,
+.Fn mdiv ,
+.Fn min ,
+.Fn mout ,
+.Fn msqrt ,
+.Fn msub ,
+.Fn mult ,
+.Fn pow ,
+.Fn rpow ,
+and
+.Fn sdiv
+function appeared in
+.At v7 .
+.\" The rest of the functions appeared in
+.\" .Bx ??
+.Sh BUGS
 Bases for input and output should be <= 10.
 Bases for input and output should be <= 10.
-.PP
-.IR dc (1)
+.Pp
+The interpreters
+.Xr dc 1
 and
 and
-.IR bc (1)
+.Xr bc 1
 don't use this library.
 don't use this library.
-.PP
+.Pp
 The input and output routines are a crock.
 The input and output routines are a crock.
-.PP
-.I pow
+.Pp
+The function name
+.Fn pow
 is also the name of a standard math library routine.
 is also the name of a standard math library routine.