aboutsummaryrefslogtreecommitdiffhomepage
path: root/plugins/nsatz/polynom.ml
diff options
context:
space:
mode:
authorGravatar letouzey <letouzey@85f007b7-540e-0410-9357-904b9bb8a0f7>2013-03-13 00:00:12 +0000
committerGravatar letouzey <letouzey@85f007b7-540e-0410-9357-904b9bb8a0f7>2013-03-13 00:00:12 +0000
commit552df1605233769ad3cdabaadaa0011605e79797 (patch)
tree28c3ae6a250aba80e1eb53ff9d906df9f49b75c1 /plugins/nsatz/polynom.ml
parentda3cbbcef1f4de9780603225e095f026bb5da709 (diff)
Restrict (try...with...) to avoid catching critical exn (part 7)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@16283 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'plugins/nsatz/polynom.ml')
-rw-r--r--plugins/nsatz/polynom.ml22
1 files changed, 8 insertions, 14 deletions
diff --git a/plugins/nsatz/polynom.ml b/plugins/nsatz/polynom.ml
index ce70a0ffb..ca6d305e8 100644
--- a/plugins/nsatz/polynom.ml
+++ b/plugins/nsatz/polynom.ml
@@ -163,17 +163,12 @@ let max_var l = Array.fold_right (fun p m -> max (max_var_pol2 p) m) l 0
(* equality between polynomials *)
+exception Failed
+
let rec equal p q =
match (p,q) with
(Pint a,Pint b) -> C.equal a b
- |(Prec(x,p1),Prec(y,q1)) ->
- if x<>y then false
- else if (Array.length p1)<>(Array.length q1) then false
- else (try (Array.iteri (fun i a -> if not (equal a q1.(i))
- then failwith "raté")
- p1;
- true)
- with _ -> false)
+ |(Prec(x,p1),Prec(y,q1)) -> (x=y) && Array.for_all2 equal p1 q1
| (_,_) -> false
(* normalize polynomial: remove head zeros, coefficients are normalized
@@ -519,12 +514,11 @@ let divP p q=
let div_pol_rat p q=
let x = max (max_var_pol p) (max_var_pol q) in
- try (let s = div_pol (multP p (puisP (Pint(coef_int_tete q))
- (1+(deg x p) - (deg x q))))
- q x in
- (* degueulasse, mais c 'est pour enlever un warning *)
- if s==s then true else true)
- with _ -> false
+ try
+ let r = puisP (Pint(coef_int_tete q)) (1+(deg x p)-(deg x q)) in
+ let _ = div_pol (multP p r) q x in
+ true
+ with Failure _ -> false
(***********************************************************************
5. Pseudo-division and gcd with subresultants.