4949\begin {document }
5050\frontmatter
5151\pagestyle {empty}
52- \title {LibTomPoly User Manual \\ v0.01 }
52+ \title {LibTomPoly User Manual \\ v0.02 }
5353\author {Tom St Denis \\ tomstdenis@iahu.ca}
5454\maketitle
5555This text and library are hereby placed in the public domain. This book has been
@@ -291,7 +291,12 @@ \section{Multiplying and Dividing by $x$}
291291int pb_rshd(pb_poly *a, int i);
292292\end {alltt }
293293These will multiply (or divide, respectfully) the polynomial `` a'' by $ x^i$ . If $ i \le 0 $ the functions return without
294- performing any operation.
294+ performing any operation. For example,
295+
296+ \begin {alltt }
297+ pb_lshd(a, 2); /* a(x) = a(x) * x^2 */
298+ pb_rshd(a, 7); /* a(x) = a(x) / x^7 */
299+ \end {alltt }
295300
296301\chapter {Basic Arithmetic }
297302\section {Addition, Subtraction and Multiplication }
@@ -319,9 +324,14 @@ \section{Division}
319324\begin {alltt }
320325int pb_div(pb_poly *a, pb_poly *b, pb_poly *c, pb_poly *d);
321326\end {alltt }
322- This will divide the polynomial `` a'' by `` b'' and store the quotient in `` c'' and remainder in `` d'' . Either of
323- `` c'' and `` d'' can be set to \textbf {NULL } to signify their value is not desired. This is useful if you only want the
324- quotient or remainder but not both.
327+ This will divide the polynomial `` a'' by `` b'' and store the quotient in `` c'' and remainder in `` d'' . That is
328+
329+ \begin {equation }
330+ b(x) \cdot c(x) + d(x) = a(x)
331+ \end {equation }
332+
333+ The value of $ deg(d(x))$ is always less than $ deg(b(x))$ . Either of `` c'' and `` d'' can be set to \textbf {NULL } to
334+ signify their value is not desired. This is useful if you only want the quotient or remainder but not both.
325335
326336Since one of the destinations can be \textbf {NULL } the characteristic of the result is taken from `` b'' . The function
327337will return an error if the characteristic of `` a'' differs from that of `` b'' .
@@ -341,6 +351,37 @@ \section{Modular Functions}
341351and store the result in the polynomial `` d'' .
342352
343353\chapter {Algebraic Functions }
354+
355+ \section {Monic Reductions }
356+ \index {pb\_ monic}
357+ \begin {alltt }
358+ int pb_monic(pb_poly *a, pb_poly *b)
359+ \end {alltt }
360+ Makes `` b'' the monic representation of `` a'' by ensuring the most significant coefficient is one. Only defined
361+ over $ GF(p)[x]$ . Note that this is not a straight copy to `` b'' so you must ensure the characteristic of the two
362+ are equal before you call the function\footnote {Note that $ a == b$ is acceptable as well.}. Monic polynomials
363+ are related to their original polynomial through an integer $ k$ as follows
364+
365+ \begin {equation }
366+ a(x) \cdot k^{-1} \equiv b(x)
367+ \end {equation }
368+
369+ \section {Extended Euclidean Algorithm }
370+ \index {pb\_ exteuclid}
371+ \begin {alltt }
372+ int pb_exteuclid(pb_poly *a, pb_poly *b,
373+ pb_poly *U1, pb_poly *U2, pb_poly *U3);
374+ \end {alltt }
375+
376+ This will compute the Euclidean algorithm and find values `` U1'' , `` U2'' , `` U3'' such that
377+
378+ \begin {equation }
379+ a(x) \cdot U1(x) + b(x) \cdot U2(x) = U3(x)
380+ \end {equation }
381+
382+ The value of `` U3'' is reduced to a monic polynomial. The three destination variables are all optional and can
383+ be specified as \textbf {NULL } if they are not desired.
384+
344385\section {Greatest Common Divisor }
345386\index {pb\_ gcd}
346387\begin {alltt }
@@ -355,7 +396,33 @@ \section{Modular Inverse}
355396int pb_invmod(pb_poly *a, pb_poly *b, pb_poly *c);
356397\end {alltt }
357398This finds the modular inverse of `` a'' modulo `` b'' and stores the result in `` c'' . The operation is only defined over
358- $ GF(p)[x]$ . If the operation succeed then the congruent $ a(x)b(x) \equiv 1 \mbox { (mod }c(x)\mbox {)}$ should hold true.
399+ $ GF(p)[x]$ . If the operation succeed then the following congruency should hold true.
400+
401+ \begin {equation }
402+ a(x)c(x) \equiv 1 \mbox { (mod }b(x)\mbox {)}
403+ \end {equation }
404+
405+ \section {Modular Exponentiation }
406+ \index {pb\_ exptmod}
407+ \begin {alltt }
408+ int pb_exptmod (pb_poly * G, mp_int * X, pb_poly * P, pb_poly * Y);
409+ \end {alltt }
410+
411+ This raise `` G'' to the power of `` X'' modulo `` P'' and stores the result in `` Y'' . Or as a congruence
412+
413+ \begin {equation }
414+ Y(x) \equiv G(x)^X \mbox { (mod }P(x)\mbox {)}
415+ \end {equation }
416+
417+ Where `` X'' can be negative\footnote {But in that case $ G^{-1}(x)$ must exist modulo $ P(x)$ .} or positive. This function
418+ is only defined over $ GF(p)[x]$ .
419+
420+ \section {Irreducibility Testing }
421+ \index {pb\_ isirreduc}
422+ \begin {alltt }
423+ int pb_isirreduc(pb_poly *a, int *res);
424+ \end {alltt }
425+ Sets `` res'' to MP\_ YES is `` a'' is irreducible (only for $ GF(p)[x]$ ) otherwise sets `` res'' to MP\_ NO.
359426
360427\input {pb.ind }
361428
0 commit comments