Created
June 3, 2018 19:17
-
-
Save danjenson/872d7a7edbfe7db9c8001984ba6add71 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn minimize<F>(func: F) | |
where | |
F: for<'r> Fn(f64, &'r mut f64) -> f64 | |
{ | |
let mmtype: rgsl::MinimizerType<f64> = rgsl::MinimizerType::brent(); | |
let mut mm: rgsl::Minimizer<f64> = rgsl::Minimizer::new(&mmtype).unwrap(); | |
let lambda = 0.5; | |
mm.set(func, &mut lambda, 0.5, 0.0, 1.0); | |
match rgsl::minimizer::test_interval(0.0, 1.0, 1e-6, 0.0) { | |
¦ rgsl::Value::Success => p!("Lambda: {}", mm.x_minimum()), | |
¦ _ => p!("Failed to converge!") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment