diff --git a/tests/C-tests/add_matrix_typed.c b/tests/C-tests/add_matrix_typed.c index bc873ea32..619b7b133 100644 --- a/tests/C-tests/add_matrix_typed.c +++ b/tests/C-tests/add_matrix_typed.c @@ -6,7 +6,7 @@ #include #include #if defined(SINGLE_REAL) || defined(SINGLE_COMPLEX) -#define REL_TOL 1e-6 +#define REL_TOL 2e-6 #else #define REL_TOL 1e-12 #endif @@ -30,33 +30,44 @@ int TYPED_FUNC( double beta = 0.8; double threshold = 0.0; - LOG_DEBUG("rel. tolerance = %e\n", REL_TOL); + LOG_INFO("rel. tolerance = %e\n", REL_TOL); A = bml_random_matrix(matrix_type, matrix_precision, N, M, sequential); B = bml_copy_new(A); C = bml_random_matrix(matrix_type, matrix_precision, N, M, sequential); + LOG_INFO("A\n"); + bml_print_bml_matrix(A, 0, N, 0, N); + LOG_INFO("B\n"); + bml_print_bml_matrix(B, 0, N, 0, N); + LOG_INFO("C\n"); + bml_print_bml_matrix(C, 0, N, 0, N); + bml_add(B, C, alpha, beta, threshold); A_dense = bml_export_to_dense(A, dense_row_major); B_dense = bml_export_to_dense(B, dense_row_major); C_dense = bml_export_to_dense(C, dense_row_major); + + LOG_INFO("A_dense\n"); bml_print_dense_matrix(N, matrix_precision, dense_row_major, A_dense, 0, N, 0, N); + LOG_INFO("B_dense\n"); bml_print_dense_matrix(N, matrix_precision, dense_row_major, B_dense, 0, N, 0, N); + LOG_INFO("C_dense\n"); bml_print_dense_matrix(N, matrix_precision, dense_row_major, C_dense, 0, N, 0, N); for (int i = 0; i < N * N; i++) { double expected = alpha * A_dense[i] + beta * C_dense[i]; - double rel_diff_val = (expected - B_dense[i]) / expected; - double rel_diff = fabs(rel_diff_val); + double abs_diff = fabs(expected - B_dense[i]); + double rel_diff = abs_diff / expected; if (rel_diff > REL_TOL) { LOG_ERROR - ("matrices are not identical; expected[%d] = %e, B[%d] = %e\n", - i, expected, i, B_dense[i]); + ("matrices are not identical; expected[%d] = %e, B[%d] = %e, abs. diff = %e, |rel. diff| = %e\n", + i, expected, i, B_dense[i], abs_diff, rel_diff); return -1; } }