Introduction
Introduction Statistics Contact Development Disclaimer Help
refsheet.tex - libzahl - big integer library
git clone git://git.suckless.org/libzahl
Log
Files
Refs
README
LICENSE
---
refsheet.tex (7771B)
---
1 \documentclass[10pt]{article}
2 \usepackage[margin=1in]{geometry}
3 \usepackage{amsmath, amssymb, mathtools}
4 \usepackage{microtype}
5 \DeclarePairedDelimiter\ab{\lvert}{\rvert}
6
7 \newcommand{\size}{{\tt size\_t}}
8 \newcommand{\ullong}{{\tt unsigned long long int}}
9
10 \newcommand{\entry}[3]{ #2 & {\tt #1} & #3 \\ }
11 \newcommand{\cont}[1]{ & & #1 \\ }
12
13 \begin{document}
14
15
16
17 {\Huge libzahl}
18 \vspace{1ex}
19
20 Unless specified otherwise, returns are {\tt void} and all parameters ar…
21 \vspace{1.5em}
22
23
24
25 \hspace{-2ex}
26 \begin{tabular}{lll}
27
28
29
30 \textbf{Initialisation} \\
31 \entry{zsetup(env)} {Initialise libzahl} {must be called before any ot…
32 \cont {used, {\tt env} is a {\tt jm…
33 \cont {{\tt longjmp} to --- with va…
34 \entry{zunsetup()} {Deinitialise libzahl} {will free any pooled memory}
35 \entry{zinit(a)} {Initialise $a$} {call once before use in any …
36 \entry{zfree(a)} {Deinitialise $a$} {must not be used again befor…
37 \\
38
39 \textbf{Error handling} \\
40 \entry{zerror(a)} {Get error code} {returns {\tt enum zerror},…
41 \cont {description in {\tt const …
42 \entry{zperror(a)} {Print error description} {behaves like {\tt perror(a…
43 \cont {possibly {\tt NULL} or $\v…
44 %\\
45
46 \textbf{Arithmetic} \\
47 \entry{zadd(a, b, c)} {$a \gets b + c$} {}
48 \entry{zsub(a, b, c)} {$a \gets b - c$} {}
49 \entry{zmul(a, b, c)} {$a \gets b \cdot c$} {}
50 \entry{zmodmul(a, b, c, d)} {$a \gets b \cdot c \mod d$} {$0 \le a~\mbo…
51 \entry{zdiv(a, b, c)} {$a \gets b / c$} {rounded towar…
52 \entry{zdivmod(a, b, c, d)} {$a \gets c / d$} {rounded towar…
53 \entry{zdivmod(a, b, c, d)} {$b \gets c \mod d$} {$0 \le b~\mbo…
54 \entry{zmod(a, b, c)} {$a \gets b \mod c$} {$0 \le a~\mbo…
55 %\entry{zdiv\_exact(a, b, c)} {$a \gets b / c$} {assumes $c \…
56 \entry{zsqr(a, b)} {$a \gets b^2$} {}
57 \entry{zmodsqr(a, b, c)} {$a \gets b^2 \mod c$} {$0 \le a < \a…
58 \entry{zsqr(a, b)} {$a \gets b^2$} {}
59 \entry{zpow(a, b, c)} {$a \gets b^c$} {}
60 \entry{zpowu(a, b, c)} {$a \gets b^c$} {{\tt c} is an…
61 \entry{zmodpow(a, b, c, d)} {$a \gets b^c \mod d$} {$0 \le a~\mbo…
62 \entry{zmodpowu(a, b, c, d)} {$a \gets b^c \mod d$} {ditto, {\tt c…
63 \entry{zabs(a, b)} {$a \gets \ab{b}$} {}
64 \entry{zneg(a, b)} {$a \gets -b$} {}
65 \\
66
67 \textbf{Assignment} \\
68 \entry{zset(a, b)} {$a \gets b$} {}
69 \entry{zseti(a, b)} {$a \gets b$} {{\tt b} is an {\t…
70 \entry{zsetu(a, b)} {$a \gets b$} {{\tt b} is a {\tt…
71 \entry{zsets(a, b)} {$a \gets b$} {{\tt b} is a deci…
72 %\entry{zsets\_radix(a, b, c)} {$a \gets b$} {{\tt b} is a rad…
73 %\cont {{\tt c} is an \u…
74 \entry{zswap(a, b)} {$a \leftrightarrow b$} {}
75 \\
76
77 \textbf{Comparison} \\
78 \entry{zcmp(a, b)} {Compare $a$ and $b$} {returns {\tt int}…
79 \entry{zcmpi(a, b)} {Compare $a$ and $b$} {ditto, {\tt b} is…
80 \entry{zcmpu(a, b)} {Compare $a$ and $b$} {ditto, {\tt b} is…
81 \entry{zcmpmag(a, b)} {Compare $\ab{a}$ and $\ab{b}$} {returns {\tt int}…
82 \\
83
84
85
86 \end{tabular}
87 \newpage
88 \hspace{-2ex}
89 \begin{tabular}{lll}
90
91
92
93 \textbf{Bit operation} \\
94 \entry{zand(a, b, c)} {$a \gets b \wedge c$} {bitwise}
95 \entry{zor(a, b, c)} {$a \gets b \vee c$} {bitwise}
96 \entry{zxor(a, b, c)} {$a \gets b \oplus c$} {bitwise}
97 \entry{znot(a, b, c)} {$a \gets \lnot b$} {bitwise, cut …
98 \entry{zlsh(a, b, c)} {$a \gets b \cdot 2^c$} {{\tt c} is a …
99 \entry{zrsh(a, b, c)} {$a \gets b / 2^c$} {ditto, rounde…
100 \entry{ztrunc(a, b, c)} {$a \gets b \mod 2^c$} {ditto, $a$ sh…
101 \entry{zbits(a)} {Get number of used bits} {returns \size…
102 \entry{zlsb(a)} {Get index of lowest set bit} {returns \size…
103 \entry{zbtest(a, b)} {Is bit $b$ in $a$ set?} {{\tt b} is a …
104 \entry{zbset(a, b, c, 1)} {$a \gets b$, set bit $c$} {{\tt c} is a …
105 \entry{zbset(a, b, c, 0)} {$a \gets b$, clear bit $c$} {ditto}
106 \entry{zbset(a, b, c, -1)} {$a \gets b$, flip bit $c$} {ditto}
107 \entry{zsplit(a, b, c, d)} {$a \gets c / 2^d$} {{\tt d} is a …
108 \entry{zsplit(a, b, c, d)} {$b \gets c \mod 2^d$} {ditto, $b$ sh…
109 \\
110
111 \textbf{Conversion to string} \\
112 \entry{zstr(a, b, c)} {Convert $a$ to decimal} {returns the …
113 \cont {--- {\tt b} …
114 {\tt NUL…
115 \cont {either 0 or …
116 \cont {resulting st…
117 \cont {allocation s…
118 %\entry{zstr\_radix(a, b, c, d)} {Convert $a$ to radix $d$} {ditto, {\tt…
119 \entry{zstr\_length(a, b)} {Get string length of $a$} {returns \siz…
120 \\
121
122 \textbf{Marshallisation} \\
123 \entry{zsave(a, b)} {Marshal $a$ into $b$} {returns \size{} number…
124 \cont {{\tt b} is a {\tt void…
125 \entry{zsave(a, NULL)} {Get marshal-size of $a$} {returns \size{}}
126 \entry{zload(a, b)} {Unmarshal $a$ from $b$} {returns \size{} number…
127 \cont {{\tt b} is a {\tt cons…
128 %\\
129
130 \textbf{Number theory} \\
131 \entry{zsignum(a, b)} {$a \gets \mbox{sgn}~b$} {}
132 \entry{zeven(a)} {Is $a$ even?} {returns {\tt int} 1 …
133 \entry{zeven\_nonzero(a)} {Is $a$ even?} {ditto, assumes $a \n…
134 \entry{zodd(a)} {Is $a$ odd?} {returns {\tt int} 1 …
135 \entry{zodd\_nonzero(a)} {Is $a$ odd?} {ditto, assumes $a \n…
136 \entry{zzero(a)} {Is $a$ zero?} {returns {\tt int} 1 …
137 \entry{zgcd(a, b, c)} {$a \gets \gcd(c, b)$} {$a < 0$ if $b < 0 \w…
138 \entry{zptest(a, b, c)} {Is $b$ a prime?} {$c$ runs of Miller--…
139 \cont {{\tt enum zprimality…
140 \cont {(and stores the witn…
141 \cont {{\tt a} is {\tt NULL…
142 \cont {{\tt PRIME} (2)}
143 %\\
144
145 \textbf{Randomness} \\
146 \entry{zrand(a, b, UNIFORM, d)} {$a \xleftarrow{\$} \textbf{Z}_d$}
147 {{\tt b} is a {\tt enum zranddev}, e.g.}
148 \cont {{\tt DEFAULT\_RANDOM}, {\tt FASTEST\_RANDOM}}
149 \\
150
151
152
153 \end{tabular}
154 \end{document}
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.