Skip to content

matmul: compute term2 through BA_kron_matrices_* - #167

Merged
dance858 merged 1 commit into
mainfrom
matmul-kron-dispatch
Oct 13, 2026
Merged

dance858 merged 1 commit into
mainfrom
matmul-kron-dispatch

Conversation

@dance858

Copy link
Copy Markdown
Collaborator

bivariate_full_dom/matmul.c computed term2 = kron(I_n, X) @ J_g with BA_dense_kron_matrices_*. term2 only feeds sum_matrices_*, which accepts any kind, so it now uses the BA_kron_matrices_* dispatcher (v0.5.1, already pinned). For n == 1 the dispatcher routes through BA_matrices_*, so term2 is permuted_dense (its CSR view is free); for n > 1 nothing changes.

This removes the engine's last direct call to BA_dense_kron_matrices_* / BA_sparse_kron_matrices_*, so the library can make both private (sparsediff_linalg PR to follow). Merge this before the next pin bump.

Test: new test_jacobian_matmul_exp_X_exp_y, the first chain-rule matmul test with n == 1 (exp(X) @ exp(y), X 2x3, y 3x1). Checks the Jacobian against finite differences at two points and asserts term2 is permuted_dense (flipping that assert makes it fail).

305 tests pass (Debug and Release; 304 + 1), library suite passes, PROFILE_ONLY builds, no new warnings.

🤖 Generated with Claude Code

term2 = kron(I_n, X) @ J_g only feeds sum_matrices_*, which takes any kind,
so it no longer needs BA_dense_kron_matrices_* directly. For n == 1 the
dispatcher routes through BA_matrices_* and term2 is permuted_dense. This is
the last direct engine use of BA_dense_kron_matrices_*, so the library can
make it private.

Adds test_jacobian_matmul_exp_X_exp_y, the first chain-rule matmul test with
n == 1: checks the Jacobian against finite differences at two points and that
term2 is permuted_dense.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dance858
dance858 merged commit ab2d561 into main Oct 13, 2026
14 checks passed
@dance858
dance858 deleted the matmul-kron-dispatch branch October 15, 2026 05:39
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.

1 participant