Skip to content

Share finite field linear algebra code between 8, 16 and 32 bit - #389

Merged
jerebertho merged 1 commit into
algebraic-solving:masterfrom
ederc:unify-linear-algebra
Nov 4, 2026
Merged

jerebertho merged 1 commit into
algebraic-solving:masterfrom
ederc:unify-linear-algebra

Conversation

@ederc

@ederc ederc commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

The linear algebra in la_ff_8.c, la_ff_16.c and la_ff_32.c consisted largely of copies of the same functions which had drifted apart over time. The field independent parts (echelon forms, dense and sparse-dense linear algebra, interreduction and the drivers) now live in the template la_ff_common.c, which each la_ff_N.c includes after defining a small set of macros for coefficient type, coefficient array name and function suffix. The scalar reduction kernels valid for primes < 2^18, formerly copied in the 8 bit, 16 bit and 17 bit code, are shared via the template la_ff_small_prime.c. The la_ff_N.c files now only contain the code that is specific to the coefficient size, i.e. normalization and the SIMD reduction kernels, plus the SBA and saturation code for 32 bit.

The shared code is based on the 32 bit version, so the 8 and 16 bit linear algebra now also gets its fixes, e.g. bad prime detection when applying a tracer and correct coefficient handling in the 16 bit tracer code. The 17 bit trace kernel now returns NULL for rows reduced to zero, and the 16 bit sparse kernel stores basis index and multiplier in new rows like the other kernels. The 8 and 16 bit sparse kernels take md_t as argument like the 32 bit ones. probabilistic_sparse_dense_linear_ algebra_ff_N_2 is renamed to probabilistic_sparse_dense_linear_algebra_ 2_ff_N to fit the naming scheme.

Done with the help of claude.

The linear algebra in la_ff_8.c, la_ff_16.c and la_ff_32.c consisted
largely of copies of the same functions which had drifted apart over
time. The field independent parts (echelon forms, dense and sparse-dense
linear algebra, interreduction and the drivers) now live in the template
la_ff_common.c, which each la_ff_N.c includes after defining a small set
of macros for coefficient type, coefficient array name and function
suffix. The scalar reduction kernels valid for primes < 2^18, formerly
copied in the 8 bit, 16 bit and 17 bit code, are shared via the template
la_ff_small_prime.c. The la_ff_N.c files now only contain the code that
is specific to the coefficient size, i.e. normalization and the SIMD
reduction kernels, plus the SBA and saturation code for 32 bit.

The shared code is based on the 32 bit version, so the 8 and 16 bit
linear algebra now also gets its fixes, e.g. bad prime detection when
applying a tracer and correct coefficient handling in the 16 bit tracer
code. The 17 bit trace kernel now returns NULL for rows reduced to zero,
and the 16 bit sparse kernel stores basis index and multiplier in new
rows like the other kernels. The 8 and 16 bit sparse kernels take md_t
as argument like the 32 bit ones. probabilistic_sparse_dense_linear_
algebra_ff_N_2 is renamed to probabilistic_sparse_dense_linear_algebra_
2_ff_N to fit the naming scheme.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jerebertho
jerebertho merged commit 708dc64 into algebraic-solving:master Nov 4, 2026
10 checks passed
@jerebertho

Copy link
Copy Markdown
Contributor

Looks good to me, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants