From e77f70958872bd90104ea717ec6f5465d4eafa1f Mon Sep 17 00:00:00 2001 From: ederc Date: Fri, 26 Jun 2026 13:58:40 +0200 Subject: [PATCH 1/3] fixes randomized multipliers for 8 --- src/neogb/la_ff_8.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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 */ From 317f15cb85f43c735ded29b249c59be72be6b5e5 Mon Sep 17 00:00:00 2001 From: ederc Date: Fri, 26 Jun 2026 13:58:54 +0200 Subject: [PATCH 2/3] fixes randomized multipliers for 16 --- src/neogb/la_ff_16.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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 */ From dc6395509b0dc8af2fe919dc722e343930560eb3 Mon Sep 17 00:00:00 2001 From: ederc Date: Fri, 26 Jun 2026 13:59:04 +0200 Subject: [PATCH 3/3] fixes randomized multipliers for 32 --- src/neogb/la_ff_32.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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 */