2323#include <stdlib.h>
2424#include <stdio.h>
2525#include <time.h>
26+
2627// #include <iostream>
2728#undef LG_FREE_ALL
2829#define LG_FREE_ALL \
5354 LAGraph_Free ((void *) &dSp, NULL) ; \
5455 LAGraph_Free ((void *) &dSj, NULL) ; \
5556 }
56- #define DEBUG 1
57+ #define DEBUG 0
5758#define dbg (x ) if (DEBUG) GxB_print(x,5)
5859// uint64_t seed = 213;
5960typedef struct tuple_fp64 {
@@ -69,13 +70,8 @@ void make_fp64(tuple_fp64 *z,
6970{
7071 z -> k = (int64_t )jx ;
7172 z -> v = (* x );
72- size_t tb = (* y )+ 1 ;
73- tb ^= tb << 13 ;
74- tb ^= tb >> 7 ;
75- tb ^= tb << 17 ;
76- tb = (tb ^ (tb >> 27 )) * 0x94D049BB133111EB ;
77- tb = (tb ^ (tb >> 31 )) ;
78- (tb = tb ^ (tb >> 30 )) * 0xBF58476D1CE4E5B9 ;
73+ uint64_t seed = (* y + ix + iy + jy );
74+ uint64_t tb = LG_Random64 (& seed );
7975 z -> tb = tb ;
8076}
8177void max_fp64 (tuple_fp64 * z , const tuple_fp64 * x , const tuple_fp64 * y ){
@@ -111,13 +107,8 @@ void max_fp64(tuple_fp64 *z, const tuple_fp64 *x, const tuple_fp64 *y){
111107"{ \n" \
112108" z->k = (int64_t)jx; \n" \
113109" z->v = (*x); \n" \
114- " size_t tb = (*y)+1; \n" \
115- " tb ^= tb << 13;\n" \
116- " tb ^= tb >> 7;\n" \
117- " tb ^= tb << 17; \n" \
118- " tb = (tb ^ (tb >> 27)) * 0x94D049BB133111EB ; \n" \
119- " tb = (tb ^ (tb >> 31)) ;\n" \
120- " (tb = tb ^ (tb >> 30)) * 0xBF58476D1CE4E5B9 ;\n" \
110+ " uint64_t seed = (*y + ix + iy + jy); \n" \
111+ " uint64_t tb = LG_Random64(&seed);\n" \
121112" z->tb = tb;\n" \
122113"}"
123114
@@ -135,7 +126,7 @@ int LAGraph_Louvain2(
135126
136127 char MATRIX_TYPE [LAGRAPH_MSG_LEN ];
137128 if (DEBUG )
138- GrB_set (GrB_GLOBAL , false , GxB_BURBLE );
129+ GrB_set (GrB_GLOBAL , true , GxB_BURBLE );
139130
140131 //assignment of monoids, bops, and semis
141132 GrB_Monoid plusmon = GrB_PLUS_MONOID_FP64 ;
@@ -184,12 +175,13 @@ int LAGraph_Louvain2(
184175 double o1 ;
185176 double k_i = 0 ;
186177 // FIXME: add check to see if S_result is NULL
187-
178+ LG_Random_Init ( msg )
188179 LG_ASSERT (S_result != NULL, GrB_NULL_POINTER );
189180
190181 GrB_Matrix A = G -> A ;
191182 // GxB_print(A,5);
192-
183+ // printf("rand init");
184+ double test = 23 ;
193185//index bin op definitions
194186//------------------------------------------------------------------------------------------------------------------
195187
@@ -207,7 +199,6 @@ int LAGraph_Louvain2(
207199 GRB_TRY (GrB_Semiring_new (& Semiring , Mon , Bop ));
208200//------------------------------------------------------------------------------------------------------------------
209201
210- GRB_TRY (LAGraph_Random_Init (msg ));
211202
212203 GRB_TRY (GrB_Matrix_nrows (& n ,A ));
213204 GRB_TRY (GrB_Matrix_ncols (& b ,A ));
@@ -255,8 +246,8 @@ int LAGraph_Louvain2(
255246 bool changed = true;
256247 int max_iter = 20 ;
257248 int iter = 0 ;
258- uint64_t seed = ( uint64_t ) time ( NULL ) ;
259- GRB_TRY ( LAGraph_Random_Seed ( y_rand , seed , msg ));
249+ uint64_t seed = 231 ;
250+
260251 // GxB_print(y_rand,5);
261252 GRB_TRY (GrB_mxv (z ,NULL ,NULL ,stdmxm ,S ,k ,NULL ));
262253 // GxB_print(z,5);
@@ -309,7 +300,9 @@ int LAGraph_Louvain2(
309300 // GxB_print(q1,5);
310301 // printf("Size of q1: %ld\n",q1_size);
311302 // GRB_TRY(GrB_Vector_setElement_UINT64(y_rand,seed,0));
312- // GRB_TRY (GrB_assign (y_rand, t_q, NULL, seed, GrB_ALL, n, GrB_DESC_S));
303+ seed += i ;
304+ GRB_TRY (GrB_assign (y_rand , t_q , NULL , seed , GrB_ALL , n , GrB_DESC_S ));
305+
313306 // GxB_print(q1,5);
314307 GRB_TRY (GrB_mxv (max_q1 ,NULL ,NULL ,Semiring ,(GrB_Matrix )q1 ,y_rand ,GrB_DESC_T0 ));
315308 // GxB_print(q1,5);
0 commit comments