1function GB_complex_compare (C1, C2, tol) 2%GB_COMPLEX_COMPARE compare GraphBLAS results for complex types 3% 4% compare two complex results, from GB_mex_op and GB_user_op 5 6% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved. 7% SPDX-License-Identifier: Apache-2.0 8 9if (tol ~= 0) 10 if (any (any (isinf (C1)))) 11 assert (isequal (isinf (C1), isinf (C2))) 12 C1 (isinf (C1)) = 1i ; 13 C2 (isinf (C2)) = 1i ; 14 end 15 if (any (any (isnan (C1)))) 16 assert (isequal (isnan (C1), isnan (C2))) 17 C1 (isnan (C1)) = 1i ; 18 C2 (isnan (C2)) = 1i ; 19 end 20 assert (norm (C1 - C2,1) < 16 * eps (norm (C2,1))) 21else 22 assert (isequal (C1, C2)) 23end 24 25 26