libzahl

big integer library
git clone git://git.suckless.org/libzahl
Log | Files | Refs | README | LICENSE

commit aeb5e44a98cb4158528206c079654357b1c75b16
parent 781e9d05388539d989e3578ebc7f8a7cd038aeb0
Author: Mattias Andrée <maandree@kth.se>
Date:   Wed, 30 Nov 2016 10:15:59 +0100

Fix errors in the manual (most of them found by Ivan Zuboff)

Signed-off-by: Mattias Andrée <maandree@kth.se>

Diffstat:
Mdoc/exercises.tex | 2+-
Mdoc/miscellaneous.tex | 2+-
Mdoc/not-implemented.tex | 44++++++++++++++++++++++----------------------
Mdoc/number-theory.tex | 6+++---
Mdoc/what-is-libzahl.tex | 15++++++++-------
5 files changed, 35 insertions(+), 34 deletions(-)

diff --git a/doc/exercises.tex b/doc/exercises.tex @@ -596,7 +596,7 @@ ptest_llt(z_t n) $M_n$ is composite if $n$ is composite, therefore, if you do not expect prime-only values on $n$, the -performance can be improve by using some other +performance can be improved by using some other primality test (or this same test if $n$ is a Mersenne number) to first check that $n$ is prime. diff --git a/doc/miscellaneous.tex b/doc/miscellaneous.tex @@ -101,7 +101,7 @@ sum of a set of numbers. Another form of assignment available in libzahl is copy-assignment. This done using {\tt zset}. As easily observable, {\tt zset} is named like -{\tt zseti}, {\tt zsetu}, and {\tt zsetu}, but +{\tt zseti}, {\tt zsetu}, and {\tt zsets}, but without the input-type suffix. The lack of a input-type suffix means that the input type is {\tt z\_t}. {\tt zset} copies value of second diff --git a/doc/not-implemented.tex b/doc/not-implemented.tex @@ -3,25 +3,25 @@ In this chapter we maintain a list of features we have chosen not to implement, -but would fit into libzahl had we not have +but would fit into libzahl, had we not have our priorities straight. Functions listed herein will only be implemented if it is shown that it would be overwhelmingly advantageous. For each feature, a sample implementation or a mathematical expression -on which you can base your implemention -is included. The sample implementations create -temporary integer references, this is to -simplify the examples. You should try to -use dedicated variables; in case of recursion, -a robust program should store temporary -variables on a stack, so they can be -clean up if something happens. - -Research problems, like prime-factorisation -and discrete logarithms do not fit in the -scope of bignum libraries. % Unless they are extraordinarily bloated with vague mission-scope, like systemd. -And therefore do not fit into libzahl, +on which you can base your implementation is +included. The sample implementations create +temporary integer references to simplify the +examples. You should try to use dedicated +variables; in case of recursion, a robust +program should store temporary variables on +a stack, so they can be cleaned up if +something happens. + +Research problems, like prime factorisation +and discrete logarithms, do not fit in the +scope of bignum libraries % Unless they are extraordinarily bloated with vague mission-scope, like systemd. +and therefore do not fit into libzahl, and will not be included in this chapter. Operators and functions that grow so ridiculously fast that a tiny lookup table @@ -330,7 +330,7 @@ method can be derived from the observation \vspace{1em} \noindent -The resulting algorithm can be expressed +The resulting algorithm can be expressed as \begin{alltt} void @@ -690,10 +690,10 @@ in an integer, counting the sign bit: \end{alltt} \noindent -It requires a compiler extension, if missing, -there are other ways to computer the population -count for a word: manually bit-by-bit, or with -a fully unrolled +It requires a compiler extension; if it's not +available, there are other ways to computer the +population count for a word: manually bit-by-bit, +or with a fully unrolled \begin{alltt} int s; @@ -706,7 +706,7 @@ a fully unrolled \label{sec:Hamming distance} A simple way to compute the Hamming distance, -the number of differing bits, between two +the number of differing bits between two numbers is with the function \begin{alltt} @@ -767,13 +767,13 @@ side-effects. \label{sec:Reference duplication} This could be useful for creating duplicates -with modified sign. But only if neither +with modified sign, but only if neither {\tt r} nor {\tt a} will be modified whilst both are in use. Because it is unsafe, fairly simple to create an implementation with acceptable performance — {\tt *r = *a}, — and probably seldom useful, this has not -be implemented. +been implemented. \begin{alltt} void diff --git a/doc/number-theory.tex b/doc/number-theory.tex @@ -145,7 +145,7 @@ definion ensures \noindent and analogously for $\frac{b}{\gcd(a,\,b)}$. Note however, the convension $\gcd(0, 0) = 0$ is adhered. Therefore, -before dividing with $\gcd{a, b}$ you may want to check +before dividing with $\gcd(a, b)$ you may want to check whether $\gcd(a, b) = 0$. $\gcd(a, b)$ is calculated with {\tt zgcd(a, b)}. @@ -179,7 +179,7 @@ $\max x : 2^x \vert z$ is returned by {\tt zlsb(z)} \section{Primality test} \label{sec:Primality test} -A primality of an integer can be test with +The primality of an integer can be tested with \begin{alltt} enum zprimality zptest(z_t w, z_t a, int t); @@ -235,7 +235,7 @@ test with witness return. \hspace{2ex} \begin{minipage}{\linewidth} - \STATE $k \xleftarrow{\$} \textbf{Z}_{a - 2} \setminus \textbf{Z}_{2}$ + \STATE $k \xleftarrow{\$} \textbf{Z}_{a - 2} \setminus \textbf{Z}_{2}$ \textcolor{c}{\{Uniformly random assignment.\}} \STATE $x \gets k^d \mod a$ \STATE {\bf continue} {\bf if} $x = 1$ \OR $x = a - 1$ \STATE {\bf repeat} $r$ {\bf times or until} $x = 1$ \OR $x = a - 1$ diff --git a/doc/what-is-libzahl.tex b/doc/what-is-libzahl.tex @@ -141,8 +141,9 @@ Unlike other bignum libraries, errors in libzahl are caught using {\tt setjmp}. This ensure that it can be used in robust applications, catching errors does not become a mess, and it minimises the overhead of -catching errors. Errors are only checked when they can -occur, not also after each function return. +catching errors. Typically, errors can be checked when +they can occur and after each function return; however, +here they can be checked only when they can occur. Additionally, libzahl tries to keep the functions' names simple and natural rather than technical or @@ -193,8 +194,8 @@ thread-safe. libzahl is also only designed for POSIX systems. It will probably run just fine on any modern system. But it makes some assumption that POSIX -stipulates or are unpractical not to implement -for machines that should support POSIX (or even +stipulates or are unpractical to leave out from +machines that should support POSIX (or even support modern software): \begin{itemize} @@ -214,12 +215,12 @@ strictly necessary for it to be an CPU-intrinsic, but that would be favourable for performance.) \end{itemize} -Because of the prevalence of theses properties +Because of the prevalence of these properties in contemporary machines, and the utilisation of these properties in software, especially software for POSIX and popular platforms with similar -properties, any new general-purpose machine most -have these properties lest, it but useless with +properties, any new general-purpose machine must +have these properties, lest it be useless with today's software. Therefore, libzahl can make the assumption that the machine has these properties. If the machine does not have these