diff --git a/src/neogb/la_ff_16.c b/src/neogb/la_ff_16.c index 7cbd7a7b..de7ba538 100644 --- a/src/neogb/la_ff_16.c +++ b/src/neogb/la_ff_16.c @@ -778,7 +778,9 @@ static void probabilistic_sparse_reduced_echelon_form_ff_16( /* fill random value array */ for (j = 0; j < nrbl; ++j) { - mull[j] = (int64_t)rand() % fc; + do { + mull[j] = (int64_t)rand() & fc; + } while (mull[j] == 0); } /* generate one dense row as random linear combination * of the rows of the block */ @@ -1675,7 +1677,9 @@ static cf16_t **probabilistic_dense_linear_algebra_ff_16( /* fill random value array */ for (j = 0; j < nrbl; ++j) { - mull[j] = (int64_t)rand() % fc; + do { + mull[j] = (int64_t)rand() & fc; + } while (mull[j] == 0); } /* generate one dense row as random linear combination * of the rows of the block */ @@ -1807,7 +1811,9 @@ static cf16_t **probabilistic_sparse_dense_echelon_form_ff_16( /* fill random value array */ for (j = 0; j < nrbl; ++j) { - mull[j] = (int64_t)rand() % fc; + do { + mull[j] = (int64_t)rand() & fc; + } while (mull[j] == 0); } /* generate one dense row as random linear combination * of the rows of the block */ diff --git a/src/neogb/la_ff_32.c b/src/neogb/la_ff_32.c index 90953f21..c5794cf8 100644 --- a/src/neogb/la_ff_32.c +++ b/src/neogb/la_ff_32.c @@ -186,7 +186,9 @@ static int is_kernel_trivial( /* fill random value array */ for (i = 0; i < ncr; ++i) { - mul[i] = (int64_t)rand() & fc; + do { + mull[j] = (int64_t)rand() & fc; + } while (mull[j] == 0); } for (i = 0; i < sat->ld; ++i) { memset(dr, 0, (uint64_t)dim * sizeof(int64_t)); @@ -2382,7 +2384,9 @@ static void probabilistic_sparse_reduced_echelon_form_ff_32( /* fill random value array */ for (j = 0; j < nrbl; ++j) { - mull[j] = (int64_t)rand() & mask; + do { + mull[j] = (int64_t)rand() & mask; + } while (mull[j] == 0); } /* generate one dense row as random linear combination * of the rows of the block */ @@ -3599,7 +3603,9 @@ static cf32_t **probabilistic_dense_linear_algebra_ff_32( /* fill random value array */ for (j = 0; j < nrbl; ++j) { - mull[j] = (int64_t)rand() & mask; + do { + mull[j] = (int64_t)rand() & mask; + } while (mull[j] == 0); } /* generate one dense row as random linear combination * of the rows of the block */ @@ -3731,7 +3737,9 @@ static cf32_t **probabilistic_sparse_dense_echelon_form_ff_32( /* fill random value array */ for (j = 0; j < nrbl; ++j) { - mull[j] = (int64_t)rand() % fc; + do { + mull[j] = (int64_t)rand() & fc; + } while (mull[j] == 0); } /* generate one dense row as random linear combination * of the rows of the block */ diff --git a/src/neogb/la_ff_8.c b/src/neogb/la_ff_8.c index ef38c4cb..2f740081 100644 --- a/src/neogb/la_ff_8.c +++ b/src/neogb/la_ff_8.c @@ -927,7 +927,9 @@ static void probabilistic_sparse_reduced_echelon_form_ff_8( /* fill random value array */ for (j = 0; j < nrbl; ++j) { - mull[j] = (int64_t)rand() % fc; + do { + mull[j] = (int64_t)rand() & fc; + } while (mull[j] == 0); } /* generate one dense row as random linear combination * of the rows of the block */ @@ -1804,7 +1806,9 @@ static cf8_t **probabilistic_dense_linear_algebra_ff_8( /* fill random value array */ for (j = 0; j < nrbl; ++j) { - mull[j] = (int64_t)rand() % fc; + do { + mull[j] = (int64_t)rand() & fc; + } while (mull[j] == 0); } /* generate one dense row as random linear combination * of the rows of the block */ @@ -1936,7 +1940,9 @@ static cf8_t **probabilistic_sparse_dense_echelon_form_ff_8( /* fill random value array */ for (j = 0; j < nrbl; ++j) { - mull[j] = (int64_t)rand() % fc; + do { + mull[j] = (int64_t)rand() & fc; + } while (mull[j] == 0); } /* generate one dense row as random linear combination * of the rows of the block */