From 8078e597c8c64d424466797bd7859548f890b90a Mon Sep 17 00:00:00 2001 From: Jean-Luc Fattebert Date: Mon, 9 Oct 2023 20:42:12 -0400 Subject: [PATCH] Fix Fortran addition test (#737) Check absolute values instead of relative since we now have truly sparse matrices --- tests/Fortran-tests/add_matrix_typed.F90 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/Fortran-tests/add_matrix_typed.F90 b/tests/Fortran-tests/add_matrix_typed.F90 index bb4d1a510..0e900d03e 100644 --- a/tests/Fortran-tests/add_matrix_typed.F90 +++ b/tests/Fortran-tests/add_matrix_typed.F90 @@ -33,7 +33,7 @@ function test_add_matrix_typed(matrix_type, element_kind, element_precision,& DUMMY_KIND(DUMMY_PREC), allocatable :: c_dense(:, :) DUMMY_KIND(DUMMY_PREC), allocatable :: d_dense(:, :) - real(DUMMY_PREC) :: expected, rel_diff, tol + real(DUMMY_PREC) :: expected, diff, tol integer :: i, j @@ -69,9 +69,9 @@ function test_add_matrix_typed(matrix_type, element_kind, element_precision,& do i = 1, n do j = 1, n expected = alpha * a_dense(i, j) + beta * c_dense(i, j) - rel_diff = abs((expected - b_dense(i, j)) / expected) - if(rel_diff > tol) then - print *, "rel. diff = ", rel_diff + diff = abs((expected - b_dense(i, j))) + if(diff > tol) then + print *, "diff = ", diff call bml_error(__FILE__, __LINE__, & & "add() matrices are not identical") end if @@ -81,9 +81,9 @@ function test_add_matrix_typed(matrix_type, element_kind, element_precision,& else expected = a_dense(i, j) end if - rel_diff = abs((expected - d_dense(i, j)) / expected) - if(rel_diff > tol) then - print *, "rel. diff = ", rel_diff + diff = abs((expected - d_dense(i, j))) + if(diff > tol) then + print *, "rel. diff = ", diff call bml_error(__FILE__, __LINE__, & & "add_identity() matrices are not identical") end if