1 //------------------------------------------------------------------------------
2 // GB_Scalar_check: print a GraphBLAS GxB_Scalar and check if it is valid
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 // GxB_Scalar: same as a GrB_Vector of length 1
11
12 #include "GB.h"
13
GB_Scalar_check(const GxB_Scalar s,const char * name,int pr,FILE * f)14 GrB_Info GB_Scalar_check // check a GraphBLAS GxB_Scalar
15 (
16 const GxB_Scalar s, // GraphBLAS GxB_Scalar to print and check
17 const char *name, // name of the GxB_Scalar
18 int pr, // print level
19 FILE *f // file for output
20 )
21 {
22
23 //--------------------------------------------------------------------------
24 // check GrB_Matrix conditions
25 //--------------------------------------------------------------------------
26
27 GrB_Info info = GB_matvec_check ((GrB_Matrix) s, name, pr, f, "scalar") ;
28 if (info != GrB_SUCCESS)
29 {
30 // GrB_Matrix form is invalid already
31 return (info) ;
32 }
33
34 //--------------------------------------------------------------------------
35 // check GxB_Scalar specific conditions
36 //--------------------------------------------------------------------------
37
38 if (!GB_SCALAR_OK (s))
39 {
40 GBPR0 (" GxB_Scalar is invalid [%s]\n", name) ;
41 return (GrB_INVALID_OBJECT) ;
42 }
43
44 return (GrB_SUCCESS) ;
45 }
46
47