MeatAxe
2.4

The MeatAxe can work with polynomials over a finite field. A polynomial is represented by a Poly_t structure. Each polynomial carries the field order, i.e., you can work with polynomials over different fields on one program. However, this feature is currently of little use since all standard operations only work on polynomials over the same field, and there is no easy way to identify polynomials over a field and its subfields.
There is a second representation of polynomials as product of factors, see FPoly_t.
Data Structures  
struct  factor_t 
Internal representation of a factor. More...  
class  FPoly_t 
A Factored Polynomial. More...  
class  Poly_t 
A Polynomial. More...  
Functions  
FPoly_t *  Factorization (const Poly_t *pol) 
Factor a polynomial. More...  
int  FpIsValid (const FPoly_t *p) 
Check a Factored Polynomial. More...  
FPoly_t *  FpAlloc () 
Allocate a Factored Polynomial. More...  
int  FpFree (FPoly_t *x) 
Free a Factored Polynomial. More...  
FPoly_t *  FpDup (const FPoly_t *src) 
Duplicate a Factored Polynomial. More...  
FPoly_t *  FpMulP (FPoly_t *dest, const Poly_t *src, int pwr) 
Multiply With an Irreducible Polynomial. More...  
FPoly_t *  FpMul (FPoly_t *dest, const FPoly_t *src) 
Multiply Factored Polynomials. More...  
int  FpPrint (const char *name, const FPoly_t *p) 
Print a factored polynomial. More...  
int  PolIsValid (const Poly_t *p) 
Check a polynomial. More...  
Poly_t *  PolAlloc (int fl, int n) 
Allocate a polynomial This function creates the polynomial p(x)=x^n over the current field. More...  
int  PolFree (Poly_t *x) 
Free a polynomial" This function frees a polynomial data structure and cleans up all internal data. More...  
void  Pol_Normalize (Poly_t *p) 
Normalize a polynomial. More...  
Poly_t *  PolDerive (Poly_t *pol) 
Derive a Polynomial. More...  
Poly_t *  PolDivMod (Poly_t *a, const Poly_t *b) 
Polynomial Division. More...  
Poly_t *  PolMod (Poly_t *a, const Poly_t *b) 
Polynomial division. More...  
Poly_t *  PolDup (const Poly_t *p) 
Duplicate a Polynomial. More...  
Poly_t *  PolGcd (const Poly_t *a, const Poly_t *b) 
Greatest Common Divisor of two Polynomials. More...  
int  PolGcdEx (const Poly_t *a, const Poly_t *b, Poly_t **result) 
Greatest Common Divisor of two Polynomials. More...  
Poly_t *  PolMul (Poly_t *dest, const Poly_t *src) 
Multiply Polynomials. More...  
void  PolPrint (char *name, const Poly_t *p) 
Print a Polynomial This function prints a polynomial on the standard output in a humanreadable form. More...  
Poly_t *  PolRead (FILE *f) 
Read a Polynomial from a File. More...  
Poly_t *  PolLoad (const char *fn) 
Read a Polynomial from a File. More...  
int  PolWrite (const Poly_t *p, FILE *f) 
Write a polynomial to a file. More...  
int  PolSave (const Poly_t *pol, const char *fn) 
Write a Polynomial to a File. More...  
Factor a polynomial.
This function decomposes a polynomial into irreducible factors using the Berlekamp algorithm.
pol  Polynomial to factor. 
FPoly_t* FpAlloc  (  ) 
Allocate a Factored Polynomial.
This function creates a new Fpoly_t structure. The new polynomial is empty, i.e., it has no factors.
Duplicate a Factored Polynomial.
This function creates a copy of a factored polynomial.
src  Pointer to a factored polynomial. 
int FpFree  (  FPoly_t *  x  ) 
int FpIsValid  (  const FPoly_t *  p  ) 
Check a Factored Polynomial.
p  The polynomial. 
Multiply Factored Polynomials.
Multiplies dest by src. The previous content of dest is lost.
dest  Factored polynomial to modify. 
src  Factored polynomial. 
Multiply With an Irreducible Polynomial.
This function multiplies a factored polynomial with the power of an an irreducible factor. It is not checked that src is irreducible.
dest  Factored polynomial to modify. 
src  Irreducible polynomial. 
pwr  Power of the irreducible polynomial. 
int FpPrint  (  const char *  name, 
const FPoly_t *  p  
) 
Print a factored polynomial.
This function prints a factored polynomial to the standard output. If name is not 0, "name=" is printed before the polynomial.
name  Name of the polynomial or 0. 
p  Pointer to the factored polynomial. 
void Pol_Normalize  (  Poly_t *  p  ) 
Normalize a polynomial.
This function makes sure that the leading coefficient of a polynomial is nonzero.
Poly_t* PolAlloc  (  int  fl, 
int  n  
) 
Allocate a polynomial This function creates the polynomial p(x)=x^n over the current field.
If n is negative, a zero polynomial is created. The return value is a pointer to a newly allocated Poly_t structure. The caller is responsible for releasing memory by calling PolFree() when the polynomial is no longer needed.
fl  Field order. 
n  Degree of the polynomial. 
Derive a Polynomial.
This function derives a polynomial. Note that the derived polynomial is stored in pol, replacing the original polynomial. The following piece of code shows how to keep the original polynomial intact while calculating the derivative:
pol  Pointer to the polynomial. 
Polynomial Division.
This function performs a polynomial division. Given two polynomials a and b≠0 over the same field, PolDivMod() finds two polynomials q and r such that a=qb+r, and deg(r)<deg(b).
The quotient q is returned as the function result. This is a newly allocated polynomial. The caller is responsible for deleting the quotient when it no longer needed.
The remainder r, is stored in a and replaces the original value. If you need to preserve the value of a you must make a copy using PolDup() before calling PolDivMod(). b is not changed.
a  First polynomial (numerator) on call, remainder on return. 
b  Second polynomial (denominator). 
Duplicate a Polynomial.
This function creates a copy of an existing polynomial.
p  Pointer to the polynomial. 
int PolFree  (  Poly_t *  x  ) 
Free a polynomial" This function frees a polynomial data structure and cleans up all internal data.
x  Pointer to the polynomial. 
Greatest Common Divisor of two Polynomials.
This function calculates the gratest common divisor of two poynomials. The polynomials must be over the same field, and at least one of them must be different from zero. Unlike most polynomial functions, PolGcd() normalizes the result, i.e., the leading coefficient of the g.c.d., is always one.
a  First polynomial. 
b  Second polynomial. 
Greatest Common Divisor of two Polynomials.
Given two polynomials a and b, this function calculates the greatest common divisor g=gcd(a,b) and two polynomials p, q such that g=pa+qb. Both a and b must be nonzero. The leading coefficient of g is always one.
result must be a pointer to an array of three Poly_t *
elements. If the function is successful, pointers to g, p, and q have been stored in result[0], result[1], and result[2], respectively. The caller is responsible for destroying these polynomials when they are no longer needed. In particular, you must not use the same result buffer again with PolGcdEx() before the contents have been freed.
a  First polynomial. 
b  Second polynomial. 
result  Result buffer for the g.c.d. and coefficients (see below). 
int PolIsValid  (  const Poly_t *  p  ) 
Check a polynomial.
This function checks if the argument is a pointer to a valid polynomial. If the polynomial the function returns 1. Otherwise, an error is signalled and, if the error handler does not terminate the program, the function returns 0.
p  The polynomial to check. 
Poly_t* PolLoad  (  const char *  fn  ) 
Read a Polynomial from a File.
This function opens a file, reads a single polynomial, and closes the file. The return value is a pointer to the polynomial or NULL on error. If the file contains more than one polynomial, only the first one is read.
If a polynomial was successfully read, the function returns a pointer to a newly created Poly_t object. The caller is responsible for deleting this object as soon as it no longer needed.
fn  File name. 
Polynomial division.
This function replaces a with the remainder of the division of a by b.
a  First polynomial (numerator) on call, remainder on return. 
b  Second polynomial (denominator). 
Multiply Polynomials.
This function multiplies dest by src and returns dest. The polynomials must be over the same field.
dest  Pointer to the first polynomial. 
src  Pointer to the second polynomial. 
void PolPrint  (  char *  name, 
const Poly_t *  p  
) 
Print a Polynomial This function prints a polynomial on the standard output in a humanreadable form.
If name is not 0, the name followed by an equal sign is printed before the polynomial. For example, the statement PolPrint("P",P)
could produce the following output:
P=3x^2+x+1
name  Name to print before the polynomial or 0. 
p  Pointer to the polynomial. 
Poly_t* PolRead  (  FILE *  f  ) 
Read a Polynomial from a File.
This function reads a polynomial from a file. If successful, the return value is a pointer to a new Poly_t object. The caller is responsible for deleting this polynomial with PolFree() when it is no longer needed.
f  File to read from. 
int PolSave  (  const Poly_t *  pol, 
const char *  fn  
) 
Write a Polynomial to a File.
This function creates a file, writes a single polynomial to the file and closes the file. If a f ile with the specified name already exists, it's contents are destroyed.
pol  Polynomial to write. 
fn  File name. 