Skip to content

Commit

Permalink
wip: use faer Row Col product in arnoldi
Browse files Browse the repository at this point in the history
  • Loading branch information
wgurecky committed Jun 18, 2024
1 parent 3dc52cf commit fb30cc0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ About
=====

[![Crates.io](https://img.shields.io/crates/v/faer_gmres)](https://crates.io/crates/faer_gmres)
![status](https://github.com/wgurecky/faer-gmres/actions/workflows/rust.yml/badge.svg)

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

Expand Down
10 changes: 7 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
//
use faer::prelude::*;
use faer::sparse::*;
use faer::row::{Row, RowMut, RowRef};
use faer::col::{Col, ColRef, ColMut};
use faer::mat;
use num_traits::Float;
use std::{error::Error, fmt};
Expand Down Expand Up @@ -162,6 +164,8 @@ fn arnoldi<'a, T>(
linalg::matmul::sparse_dense_matmul(
qv.as_mut(), a.as_ref(), q_col.as_ref(), None, T::from(1.0).unwrap(), faer::get_global_parallelism());

// let mut qvc: Col<T> = a * q_col.col(0);

// Apply left preconditioner if supplied
match m {
Some(m) => m.apply_linop_to_vec(qv.as_mut()),
Expand All @@ -171,9 +175,9 @@ fn arnoldi<'a, T>(
let mut h = Vec::with_capacity(k + 2);
for i in 0..=k {
let qci: MatRef<T> = q[i].as_ref();
let ht = qv.transpose() * qci;
h.push( ht.read(0, 0) );
qv = qv - (qci * faer::scale(h[i]));
let ht = qv.transpose().row(0) * qci.col(0);
h.push( ht );
qv = qv - (qci * faer::scale(ht));
}

h.push(qv.norm_l2());
Expand Down

0 comments on commit fb30cc0

Please sign in to comment.