LCOV - code coverage report
Current view: top level - src/utility - LAGraph_Cached_EMin.c (source / functions) Hit Total Coverage
Test: LAGraph code coverage report. Commit id: 7b9d2ee. Current time (UTC): 2025-06-03T21:57:17Z Lines: 25 25 100.0 %
Date: 2025-06-03 22:02:40 Functions: 1 1 100.0 %

          Line data    Source code
       1             : //------------------------------------------------------------------------------
       2             : // LAGraph_Cached_EMin: determine G->emin
       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             : #define LG_FREE_ALL             \
      19             : {                               \
      20             :     GrB_free (&G->emin) ;       \
      21             : }
      22             : 
      23             : #include "LG_internal.h"
      24             : 
      25          93 : int LAGraph_Cached_EMin
      26             : (
      27             :     // input/output:
      28             :     LAGraph_Graph G,    // graph to determine G->emin
      29             :     char *msg
      30             : )
      31             : {
      32             : 
      33             :     //--------------------------------------------------------------------------
      34             :     // clear msg and check G
      35             :     //--------------------------------------------------------------------------
      36             : 
      37          93 :     LG_CLEAR_MSG_AND_BASIC_ASSERT (G, msg) ;
      38             : 
      39          93 :     if (G->emin != NULL)
      40             :     {
      41             :         // G->emin already computed
      42           2 :         return (GrB_SUCCESS) ;
      43             :     }
      44             : 
      45          91 :     G->emin_state = LAGRAPH_UNKNOWN ;
      46             : 
      47             :     //--------------------------------------------------------------------------
      48             :     // determine the type of G->A and the corresponding min monoid
      49             :     //--------------------------------------------------------------------------
      50             : 
      51          91 :     GrB_Type atype = NULL ;
      52             :     char atype_name [LAGRAPH_MAX_NAME_LEN] ;
      53          91 :     atype_name [0] = '\0' ;
      54          91 :     LAGraph_Matrix_TypeName (atype_name, G->A, msg) ;
      55          91 :     LAGraph_TypeFromName (&atype, atype_name, msg) ;
      56             :     GrB_Monoid monoid ;
      57          91 :     if      (atype == GrB_BOOL  ) monoid = GrB_LAND_MONOID_BOOL  ;
      58          74 :     else if (atype == GrB_INT8  ) monoid = GrB_MIN_MONOID_INT8   ;
      59          72 :     else if (atype == GrB_INT16 ) monoid = GrB_MIN_MONOID_INT16  ;
      60          70 :     else if (atype == GrB_INT32 ) monoid = GrB_MIN_MONOID_INT32  ;
      61          64 :     else if (atype == GrB_INT64 ) monoid = GrB_MIN_MONOID_INT64  ;
      62          51 :     else if (atype == GrB_UINT8 ) monoid = GrB_MIN_MONOID_UINT8  ;
      63          50 :     else if (atype == GrB_UINT16) monoid = GrB_MIN_MONOID_UINT16 ;
      64          49 :     else if (atype == GrB_UINT32) monoid = GrB_MIN_MONOID_UINT32 ;
      65          47 :     else if (atype == GrB_UINT64) monoid = GrB_MIN_MONOID_UINT64 ;
      66          45 :     else if (atype == GrB_FP32  ) monoid = GrB_MIN_MONOID_FP32   ;
      67          42 :     else if (atype == GrB_FP64  ) monoid = GrB_MIN_MONOID_FP64   ;
      68             :     else
      69             :     {
      70           1 :         LG_ASSERT_MSG (false, GrB_NOT_IMPLEMENTED, "type not supported") ;
      71             :     }
      72             : 
      73             :     //--------------------------------------------------------------------------
      74             :     // compute G->emin
      75             :     //--------------------------------------------------------------------------
      76             : 
      77          90 :     GRB_TRY (GrB_Scalar_new (&(G->emin), atype)) ;
      78          90 :     GRB_TRY (GrB_reduce (G->emin, NULL, monoid, G->A, NULL)) ;
      79          90 :     G->emin_state = LAGraph_VALUE ;
      80          90 :     return (GrB_SUCCESS) ;
      81             : }

Generated by: LCOV version 1.14