diff --git a/readme.md b/readme.md index d6e4d8a..074367e 100644 --- a/readme.md +++ b/readme.md @@ -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 === @@ -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); @@ -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: @@ -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.