1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
//------------------------------------------------------------------------------
// GB_aliased: determine if two matrices are aliased
//------------------------------------------------------------------------------
// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2022, All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//------------------------------------------------------------------------------
// Returns true if A == B (and not NULL), or if any component A and B are
// aliased to each other. In the latter case, that component of A and B will
// always be shallow, in either A or B, or both. NULL pointers are not
// aliased.
#include "GB.h"
// true if pointers p1 and p2 are aliased and not NULL
#define GB_POINTER_ALIASED(p1,p2) ((p1) == (p2) && (p1) != NULL)
GB_PUBLIC
bool GB_aliased // determine if A and B are aliased
(
GrB_Matrix A, // input A matrix
GrB_Matrix B // input B matrix
)
{
//--------------------------------------------------------------------------
// check the matrices themselves
//--------------------------------------------------------------------------
if (A == NULL || B == NULL)
{
// this is not an error condition; NULL pointers are not an alias
return (false) ;
}
if (A == B)
{
return (true) ;
}
//--------------------------------------------------------------------------
// check their content
//--------------------------------------------------------------------------
bool aliased = false ;
if (GB_POINTER_ALIASED (A->h, B->h))
{
ASSERT (A->h_shallow || B->h_shallow) ;
aliased = true ;
}
if (GB_POINTER_ALIASED (A->p, B->p))
{
ASSERT (A->p_shallow || B->p_shallow) ;
aliased = true ;
}
if (GB_POINTER_ALIASED (A->b, B->b))
{
ASSERT (A->b_shallow || B->b_shallow) ;
aliased = true ;
}
if (GB_POINTER_ALIASED (A->i, B->i))
{
ASSERT (A->i_shallow || B->i_shallow) ;
aliased = true ;
}
if (GB_POINTER_ALIASED (A->x, B->x))
{
ASSERT (A->x_shallow || B->x_shallow) ;
aliased = true ;
}
if (GB_aliased (A->Y, B->Y))
{
ASSERT (A->Y_shallow || B->Y_shallow) ;
aliased = true ;
}
//--------------------------------------------------------------------------
// return result
//--------------------------------------------------------------------------
return (aliased) ;
}
|