next up previous
Next: mpffn class functions Up: mpff class functions Previous: Input and Output Functions

Example program

The following example set pol to the polynomial P = T5 + 2&sstarf#star;T3 + T2 + 3&sstarf#star;T + 1 and build the finite field $ \mathbb {F}$5[T]/(P) and the elements x = T3 + 2&sstarf#star;T + 1(mod P) and y = 4&sstarf#star;T3 + 3&sstarf#star;T + 4(mod P). Finally it computes the product x&sstarf#star;y.

#include <stdio.h>
#include "mpff.h"
int main(void)
{
  mpff_field ff;
  mpz_t p,pol;
  mpz_t px,py;
  mpff_t x,y,z;
  mpz_init_set_ui(p,5);
  mpz_init_set_str(pol,"1 00000000 00000002 00000001 00000003 00000001",16);
  mpz_init_set_str(px,"1  00000000  00000002  00000001",16);
  mpz_init_set_str(py,"1  00000000  00000004  00000000 00000002",16);
  mpff_field_init(ff,p,pol);
  mpff_init(x,ff);
  mpff_init(y,ff);
  mpff_init(z,ff);
  mpff_set_z(x,px);
  mpff_set_z(y,py);
  mpff_mul(z,x,y);
  mpff_out_str(stdout,10,z);
  printf("\n");
  return 0;
}


Bill Allombert 2003-07-01