Commits

Yaron Minsky committed 3bf2ce9

ZZp.zz -> ZZp.t

Comments (0)

Files changed (10)

   < write_int : int -> 'a; write_string : string -> unit; .. > ->
   string array -> unit
 val marshal_set :
-  f:((< write_int : int -> 'b; .. > as 'a) -> ZZp.zz -> unit) ->
+  f:((< write_int : int -> 'b; .. > as 'a) -> ZZp.t -> unit) ->
   'a -> ZZp.Set.t -> unit
 val unmarshal_set :
-  f:((< read_int : int; .. > as 'a) -> ZZp.zz) -> 'a -> ZZp.Set.t
+  f:((< read_int : int; .. > as 'a) -> ZZp.t) -> 'a -> ZZp.Set.t
 val marshal_sockaddr :
   < upcast : #Channel.out_channel_obj; write_byte : int -> unit;
     write_char : char -> unit; write_float : float -> unit;
   if Poly.degree x = 1 || Poly.degree x = 0 then true
   else
     let z = Poly.of_array [| ZZp.zero; ZZp.one |] in
-    let zq = powmod ~modulus:x z !ZZp.order in
+    let zq = powmod ~modulus:x z (ZZp.to_number (ZZp.copy_out ZZp.order)) in
     let mz = Poly.scmult z (ZZp.of_int (-1)) in
     let zqmz = Poly.modulo (Poly.add zq mz) x in
     Poly.eq zqmz Poly.zero
 exception Low_mbar
 exception Interpolation_failure
 val interpolate :
-  values:ZZp.zz array -> points:ZZp.zz array -> d:int -> Poly.t * Poly.t
+  values:ZZp.t array -> points:ZZp.t array -> d:int -> Poly.t * Poly.t
 val factor : Poly.t -> ZZp.Set.t
 val reconcile :
-  values:ZZp.zz array -> points:ZZp.zz array -> d:int -> ZZp.Set.t * ZZp.Set.t
+  values:ZZp.t array -> points:ZZp.t array -> d:int -> ZZp.Set.t * ZZp.Set.t
 val rfind : f:(int -> bool) -> int -> int -> int
 module MatrixSlow :
   sig
-    type t = { columns : int; rows : int; array : ZZp.zz array; }
+    type t = { columns : int; rows : int; array : ZZp.t array; }
     val columns : t -> int
     val rows : t -> int
     val dims : t -> int * int
     val copy : t -> t
-    val make : columns:int -> rows:int -> ZZp.zz -> t
-    val init : columns:int -> rows:int -> f:(int -> int -> ZZp.zz) -> t
-    val get : t -> int -> int -> ZZp.zz
-    val set : t -> int -> int -> ZZp.zz -> unit
-    val scmult_ip : t -> ZZp.zz -> unit
-    val scmult : t -> ZZp.zz -> t
-    val scmult_row : t -> int -> ZZp.zz -> unit
+    val make : columns:int -> rows:int -> ZZp.t -> t
+    val init : columns:int -> rows:int -> f:(int -> int -> ZZp.t) -> t
+    val get : t -> int -> int -> ZZp.t
+    val set : t -> int -> int -> ZZp.t -> unit
+    val scmult_ip : t -> ZZp.t -> unit
+    val scmult : t -> ZZp.t -> t
+    val scmult_row : t -> int -> ZZp.t -> unit
     val swap_rows : t -> int -> int -> unit
     val add_ip : t -> t -> unit
     val add : t -> t -> t
     val idot_rec :
-      t -> t -> i:int -> pos1:int -> pos2:int -> ZZp.zz -> ZZp.zz
-    val idot : t -> t -> int -> int -> ZZp.zz
+      t -> t -> i:int -> pos1:int -> pos2:int -> ZZp.t -> ZZp.t
+    val idot : t -> t -> int -> int -> ZZp.t
     val mult : t -> t -> t
     val transpose : t -> t
-    val rowadd : t -> src:int -> dst:int -> scmult:ZZp.zz -> unit
-    val rowsub : t -> src:int -> dst:int -> scmult:ZZp.zz -> unit
+    val rowadd : t -> src:int -> dst:int -> scmult:ZZp.t -> unit
+    val rowsub : t -> src:int -> dst:int -> scmult:ZZp.t -> unit
     val print : t -> unit
   end
 module Matrix :
   sig
-    type t = { columns : int; rows : int; array : ZZp.zzref array; }
+    type t = { columns : int; rows : int; array : ZZp.tref array; }
     val columns : t -> int
     val rows : t -> int
     val dims : t -> int * int
     val copy : t -> t
-    val init : columns:int -> rows:int -> f:(int -> int -> ZZp.zz) -> t
-    val make : columns:int -> rows:int -> ZZp.zz -> t
-    val lget : t -> int -> int -> ZZp.zz
-    val rget : t -> int -> int -> ZZp.zzref
-    val get : t -> int -> int -> ZZp.zz
-    val set : t -> int -> int -> ZZp.zz -> unit
-    val scmult_row : ?scol:int -> t -> int -> ZZp.zz -> unit
+    val init : columns:int -> rows:int -> f:(int -> int -> ZZp.t) -> t
+    val make : columns:int -> rows:int -> ZZp.t -> t
+    val lget : t -> int -> int -> ZZp.t
+    val rget : t -> int -> int -> ZZp.tref
+    val get : t -> int -> int -> ZZp.t
+    val set : t -> int -> int -> ZZp.t -> unit
+    val scmult_row : ?scol:int -> t -> int -> ZZp.t -> unit
     val swap_rows : t -> int -> int -> unit
     val transpose : t -> t
     val rowsub :
-      ?scol:int -> t -> src:int -> dst:int -> scmult:ZZp.zz -> unit
+      ?scol:int -> t -> src:int -> dst:int -> scmult:ZZp.t -> unit
     val print : t -> unit
   end
 val process_row : Matrix.t -> int -> unit
   else if f(low) then low
   else rfind ~f (low + 1) high
 
-type t = { a : ZZp.zz array;
+type t = { a : ZZp.t array;
            (** coefficients, listed from lowest to highest degree *)
            degree : int; (** degree of polynomial *)
          }
 val rfind : f:(int -> bool) -> int -> int -> int
 type t = { a : ZZp.t array; degree : int; }
-val compute_degree : ZZp.zz array -> int
-val init : int -> f:(int -> ZZp.zz) -> t
-val make : int -> ZZp.zz -> t
+val compute_degree : ZZp.t array -> int
+val init : int -> f:(int -> ZZp.t) -> t
+val make : int -> ZZp.t -> t
 val zero : t
 val one : t
 val degree : t -> int
 val copy : t -> t
 val to_string : t -> string
 val splitter : Str.regexp
-val parse_digit : string -> int * ZZp.zz
+val parse_digit : string -> int * ZZp.t
 val of_string : string -> t
 val print : t -> unit
 exception NotEqual
 val eq : t -> t -> bool
-val of_array : ZZp.zz array -> t
-val term : int -> ZZp.zz -> t
+val of_array : ZZp.t array -> t
+val term : int -> ZZp.t -> t
 val set_length : int -> t -> t
-val to_array : t -> ZZp.zz array
+val to_array : t -> ZZp.t array
 val is_monic : t -> bool
-val eval : t -> ZZp.zz -> ZZp.zz
+val eval : t -> ZZp.t -> ZZp.t
 val mult : t -> t -> t
-val scmult : t -> ZZp.zz -> t
+val scmult : t -> ZZp.t -> t
 val add : t -> t -> t
 val neg : t -> t
 val sub : t -> t -> t
 val divmod : t -> t -> t * t
 val modulo : t -> t -> t
 val div : t -> t -> t
-val const_coeff : t -> ZZp.zz
-val nth_coeff : t -> int -> ZZp.zz
-val const : ZZp.zz -> t
+val const_coeff : t -> ZZp.t
+val nth_coeff : t -> int -> ZZp.t
+val const : ZZp.t -> t
 val gcd_rec : t -> t -> t
 val gcd : t -> t -> t
 val child_keys : 'a tree -> Bitstring.t -> Bitstring.t list
 val get_zzp_elements : 'a tree -> node -> ZZp.Set.t
 val clean : 'a option -> 'a tree -> unit
-val points : 'a tree -> ZZp.zz array
+val points : 'a tree -> ZZp.t array
 val get_node_key : ?sef:bool -> 'a tree -> Bitstring.t -> node
 val svalues : node -> ZZp.mut_array
 val size : node -> int
 val truncate : string -> int -> string
 val truncset : String.Set.t -> int -> String.Set.t
 val order_string : string
-val print_ZZp_list : ZZp.zz list -> unit
+val print_ZZp_list : ZZp.t list -> unit
 val print_ZZp_set : ZZp.Set.t -> unit
 
 
 open Number.Infix
-type zz = Number.z
-type t = zz
-type zzref = Number.z ref
-type mut_array = zz array
+type t = Number.z
+type tref = t ref
+type mut_array = t array
 
 module Number = struct
   module T_ = struct
-    type t = zz
+    type t = Number.z
     let compare = Number.compare
     let to_string = Number.to_string
     let of_string = Number.of_string
 (***********************************************************************)
 
 open Core.Std
-type zz
-type t = zz
+type t
 include Comparable with type t := t
 
-type zzref
+type tref
 type mut_array
-val order : Number.z ref
+val order : tref
 val nbits : int ref
 val nbytes : int ref
-val two : zz
-val zero : zz
-val one : zz
-val set_order : zz -> unit
+val two : t
+val zero : t
+val one : t
+val set_order : t -> unit
 val num_bytes : unit -> int
-val of_bytes : string -> zz
-val to_bytes : zz -> string
-val of_int : int -> zz
+val of_bytes : string -> t
+val to_bytes : t -> string
+val of_int : int -> t
 val to_N : 'a -> 'a
-val of_N : zz -> zz
-val add : zz -> zz -> zz
-val sub : zz -> zz -> zz
-val mul : zz -> zz -> zz
-val mult : zz -> zz -> zz
-val imult : zz -> int -> zz
-val add_fast : zz -> zz -> zz
-val mul_fast : zz -> zz -> zz
-val mult_fast : zz -> zz -> zz
-val canonicalize : zz -> zz
-val square : zz -> zz
-val square_fast : zz -> zz
-val imul : zz -> zz -> zz
-val neg : zz -> zz
-val inv : zz -> zz
-val div : zz -> zz -> zz
-(* val sub_fast : zz -> zz -> zz *)
-val lt : zz -> zz -> bool
-val gt : zz -> zz -> bool
-val eq : zz -> zz -> bool
-val neq : zz -> zz -> bool
-val to_string : zz -> string
-val of_string : string -> zz
-val print : zz -> unit
-val points : int -> zz array
+val of_N : t -> t
+val add : t -> t -> t
+val sub : t -> t -> t
+val mul : t -> t -> t
+val mult : t -> t -> t
+val imult : t -> int -> t
+val add_fast : t -> t -> t
+val mul_fast : t -> t -> t
+val mult_fast : t -> t -> t
+val canonicalize : t -> t
+val square : t -> t
+val square_fast : t -> t
+val imul : t -> t -> t
+val neg : t -> t
+val inv : t -> t
+val div : t -> t -> t
+(* val sub_fast : t -> t -> t *)
+val lt : t -> t -> bool
+val gt : t -> t -> bool
+val eq : t -> t -> bool
+val neq : t -> t -> bool
+val to_string : t -> string
+val of_string : string -> t
+val print : t -> unit
+val points : int -> t array
 val svalues : int -> mut_array
-val mult_in : zzref -> zz -> zz -> unit
-(* val mult_fast_in : zzref -> zz -> zz -> unit *)
-val add_in : zzref -> zz -> zz -> unit
-(* val add_fast_in : zzref -> zz -> zz -> unit *)
-val sub_in : zzref -> zz -> zz -> unit
-(* val sub_fast_in : zzref -> zz -> zz -> unit *)
-val copy_in : zzref -> zz -> unit
-val copy_out : zzref -> zz
-val make_ref : zz -> zzref
-val look : zzref -> zz
-val canonicalize_in : zzref -> unit
-val add_el_array : points: zz array -> zz -> zz array
-val del_el_array : points: zz array -> zz -> zz array
-val mult_array : svalues:mut_array -> zz array -> unit
-val add_el : svalues:mut_array -> points:zz array -> zz -> unit
-val del_el : svalues:mut_array -> points:zz array -> zz -> unit
-val array_mult : zz array -> zz array -> zz array
-val mut_array_div : mut_array -> mut_array -> zz array
+val mult_in : tref -> t -> t -> unit
+(* val mult_fast_in : tref -> t -> t -> unit *)
+val add_in : tref -> t -> t -> unit
+(* val add_fast_in : tref -> t -> t -> unit *)
+val sub_in : tref -> t -> t -> unit
+(* val sub_fast_in : tref -> t -> t -> unit *)
+val copy_in : tref -> t -> unit
+val copy_out : tref -> t
+val make_ref : t -> tref
+val look : tref -> t
+val canonicalize_in : tref -> unit
+val add_el_array : points: t array -> t -> t array
+val del_el_array : points: t array -> t -> t array
+val mult_array : svalues:mut_array -> t array -> unit
+val add_el : svalues:mut_array -> points:t array -> t -> unit
+val del_el : svalues:mut_array -> points:t array -> t -> unit
+val array_mult : t array -> t array -> t array
+val mut_array_div : mut_array -> mut_array -> t array
 val mut_array_copy : mut_array -> mut_array
-val cmp : zz -> zz -> int
+val cmp : t -> t -> int
 val length : mut_array -> int
-val mut_array_to_array : mut_array -> zz array
-val mut_array_of_array : zz array -> mut_array
-val to_string_array : zz -> string array
-val rand : (unit -> int) -> zz
+val mut_array_to_array : mut_array -> t array
+val mut_array_of_array : t array -> mut_array
+val to_string_array : t -> string array
+val rand : (unit -> int) -> t
 
-val zset_of_list : zz list -> Set.t
-val canonical_of_number : Number.z -> zz
-val of_number : Number.z -> zz
-val to_number : zz -> Number.z
-module Infix :
-  sig
-    val ( +: ) : zz -> zz -> zz
-    val ( -: ) : zz -> zz -> zz
-    val ( *: ) : zz -> zz -> zz
-    val ( /: ) : zz -> zz -> zz
-    val ( =: ) : zz -> zz -> bool
-    val ( <>: ) : zz -> zz -> bool
-  end
+val zset_of_list : t list -> Set.t
+val canonical_of_number : Number.z -> t
+val of_number : Number.z -> t
+val to_number : t -> Number.z
+module Infix : sig
+  val ( +: ) : t -> t -> t
+  val ( -: ) : t -> t -> t
+  val ( *: ) : t -> t -> t
+  val ( /: ) : t -> t -> t
+  val ( =: ) : t -> t -> bool
+  val ( <>: ) : t -> t -> bool
+end