LCOV - code coverage report
Current view: top level - src/utility - LAGraph_TypeName.c (source / functions) Hit Total Coverage
Test: LAGraph code coverage report. Commit id: 3b461aa. Current time (UTC): 2024-01-25T16:04:32Z Lines: 12 12 100.0 %
Date: 2024-01-25 16:05:28 Functions: 3 3 100.0 %

          Line data    Source code
       1             : //------------------------------------------------------------------------------
       2             : // LAGraph_*TypeName: return the name of type of a matrix, vector, or scalar
       3             : //------------------------------------------------------------------------------
       4             : 
       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
       6             : // SPDX-License-Identifier: BSD-2-Clause
       7             : //
       8             : // For additional details (including references to third party source code and
       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
      10             : // Contributors.txt for a full list of contributors. Created, in part, with
      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
      12             : // DM22-0790
      13             : 
      14             : // Contributed by Timothy A. Davis, Texas A&M University
      15             : 
      16             : //------------------------------------------------------------------------------
      17             : 
      18             : // On input, "char *name" is a pointer to a pre-allocated array of size at
      19             : // least LAGRAPH_MAX_NAME_LEN.  On output, the array is filled with a string
      20             : // corresponding to the type of a GrB_Matrix, GrB_Vector, or GrB_Scalar.
      21             : // For built-in types, the strings are defined as:
      22             : 
      23             : //      "bool"      GrB_BOOL
      24             : //      "int8_t"    GrB_INT8
      25             : //      "int16_t"   GrB_INT16
      26             : //      "int32_t"   GrB_INT32
      27             : //      "int64_t"   GrB_INT64
      28             : //      "uint8_t"   GrB_UINT8
      29             : //      "uint16_t"  GrB_UINT16
      30             : //      "uint32_t"  GrB_UINT32
      31             : //      "uint64_t"  GrB_UINT64
      32             : //      "float"     GrB_FP32
      33             : //      "double"    GrB_FP64
      34             : 
      35             : // SuiteSparse:GraphBLAS adds two extended types:
      36             : //      "float complex"     GxB_FC32
      37             : //      "double complex"    GxB_FC64
      38             : 
      39             : // For user-defined types, if SuiteSparse:GraphBLAS is used, then GrB_Type_new
      40             : // can capture the type name, if called as follows, where the 2nd parameter has
      41             : // the form "sizeof (T)" for some C typedef type T.
      42             : //
      43             : //      typedef ... myctype ;
      44             : //      GrB_Type MyType ;
      45             : //      GrB_Type_new (&MyType, sizeof (myctype)) ;
      46             : //
      47             : // In this case, LAGraph_*TypeName returns the string "myctype".
      48             : 
      49             : // Currently, these methods require SuiteSparse:GraphBLAS.  Other GraphBLAS
      50             : // libraries will result in a return value of GrB_NOT_IMPLEMENTED, and the name
      51             : // is returned as an empty string.  The type cannot be queried using the v2.0 C
      52             : // API.  This will be resolved in a future C API spec.
      53             : 
      54             : #include "LG_internal.h"
      55             : 
      56             : //------------------------------------------------------------------------------
      57             : // LAGraph_Matrix_TypeName: return the name of the GrB_Type of a GrB_Matrix
      58             : //------------------------------------------------------------------------------
      59             : 
      60       29498 : int LAGraph_Matrix_TypeName
      61             : (
      62             :     // output:
      63             :     char *name,     // name of the type of the matrix A (user-provided array
      64             :                     // of size at least LAGRAPH_MAX_NAME_LEN).
      65             :     // input:
      66             :     GrB_Matrix A,   // matrix to query
      67             :     char *msg
      68             : )
      69             : {
      70             : 
      71             :     //--------------------------------------------------------------------------
      72             :     // check inputs
      73             :     //--------------------------------------------------------------------------
      74             : 
      75       29498 :     LG_CLEAR_MSG ;
      76       29498 :     LG_ASSERT (name != NULL, GrB_NULL_POINTER) ;
      77             : 
      78             :     //--------------------------------------------------------------------------
      79             :     // determine the name of the type of the GrB_Matrix A
      80             :     //--------------------------------------------------------------------------
      81             : 
      82             :     #if 1 // LAGRAPH_SUITESPARSE
      83       29498 :     return (GxB_Matrix_type_name (name, A)) ;
      84             :     #else
      85             :     name [0] = '\0' ;
      86             :     return (GrB_NOT_IMPLEMENTED) ;
      87             :     #endif
      88             : }
      89             : 
      90             : //------------------------------------------------------------------------------
      91             : // LAGraph_Vector_TypeName: return the name of the GrB_Type of a GrB_Vector
      92             : //------------------------------------------------------------------------------
      93             : 
      94       25383 : int LAGraph_Vector_TypeName
      95             : (
      96             :     // output:
      97             :     char *name,     // name of the type of the vector v (user-provided array
      98             :                     // of size at least LAGRAPH_MAX_NAME_LEN).
      99             :     // input:
     100             :     GrB_Vector v,   // vector to query
     101             :     char *msg
     102             : )
     103             : {
     104             : 
     105             :     //--------------------------------------------------------------------------
     106             :     // check inputs
     107             :     //--------------------------------------------------------------------------
     108             : 
     109       25383 :     LG_CLEAR_MSG ;
     110       25383 :     LG_ASSERT (name != NULL, GrB_NULL_POINTER) ;
     111             : 
     112             :     //--------------------------------------------------------------------------
     113             :     // determine the name of the type of the GrB_Vector v
     114             :     //--------------------------------------------------------------------------
     115             : 
     116             :     #if 1 // LAGRAPH_SUITESPARSE
     117       25383 :     return (GxB_Vector_type_name (name, v)) ;
     118             :     #else
     119             :     name [0] = '\0' ;
     120             :     return (GrB_NOT_IMPLEMENTED) ;
     121             :     #endif
     122             : }
     123             : 
     124             : //------------------------------------------------------------------------------
     125             : // LAGraph_Scalar_TypeName: return the name of the GrB_Type of a GrB_Scalar
     126             : //------------------------------------------------------------------------------
     127             : 
     128           3 : int LAGraph_Scalar_TypeName
     129             : (
     130             :     // output:
     131             :     char *name,     // name of the type of the scalar s (user-provided array
     132             :                     // of size at least LAGRAPH_MAX_NAME_LEN).
     133             :     // input:
     134             :     GrB_Scalar s,   // scalar to query
     135             :     char *msg
     136             : )
     137             : {
     138             : 
     139             :     //--------------------------------------------------------------------------
     140             :     // check inputs
     141             :     //--------------------------------------------------------------------------
     142             : 
     143           3 :     LG_CLEAR_MSG ;
     144           3 :     LG_ASSERT (name != NULL, GrB_NULL_POINTER) ;
     145             : 
     146             :     //--------------------------------------------------------------------------
     147             :     // determine the name of the type of the GrB_Scalar s
     148             :     //--------------------------------------------------------------------------
     149             : 
     150             :     #if 1 // LAGRAPH_SUITESPARSE
     151           2 :     return (GxB_Scalar_type_name (name, s)) ;
     152             :     #else
     153             :     name [0] = '\0' ;
     154             :     return (GrB_NOT_IMPLEMENTED) ;
     155             :     #endif
     156             : }

Generated by: LCOV version 1.14