@@ -202,7 +202,7 @@ fn sign_changes_at(
202
202
let degree = polynomial. degree ( ) . unwrap_or ( 0 ) ;
203
203
let s = Sign :: new ( & polynomial. highest_power_coefficient ( ) ) ;
204
204
if degree. is_odd ( ) {
205
- s. map ( || -s)
205
+ s. map ( |s | -s)
206
206
} else {
207
207
s
208
208
}
@@ -1000,23 +1000,20 @@ trait RootSelector: Sized {
1000
1000
& factor. primitive_sturm_sequence ,
1001
1001
ValueOrInfinity :: Value ( & lower_bound) ,
1002
1002
) ;
1003
- if lower_bound_sign_changes. is_root {
1004
- return lower_bound. into ( ) ;
1005
- }
1006
1003
let upper_bound_sign_changes = sign_changes_at (
1007
1004
& factor. primitive_sturm_sequence ,
1008
1005
ValueOrInfinity :: Value ( & upper_bound) ,
1009
1006
) ;
1010
- if upper_bound_sign_changes . is_root {
1011
- return upper_bound . into ( ) ;
1012
- }
1013
- if lower_bound_sign_changes . sign_change_count
1014
- != upper_bound_sign_changes . sign_change_count
1015
- {
1016
- let num_roots = distance (
1017
- lower_bound_sign_changes . sign_change_count ,
1018
- upper_bound_sign_changes . sign_change_count ,
1019
- ) ;
1007
+ let num_roots = if lower_bound_sign_changes . is_root {
1008
+ 1
1009
+ } else {
1010
+ 0
1011
+ } + distance (
1012
+ lower_bound_sign_changes . sign_change_count ,
1013
+ upper_bound_sign_changes . sign_change_count ,
1014
+ ) ;
1015
+
1016
+ if num_roots > 0 {
1020
1017
roots_left += num_roots;
1021
1018
factors. push ( factor) ;
1022
1019
}
@@ -1885,6 +1882,20 @@ mod tests {
1885
1882
make_sqrt ( 3 , DyadicFractionInterval :: from_int_range ( bi ( 1 ) , bi ( 2 ) , 0 ) ) ,
1886
1883
make_sqrt ( 6 , DyadicFractionInterval :: from_int_range ( bi ( 1 ) , bi ( 10 ) , 0 ) ) ,
1887
1884
) ;
1885
+ test_case (
1886
+ RealAlgebraicNumber :: new_unchecked (
1887
+ p ( & [ -1 , 2 , 4 ] ) ,
1888
+ DyadicFractionInterval :: new ( bi ( -1 ) , bi ( 3 ) , 1 ) ,
1889
+ ) ,
1890
+ RealAlgebraicNumber :: new_unchecked (
1891
+ p ( & [ -1 , 2 , 4 ] ) ,
1892
+ DyadicFractionInterval :: new ( bi ( -1 ) , bi ( 3 ) , 1 ) ,
1893
+ ) ,
1894
+ RealAlgebraicNumber :: new_unchecked (
1895
+ p ( & [ 1 , -12 , 16 ] ) ,
1896
+ DyadicFractionInterval :: new ( bi ( 0 ) , bi ( 2 ) , 3 ) ,
1897
+ ) ,
1898
+ ) ;
1888
1899
}
1889
1900
1890
1901
#[ test]
0 commit comments