Commit 8c9d4582 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Fixed for-loop in triangularSolveUpper to work with unsigned integer types

Also fixed the header in Preconditioner.h
parent ea7bb4c3
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
/***************************************************************************
                          Dummy.h  -  description
                          Preconditioner.h  -  description
                             -------------------
    begin                : Oct 19, 2012
    copyright            : (C) 2012 by Tomas Oberhuber
    copyright            : (C) 2012 by Tomas Oberhuber et al.
    email                : tomas.oberhuber@fjfi.cvut.cz
 ***************************************************************************/

/* See Copyright Notice in tnl/Copyright */

// Implemented by: Jakub Klinkovsky

#pragma once

#include <type_traits>  // std::add_const_t
+5 −3
Original line number Diff line number Diff line
@@ -88,10 +88,12 @@ void triangularSolveUpper( const Matrix& U, Vector1& x, const Vector2& b )

   const IndexType N = x.getSize();

   for( IndexType i = N - 1; i >= 0; i-- ) {
      RealType x_i = b[ i ];
   // GOTCHA: the loop with IndexType i = N - 1; i >= 0; i-- does not work for unsigned integer types
   for( IndexType k = 0; k < N; k++ ) {
      const IndexType i = N - 1 - k;
      const IndexType U_idx = (reversedRows) ? k : i;

      const IndexType U_idx = (reversedRows) ? N - 1 - i : i;
      RealType x_i = b[ i ];

      const auto U_entries = U.getRowCapacity( U_idx );
      const auto U_i = U.getRow( U_idx );