@@ -332,7 +332,7 @@ macro_rules! new_root_finding_method {
332332 /// implements [`SetTolerances`]), leaving unchanged the value
333333 /// of the absolute tolerance.
334334 ///
335- /// Panics if `rtol` is ≤ 0.
335+ /// Set the default value if `rtol` is ≤ 0.
336336 pub fn rtol<U >( mut self , rtol: U ) -> Self
337337 where Term : SetTolerances <U > {
338338 self . t. set_rtol( rtol) ;
@@ -342,7 +342,7 @@ macro_rules! new_root_finding_method {
342342 /// implements [`SetTolerances`]), leaving unchanged the value
343343 /// of the relative tolerance.
344344 ///
345- /// Panics if `atol` is < 0.
345+ /// Set the default value if `atol` is < 0.
346346 pub fn atol<U >( mut self , atol: U ) -> Self
347347 where Term : SetTolerances <U > {
348348 self . t. set_atol( atol) ;
@@ -1601,8 +1601,8 @@ mod rug {
16011601 macro_rules! float_is_zero { ( $s: expr) => { Float :: is_zero( $s) } }
16021602 macro_rules! float_div64 { ( $x: ident) => { * $x *= 0.015625 } }
16031603 impl_rug ! ( Float , float_new,
1604- Float :: with_val( 53 , 1e-16 ) ,
1605- Float :: with_val( 53 , 1e-12 ) ,
1604+ Float :: with_val( 53 , 1e-16 ) , // Sync with `set_rtol` below
1605+ Float :: with_val( 53 , 1e-12 ) , // Sync with `set_atol` below
16061606 float_is_finite,
16071607 fn assign_mid( & mut self , a: & Self , b: & Self ) {
16081608 self . assign( a) ;
@@ -1628,15 +1628,19 @@ mod rug {
16281628 impl < U > super :: SetTolerances < U > for TolRug < Float >
16291629 where Float : AssignRound < U , Round = Round , Ordering = Ordering > {
16301630 fn set_rtol ( & mut self , rtol : U ) {
1631- self . rtol . assign_round ( rtol, Round :: Nearest ) ;
16321631 if self . rtol <= 0 {
1633- panic ! ( "root1d<rug::Float>: rtol = {:e} ≤ 0" , self . rtol)
1632+ <Float as AssignRound < f64 > >:: assign_round (
1633+ & mut self . rtol , 1e-16 , Round :: Nearest ) ;
1634+ } else {
1635+ self . rtol . assign_round ( rtol, Round :: Nearest ) ;
16341636 }
16351637 }
16361638 fn set_atol ( & mut self , atol : U ) {
1637- self . atol . assign_round ( atol, Round :: Nearest ) ;
16381639 if self . atol < 0 {
1639- panic ! ( "root1d<rug::Float>: atol = {:e} < 0" , self . atol)
1640+ <Float as AssignRound < f64 > >:: assign_round (
1641+ & mut self . atol , 1e-12 , Round :: Nearest ) ;
1642+ } else {
1643+ self . atol . assign_round ( atol, Round :: Nearest ) ;
16401644 }
16411645 }
16421646 }
@@ -1648,8 +1652,8 @@ mod rug {
16481652 } }
16491653 macro_rules! rational_div64 { ( $x: ident) => { * $x /= 64 } }
16501654 impl_rug ! ( Rational , rational_new,
1651- ( 1 , 1000_0000_0000_0000u64 ) . into( ) ,
1652- ( 1 , 1000_0000_0000_0000u64 ) . into( ) ,
1655+ ( 1 , 1000_0000_0000_0000u64 ) . into( ) , // Sync with set_rtol below
1656+ ( 1 , 1000_0000_0000_0000u64 ) . into( ) , // Sync with set_atol below
16531657 rational_is_finite,
16541658 fn assign_mid( & mut self , a: & Self , b: & Self ) {
16551659 self . assign( a) ;
@@ -1675,15 +1679,21 @@ mod rug {
16751679 impl < U > super :: SetTolerances < U > for TolRug < Rational >
16761680 where Rational : rug:: Assign < U > {
16771681 fn set_rtol ( & mut self , rtol : U ) {
1678- <Rational as rug:: Assign < U > >:: assign ( & mut self . rtol , rtol) ;
16791682 if self . rtol <= 0 {
1680- panic ! ( "root1d<rug::Rational>: rtol = {} ≤ 0" , self . rtol)
1683+ <Rational as rug:: Assign < & ( _ , _ ) > >:: assign (
1684+ & mut self . rtol ,
1685+ & ( 1 , 1000_0000_0000_0000u64 ) ) ;
1686+ } else {
1687+ <Rational as rug:: Assign < U > >:: assign ( & mut self . rtol , rtol) ;
16811688 }
16821689 }
16831690 fn set_atol ( & mut self , atol : U ) {
1684- <Rational as rug:: Assign < U > >:: assign ( & mut self . atol , atol) ;
16851691 if self . atol < 0 {
1686- panic ! ( "root1d<rug::Rational>: atol = {} < 0" , self . atol)
1692+ <Rational as rug:: Assign < & ( _ , _ ) > >:: assign (
1693+ & mut self . atol ,
1694+ & ( 1 , 1000_0000_0000_0000u64 ) ) ;
1695+ } else {
1696+ <Rational as rug:: Assign < U > >:: assign ( & mut self . atol , atol) ;
16871697 }
16881698 }
16891699 }
@@ -1740,8 +1750,8 @@ mod tests {
17401750 fn test_ipzero ( ) {
17411751 // y³ + 3 = x
17421752 let r = root1d:: Toms748 :: < f64 , fn ( f64 ) -> f64 , root1d:: Tol < f64 > >
1743- :: ipzero ( -5. , 2. , 4. , 11. ,
1744- -2. , -1. , 1. , 2. ) ;
1753+ :: ipzero ( [ -5. , 2. , 4. , 11. ] ,
1754+ [ -2. , -1. , 1. , 2. ] ) ;
17451755 assert_eq ! ( r, 3. ) ;
17461756 }
17471757
0 commit comments