X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/8017495b1a3ba7f0edbe3ca2edb004aefbc2c9b6..674cd11ec63b56561980249cb19a0db54bacfa86:/manual/mp-mpx.tex diff --git a/manual/mp-mpx.tex b/manual/mp-mpx.tex index f775f6b..28c1424 100644 --- a/manual/mp-mpx.tex +++ b/manual/mp-mpx.tex @@ -54,7 +54,7 @@ frequently used abbreviation for |(mpw)(|$x$| & MPW_MAX)|. \fsec{Returns} -The number of bytes occupied by an array of $n$ \code{mpw}s (i.e., $n \cdot +The number of bytes occupied by an array of $n$~\code{mpw}s (i.e., $n \cdot |sizeof(mpw)|$). \subsubsection{The \code{MPW_RQ} macro} @@ -70,7 +70,7 @@ The number of bytes occupied by an array of $n$ \code{mpw}s (i.e., $n \cdot \fsec{Returns} The number of \code{mpw}s required to represent a multiprecision integer -occupying $\sz$ octets in an external representation. +occupying $\sz$~octets in an external representation. \subsection{Low-level multiprecision integer representation} @@ -85,7 +85,7 @@ pointers to the array's \emph{base} (i.e., its first element) and \emph{limit} (i.e., the location immediately following its last element). Let $v$ be the base and $\vl$ the limit of a multiprecision integer array. -The array itself is notated as $v .. \vl$. The array's size in words may be +The array itself is notated as~$v .. \vl$. The array's size in words may be computed as $\vl - v$ in the normal C fashion. The integer represented by the array, denoted $\mp(v .. \vl)$, is defined to be \[ @@ -100,8 +100,8 @@ the arithmetic algorithms don't need to consider high-order words which make no difference to the final result anyway. Whenever a result is too large to be represented in the memory allocated for -it, high-order bits are discarded. Thus, a result written to an array of $k$ -words is reduced modulo $2^{\code{MPW_BITS} \cdot k}$. +it, high-order bits are discarded. Thus, a result written to an array of +$k$~words is reduced modulo $2^{\code{MPW_BITS} \cdot k}$. \subsection{Low-level macros} @@ -122,9 +122,8 @@ manipulating multiprecision integers at the MPX level. \fsec{Description} -The \code{MPX_SHRINK} macro reduces the limit $\vl$ of a multiprecision -integer array so that either $v = \vl$ or $\vl[-1] \ne 0$. The $\vl$ -argument must be an lvalue, since the macro writes the result back when it +The \code{MPX_SHRINK} macro reduces the limit~$\vl$ of a multiprecision +integer array so that either $v = \vl$ or~$\vl[-1] \ne 0$. The argument~$\vl$ must be an lvalue, since the macro writes the result back when it finishes. \subsubsection{The \code{MPX_BITS} macro} @@ -140,7 +139,7 @@ finishes. \fsec{Description} Determines the smallest number of bits which could represent the number -$\mp(v .. \vl)$, and writes the answer to $b$, which must therefore be an +$\mp(v .. \vl)$, and writes the answer to~$b$, which must therefore be an lvalue. The result is zero if the number is zero; otherwise $b$ is the largest integer such that \[ \mp(v .. \vl) \ge 2^{(b - 1) \bmod \code{MPW_BITS}}.\] @@ -159,11 +158,11 @@ largest integer such that \fsec{Description} Determines the smallest number of octets which could represent the number -$\mp(v .. \vl)$, and writes the answer to $o$, which must therefore be an +$\mp(v .. \vl)$, and writes the answer to~$o$, which must therefore be an lvalue. This is useful for determining appropriate buffer sizes for the results of \code{mpx_storel} and \code{mpx_storeb}. -The result $o$ can be calculated from the number of bits $b$ reported by +The result $o$ can be calculated from the number of bits~$b$ reported by \code{MPX_BITS} as $o = \lceil b / 8 \rceil$; the algorithm used by \code{MPX_OCTETS} is more efficient than this, however. @@ -240,8 +239,8 @@ in an octet array of a particular size. \fsec{Description} -Stores the number held in the array $v .. \vl$ to the array of $\sz$ octets -starting at address $p$ in little-endian byte order (i.e., least significant +Stores the number held in the array $v .. \vl$ to the array of $\sz$~octets +starting at address~$p$ in little-endian byte order (i.e., least significant byte first). \subsubsection{The \code{mpx_loadl} function} @@ -257,8 +256,8 @@ byte first). \fsec{Description} -Loads into the array $v .. \vl$ the number represented in the array of $\sz$ -octets starting at address $p$ in little-endian byte order (i.e., least +Loads into the array $v .. \vl$ the number represented in the array of +$\sz$~octets starting at address~$p$ in little-endian byte order (i.e., least significant byte first). \subsubsection{The \code{mpx_storeb} function} @@ -274,8 +273,8 @@ significant byte first). \fsec{Description} -Stores the number held in the array $v .. \vl$ to the array of $\sz$ octets -starting at address $p$ in big-endian byte order (i.e., least significant +Stores the number held in the array $v .. \vl$ to the array of $\sz$~octets +starting at address~$p$ in big-endian byte order (i.e., least significant byte last). \subsubsection{The \code{mpx_loadb} function} @@ -291,8 +290,8 @@ byte last). \fsec{Description} -Loads into the array $v .. \vl$ the number represented in the array of $\sz$ -octets starting at address $p$ in big-endian byte order (i.e., least +Loads into the array $v .. \vl$ the number represented in the array of +$\sz$~octets starting at address $p$ in big-endian byte order (i.e., least significant byte last). @@ -326,8 +325,8 @@ integer. \fsec{Description} -Stores in $\dv .. \dvl$ the result of shifting $\mp(\av .. \avl)$ left by $n$ -bits (i.e., multiplying it by $2^n$). +Stores in $\dv .. \dvl$ the result of shifting $\mp(\av .. \avl)$ left by +$n$~bits (i.e., multiplying it by~$2^n$). \subsubsection{The \code{mpx_lsr} function} \label{fn:mpx-lsr} @@ -345,10 +344,10 @@ bits (i.e., multiplying it by $2^n$). \fsec{Description} Stores in $\dv .. \dvl$ the result of shifting $\mp(\av .. \avl)$ right by -$n$ bits (i.e., dividing it by $2^n$, rounding towards zero). +$n$~bits (i.e., dividing it by~$2^n$, rounding towards zero). -\subsection{Low level arithmetic} +\subsection{Low-level arithmetic} The remaining functions perform standard arithmetic operations on large integers. The form for the arguments is fairly well-standardized: @@ -395,7 +394,7 @@ $\dv .. \dvl$. The two arrays $v .. \vl$ and $\dv .. \dvl$ may be the same. \fsec{Description} The function \code{mpx_ucmp} performs an unsigned comparison of two unsigned -multiprecision integers $a$ and $b$, passed in the arrays $\av .. \avl$ and +multiprecision integers $a$ and~$b$, passed in the arrays $\av .. \avl$ and $\bv .. \bvl$ respectively. The macro \code{MPX_UCMP} provides a slightly more readable interface for @@ -407,7 +406,7 @@ $a \mathrel{\synt{rel-op}} b$. The function \code{mpx_ucmp} returns a value less then, equal to, or greater than zero depending on whether $a$ is less than, equal to or greater -than $b$. +than~$b$. The macro \code{MPX_UCMP} returns a nonzero result if $a \mathrel{\synt{rel-op}} b$ is true, and zero if false. @@ -447,7 +446,7 @@ destination array may be equal to either or both source arrays.\footnote{% \fsec{Description} -The function \code{mpx_uaddn} adds a small integer $n$ (expressed as a single +The function \code{mpx_uaddn} adds a small integer~$n$ (expressed as a single \code{mpw}) to the multiprecision integer held in $\dv .. \dvl$. The macro \code{MPX_UADDN} performs exactly the same operation, but uses @@ -494,7 +493,7 @@ obtained. \fsec{Description} -The function \code{mpx_usubn} subtracts a small integer $n$ (expressed as a +The function \code{mpx_usubn} subtracts a small integer~$n$ (expressed as a single \code{mpw}) from the multiprecision integer held in $\dv .. \dvl$. The macro \code{MPX_USUBN} performs exactly the same operation, but uses @@ -538,7 +537,7 @@ destination array may not be equal to either source array. \fsec{Description} The function \code{mpx_umuln} multiplies the multiprecision integer passed in -$\av .. \avl$ by a small integer $n$ (expressed as a single \code{mpw}), +$\av .. \avl$ by a small integer~$n$ (expressed as a single \code{mpw}), writing the product $n \cdot \mp(\av .. \avl)$ to the destination array $\dv .. \dvl$. The destination array may be equal to the source array $\av .. \avl$. @@ -564,7 +563,7 @@ inline code rather than calling a function. \fsec{Description} The function \code{mpx_umlan} multiplies the multiprecision integer passed in -$\av .. \avl$ by a small integer $n$ (expressed as a single \code{mpw}), and +$\av .. \avl$ by a small integer~$n$ (expressed as a single \code{mpw}), and adds it to the value already stored in the destination array $\dv .. \dvl$. The destination array may be equal to the source array $\av .. \avl$, although this isn't very useful.