Skip to content

Commit

Permalink
Fixes for rust-GSL v7
Browse files Browse the repository at this point in the history
  • Loading branch information
hombit committed Jun 6, 2024
1 parent e75e74a commit 0127667
Showing 1 changed file with 16 additions and 9 deletions.
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 };

Check warning on line 144 in src/nl_fit/lmsder.rs

View check run for this annotation

Codecov / codecov/patch

src/nl_fit/lmsder.rs#L144

Added line #L144 was not covered by tests
}

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 },

Check warning on line 151 in src/nl_fit/lmsder.rs

View check run for this annotation

Codecov / codecov/patch

src/nl_fit/lmsder.rs#L151

Added line #L151 was not covered by tests
}

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 },

Check warning on line 162 in src/nl_fit/lmsder.rs

View check run for this annotation

Codecov / codecov/patch

src/nl_fit/lmsder.rs#L162

Added line #L162 was not covered by tests
}
}
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 0127667

Please sign in to comment.