math/: Improve some commentary in the binary-field arithmetic.
[catacomb] / math / gfreduce.h
index 9f69585..ef075c4 100644 (file)
@@ -129,7 +129,10 @@ extern mp *gfreduce_sqrt(gfreduce */*r*/, mp */*d*/, mp */*x*/);
  *             @mp *x@ = some polynomial
  *
  * Returns:    The trace of @x@. (%$\Tr(x)=x + x^2 + \cdots + x^{2^{m-1}}$%
- *             if %$x \in \gf{2^m}$%).
+ *             if %$x \in \gf{2^m}$%).  Since the trace is invariant under
+ *             the Frobenius automorphism (i.e., %$\Tr(x)^2 = \Tr(x)$%), it
+ *             must be an element of the base field, i.e., %$\gf{2}$%, and
+ *             we only need a single bit to represent it.
  */
 
 extern int gfreduce_trace(gfreduce */*r*/, mp */*x*/);
@@ -154,6 +157,17 @@ extern mp *gfreduce_halftrace(gfreduce */*r*/, mp */*d*/, mp */*x*/);
  *             @mp *x@ = some polynomial
  *
  * Returns:    A polynomial @y@ such that %$y^2 + y = x$%, or null.
+ *
+ * Use:                Solves quadratic equations in a field with characteristic 2.
+ *             Suppose we have an equation %$y^2 + A y + B = 0$% where
+ *             %$A \ne 0$%.  (If %$A = 0$% then %$y = \sqrt{B}$% and you
+ *             want @gfreduce_sqrt@ instead.)  Use this function to solve
+ *             %$z^2 + z = B/A^2$%; then set %$y = A z$%, since
+ *             %$y^2 + y = A^2 z^2 + A^2 z = A^2 (z^2 + z) = B$% as
+ *             required.
+ *
+ *             The two roots are %$z$% and %$z + 1$%; this function always
+ *             returns the one with zero scalar coefficient.
  */
 
 extern mp *gfreduce_quadsolve(gfreduce */*r*/, mp */*d*/, mp */*x*/);