Skip to content

Commit

Permalink
Merge pull request #149 from light-curve/dependabot/cargo/GSL-tw-7
Browse files Browse the repository at this point in the history
Update GSL requirement from ^6 to ^7
  • Loading branch information
hombit authored Jun 6, 2024
2 parents ab213b8 + 0127667 commit 8b2e9bf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ emcee = "^0.3.0"
emcee_rand = { version = "^0.3.15", package = "rand" }
enum_dispatch = "^0.3.9"
fftw = { version = "^0.8", default-features = false }
GSL = { version = "^6", default-features = false, optional = true }
GSL = { version = "^7", default-features = false, optional = true }
itertools = "^0.13"
lazy_static = "^1.4"
libm = "^0.2"
Expand Down
25 changes: 16 additions & 9 deletions src/nl_fit/lmsder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use hyperdual::Hyperdual;
use ndarray::Zip;
use rgsl::{
MatrixF64, MultiFitFdfSolver, MultiFitFdfSolverType, MultiFitFunctionFdf, Value, VectorF64,
View,
};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -139,20 +140,26 @@ impl NlsProblem {
self.fit_function.p,
)
.unwrap();
match solver.set(&mut self.fit_function, &x0) {
Value::Success => {}
status => return NlsFitResult { status, solver },
if let Err(status) = solver.set(&mut self.fit_function, &x0) {
return NlsFitResult { status, solver };
}

for _ in 0..self.max_iter {
match solver.iterate() {
Value::Success | Value::ToleranceX | Value::ToleranceF | Value::ToleranceG => {}
status => return NlsFitResult { status, solver },
Ok(_) => {}
Err(Value::ToleranceX | Value::ToleranceF | Value::ToleranceG) => {}
Err(status) => return NlsFitResult { status, solver },
}

match rgsl::multifit::test_delta(&solver.dx(), &solver.x(), self.atol, self.rtol) {
Value::Continue => {}
status => return NlsFitResult { status, solver },
Err(Value::Continue) => {}
Ok(_) => {
return NlsFitResult {
status: Value::Success,
solver,
}
}
Err(status) => return NlsFitResult { status, solver },
}
}
NlsFitResult {
Expand Down Expand Up @@ -275,11 +282,11 @@ struct NlsFitResult {
}

impl NlsFitResult {
fn x(&self) -> VectorF64 {
fn x(&self) -> View<VectorF64> {
self.solver.x()
}

fn f(&self) -> VectorF64 {
fn f(&self) -> View<VectorF64> {
self.solver.f()
}

Expand Down

0 comments on commit 8b2e9bf

Please sign in to comment.