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
|
//------------------------------------------------------------------------------
// GB_mex_isequal: returns true if A and B are equal
//------------------------------------------------------------------------------
// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2020, All Rights Reserved.
// http://suitesparse.com See GraphBLAS/Doc/License.txt for license.
//------------------------------------------------------------------------------
#include "GB_mex.h"
#define USAGE "C = GB_mex_isequal (A, B)"
#define FREE_ALL \
{ \
GB_MATRIX_FREE (&A) ; \
GB_MATRIX_FREE (&B) ; \
GB_mx_put_global (true, 0) ; \
}
void mexFunction
(
int nargout,
mxArray *pargout [ ],
int nargin,
const mxArray *pargin [ ]
)
{
bool malloc_debug = GB_mx_get_global (true) ;
GrB_Matrix A = NULL ;
GrB_Matrix B = NULL ;
GB_WHERE (USAGE) ;
// check inputs
if (nargout > 1 || nargin != 2)
{
mexErrMsgTxt ("Usage: " USAGE) ;
}
#define GET_DEEP_COPY ;
#define FREE_DEEP_COPY ;
// get A and B
A = GB_mx_mxArray_to_Matrix (pargin [0], "A", false, true) ;
B = GB_mx_mxArray_to_Matrix (pargin [1], "B", false, true) ;
if (A == NULL || B == NULL)
{
FREE_ALL ;
mexErrMsgTxt ("failed") ;
}
// C = all (A == B) ; if type is Complex and Complex != GxB_FC64,
// use Complex_eq
bool result ;
METHOD (isequal (&result, A, B, Complex_eq)) ;
// return C to MATLAB as a plain sparse matrix
pargout [0] = mxCreateDoubleScalar ((double) result) ;
FREE_ALL ;
}
|