Skip to content

Commit

Permalink
update readme for new interface changes
Browse files Browse the repository at this point in the history
  • Loading branch information
wgurecky committed Aug 8, 2024
1 parent d6b8430 commit 7a4262a
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ About

GMRES in rust using [faer](https://github.com/sarah-ek/faer-rs).

Solves linear systems of the form: Ax=b, where A is sparse. Depends on faer for sparse matrix implementation and sparse QR solver.
Solves linear systems of the form: Ax=b, where A is sparse. Depends on faer for sparse matrix implementation.

Use
===
Expand Down Expand Up @@ -36,15 +36,16 @@ Example use:
];

// init sol guess
let x0 = faer::mat![
// Note: x is modified in-place, the result is stored in x
let mut x = faer::mat![
[0.0],
[0.0],
[0.0],
];

// the final None arg means do not apply left preconditioning
let (res_x, err, iters) = gmres(a_test.as_ref(), b.as_ref(), x0.as_ref(), 10, 1e-8, None).unwrap();
println!("Result x: {:?}", res_x);
let (err, iters) = gmres(a_test.as_ref(), b.as_ref(), x.as_mut(), 10, 1e-8, None).unwrap();
println!("Result x: {:?}", x);
println!("Error x: {:?}", err);
println!("Iters : {:?}", iters);

Expand All @@ -55,7 +56,7 @@ A preconditioner can be supplied:
// continued from above...
use faer_gmres::{JacobiPreconLinOp};
let jacobi_pre = JacobiPreconLinOp::new(a_test.as_ref());
let (res_x, err, iters) = gmres(a_test.as_ref(), b.as_ref(), x0.as_ref(), 10, 1e-8, Some(&jacobi_pre)).unwrap();
let (err, iters) = gmres(a_test.as_ref(), b.as_ref(), x.as_mut(), 10, 1e-8, Some(&jacobi_pre)).unwrap();

## Restarted GMRES:

Expand All @@ -64,8 +65,8 @@ A restarted GMRES routine is provided:
use faer_gmres::restarted_gmres;
let max_inner = 30;
let max_outer = 50;
let (res_x, err, iters) = restarted_gmres(
a_test.as_ref(), b.as_ref(), x0.as_ref(), max_inner, max_outer, 1e-8, None).unwrap();
let (err, iters) = restarted_gmres(
a_test.as_ref(), b.as_ref(), x.as_mut(), max_inner, max_outer, 1e-8, None).unwrap();

This will repeatedly call the inner GMRES routine, using the previous outer iteration's solution as the inital guess for the next outer solve. The current implementation of restarted GMRES in this package can reduce the memory requirements needed, but slow convergence.

Expand Down

0 comments on commit 7a4262a

Please sign in to comment.