From e252921bfbfd77c9fedc50e3b08df57214d47649 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= <klinkjak@fjfi.cvut.cz>
Date: Thu, 27 Sep 2018 22:37:52 +0200
Subject: [PATCH] Optimization in GMRES: avoiding a priori known scalar product

---
 src/TNL/Solvers/Linear/GMRES_impl.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/TNL/Solvers/Linear/GMRES_impl.h b/src/TNL/Solvers/Linear/GMRES_impl.h
index 2e412398e5..eb2dd89d33 100644
--- a/src/TNL/Solvers/Linear/GMRES_impl.h
+++ b/src/TNL/Solvers/Linear/GMRES_impl.h
@@ -459,8 +459,10 @@ hauseholder_apply_trunc( HostView out,
    // no-op if the problem is not distributed
    CommunicatorType::Bcast( YL_i.getData(), YL_i.getSize(), 0, Traits::getCommunicationGroup( *this->matrix ) );
 
-   // TODO: is aux always 1?
-   const RealType aux = T[ i + i * (restarting_max + 1) ] * y_i.scalarProduct( z );
+   // NOTE: aux = t_i * (y_i, z) = 1  since  t_i = 2 / ||y_i||^2  and
+   //       (y_i, z) = ||z_trunc||^2 + |z_i| ||z_trunc|| = ||y_i||^2 / 2
+//   const RealType aux = T[ i + i * (restarting_max + 1) ] * y_i.scalarProduct( z );
+   constexpr RealType aux = 1.0;
    if( localOffset == 0 ) {
       if( std::is_same< DeviceType, Devices::Host >::value ) {
          for( int k = 0; k <= i; k++ )
-- 
GitLab