blob: cb5cbe4acbc214f290eb56a002c38a0a22aee62a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
(** Finite field. *)
exception Invalid_arrity
(** Raised when creating a polynomial extension field element with the wrong
number of coefficients. *)
(** Module signature for a finite field. *)
module type S = sig
type t
(** A type representing an element in the finite field. *)
val zero : t
(** The zero value, i.e. the additive identity. *)
val one : t
(** The one value, i.e. the multiplicative identity. *)
val of_string : string -> t
(** [of_string s] returns the field element represented by [s]. *)
val to_string : t -> string
(** [to_string a] returns the string representation of [a]. *)
val equal : t -> t -> bool
(** [equal a b] returns [true] if [a] is equal to [b]. *)
val neg : t -> t
(** [neg a] is the additive inverse of [a]. [add a (neg a) = zero] for all
[a]. *)
val inv : t -> t
(** [inv a] is the multiplicative inverse of [a]. [mul a (inv a) = one] for
all non-zero [a]. Furthermore, we define [inv zero = zero]. *)
val add : t -> t -> t
(** [add a b] is the sum of [a] plus [b] *)
val sub : t -> t -> t
(** [sub a b] is the difference of [a] minus [b]. It is equivalent to
[add a (neg b)]. *)
val mul : t -> t -> t
(** [add a b] is the product of [a] times [b] *)
val div : t -> t -> t
(** [div a b] is the field division of [a] by [b]. It is equivalent to
[mul a (inv b)]. Furthermore, we define [div a zero = zero]. *)
val ( ~- ) : t -> t
(** [neg]. *)
val ( ~/ ) : t -> t
(** [inv]. *)
val ( + ) : t -> t -> t
(** [add]. *)
val ( - ) : t -> t -> t
(** [sub]. *)
val ( * ) : t -> t -> t
(** [mul]. *)
val ( / ) : t -> t -> t
(** [div]. *)
end
(** Module signature for a polynomial extension field. *)
module type Sx = sig
include S
type f
(** The field over which the polynomial is defined. *)
val of_f : f -> t
(** [of_f a] maps an underlying field element to the extension field. *)
val of_coeffs : f array -> t
(** [of_coeffs c] is the field element with polynomial coefficients [c]. *)
val to_coeffs : t -> f array
(** [to_coeffs a] are the polynomial coefficients of [a]. *)
end
|