aboutsummaryrefslogtreecommitdiffhomepage
path: root/plugins/nsatz
diff options
context:
space:
mode:
authorGravatar thery <thery@sophia.inria.fr>2016-07-06 13:37:34 +0200
committerGravatar thery <thery@sophia.inria.fr>2016-07-06 13:37:34 +0200
commit8438b97aa5c8d8464ec7389f7992520e2c176ae6 (patch)
tree83c23eb2036260be05421d28632c7e278b851ab1 /plugins/nsatz
parentabe34e282ee0a5f9cca3ea9f527b254388de2cf9 (diff)
improved complexity in nsatz
we use a hashtable to reduce the complexity of creating a duplicate-free list.
Diffstat (limited to 'plugins/nsatz')
-rw-r--r--plugins/nsatz/nsatz.ml425
1 files changed, 13 insertions, 12 deletions
diff --git a/plugins/nsatz/nsatz.ml4 b/plugins/nsatz/nsatz.ml4
index 1230e64b9..592fbce67 100644
--- a/plugins/nsatz/nsatz.ml4
+++ b/plugins/nsatz/nsatz.ml4
@@ -472,12 +472,6 @@ let theoremedeszeros lpol p =
open Ideal
-(* Check if the polynomial p is in the list lp *)
-let rec in_pol p lp =
- match lp with
- | [] -> false
- | p1 :: lp1 -> if equal p p1 then true else in_pol p lp1
-
(* Remove zero polynomials and duplicates from the list of polynomials lp
Return (clp, lb)
where clp is the reduced list and lb is a list of booleans
@@ -485,12 +479,19 @@ let rec in_pol p lp =
element that has been removed
*)
let rec clean_pol lp =
- match lp with
- | [] -> [], []
- | p :: lp1 ->
- let clp, lb = clean_pol lp1 in
- if equal p zeroP || in_pol p clp then clp, true::lb
- else p :: clp, false::lb
+ let t = Hashpol.create 12 in
+ let find p = try Hashpol.find t p
+ with
+ Not_found -> Hashpol.add t p true; false in
+ let rec aux lp =
+ match lp with
+ | [] -> [], []
+ | p :: lp1 ->
+ let clp, lb = aux lp1 in
+ if equal p zeroP || find p then clp, true::lb
+ else
+ (p :: clp, false::lb) in
+ aux lp
(* Expand the list of polynomials lp putting zeros where the list of
booleans lb indicates there is a missing element