1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
// // A rust binding for the GSL library by Guillaume Gomez (guillaume1.gomez@gmail.com) // use std::default::Default; /// The error handling form of the special functions always calculate an error estimate along with the value of the result. /// Therefore, structures are provided for amalgamating a value and error estimate. #[derive(Clone, Copy)] pub struct Result { /// Contains the value. pub val: f64, /// Contains an estimate of the absolute error in the value. pub err: f64 } impl Default for Result { fn default() -> Result { Result::new() } } impl Result { pub fn new() -> Result { Result { val: 0f64, err: 0f64 } } } /// In some cases, an overflow or underflow can be detected and handled by a function. /// In this case, it may be possible to return a scaling exponent as well as an error/value pair in order to save the result from exceeding the dynamic range of the built-in types. #[derive(Clone, Copy)] pub struct ResultE10 { /// Contains the value. pub val: f64, /// Contains an estimate of the absolute error in the value. pub err: f64, /// Exponent field such that the actual result is obtained as result * 10^(e10). pub e10: i32 } impl Default for ResultE10 { fn default() -> ResultE10 { ResultE10::new() } } impl ResultE10 { pub fn new() -> ResultE10 { ResultE10 { val: 0f64, err: 0f64, e10: 0i32 } } }