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
|
//------------------------------------------------------------------------------
// gb_mxget_int64_scalar: return an int64 scalar
//------------------------------------------------------------------------------
// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2022, All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//------------------------------------------------------------------------------
#include "gb_interface.h"
uint64_t gb_mxget_uint64_scalar // return uint64 value of a MATLAB scalar
(
const mxArray *mxscalar, // MATLAB scalar to extract
char *name // name of the scalar
)
{
//--------------------------------------------------------------------------
// check inputs
//--------------------------------------------------------------------------
if (!gb_mxarray_is_scalar (mxscalar))
{
GB_COV_PUT ;
mexErrMsgIdAndTxt ("GrB:error", "%s must be a scalar", name) ;
}
//--------------------------------------------------------------------------
// extract the scalar
//--------------------------------------------------------------------------
uint64_t *p, scalar ;
switch (mxGetClassID (mxscalar))
{
case mxINT64_CLASS :
case mxUINT64_CLASS :
p = (uint64_t *) mxGetData (mxscalar) ;
scalar = p [0] ;
break ;
default :
scalar = (uint64_t) mxGetScalar (mxscalar) ;
break ;
}
return (scalar) ;
}
|