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

          Line data    Source code
       1             : //------------------------------------------------------------------------------
       2             : // LG_Random.c: simple and portable random number generator
       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             : #include "LG_internal.h"
      19             : 
      20             : // return a random number between 0 and LG_RANDOM15_MAX
      21    11273171 : GrB_Index LG_Random15 (uint64_t *seed)
      22             : {
      23    11273171 :    (*seed) = (*seed) * 1103515245 + 12345 ;
      24    11273171 :    return (((*seed) / 65536) % (LG_RANDOM15_MAX + 1)) ;
      25             : }
      26             : 
      27             : // return a random uint64_t, in range 0 to LG_RANDOM60_MAX
      28     1768087 : GrB_Index LG_Random60 (uint64_t *seed)
      29             : {
      30             :     GrB_Index i ;
      31     1768087 :     i = LG_Random15 (seed) ;
      32     1768087 :     i = LG_Random15 (seed) + LG_RANDOM15_MAX * i ;
      33     1768087 :     i = LG_Random15 (seed) + LG_RANDOM15_MAX * i ;
      34     1768087 :     i = LG_Random15 (seed) + LG_RANDOM15_MAX * i ;
      35     1768087 :     i = i % (LG_RANDOM60_MAX + 1) ;
      36     1768087 :     return (i) ;
      37             : }

Generated by: LCOV version 1.14