1 //------------------------------------------------------------------------------
2 // GB_mx_xsame: check if two arrays are equal (ignoring zombies)
3 //------------------------------------------------------------------------------
4
5 // SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
6 // SPDX-License-Identifier: Apache-2.0
7
8 //------------------------------------------------------------------------------
9
10 #include "GB_mex.h"
11
GB_mx_xsame(char * X,char * Y,int8_t * Xb,int64_t len,size_t s,int64_t * I)12 bool GB_mx_xsame // true if arrays X and Y are the same (ignoring zombies)
13 (
14 char *X,
15 char *Y,
16 int8_t *Xb, // bitmap of X and Y (NULL if no bitmap)
17 int64_t len, // length of X and Y
18 size_t s, // size of each entry of X and Y
19 int64_t *I // row indices (for zombies), same length as X and Y
20 )
21 {
22 if (X == Y) return (true) ;
23 if (X == NULL) return (false) ;
24 if (Y == NULL) return (false) ;
25 for (int64_t i = 0 ; i < len ; i++)
26 {
27 if (Xb != NULL && Xb [i] == 0)
28 {
29 // ignore X [i] and Y [i] if they are not in the bitmap
30 continue ;
31 }
32 // check X [i] and Y [i], but ignore zombies
33 if (I == NULL || I [i] >= 0)
34 {
35 if (!GB_mx_same (X+i*s, Y+i*s, s)) return (false) ;
36 }
37 }
38 return (true) ;
39 }
40
41