Skip to content

A scalar over a matrix argument is not compiled - #2289

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
a-scalar-over-a-matrix-argument-is-not-compiled-elementwise
Oct 31, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
a-scalar-over-a-matrix-argument-is-not-compiled-elementwise

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

Compiled, x / A with a matrix argument A divided x by every element: 2 / [[1, 2], [3, 4]] came out as [[2, 1], [0.667, 0.5]]. Evaluation takes a scalar over a matrix as the scalar times the inverse, [[-4, 2], [3, -1]]. The compiler does not compute an inverse, just as it does not compute a negative matrix power, so the quotient is now refused with UncompilableNodeException. A matrix written into the expression is still inverted before compiling, as before. DivideFromScalar stays public and does what its documentation says, but the compiler no longer uses it.

2.6.0 and master Now
"x / A" over GenTensor<double>, at A = [[1, 2], [3, 4]], x = 2 [[2, 1], [0.667, 0.5]] throws UncompilableNodeException

AScalarOverAMatrixArgumentTest: the refusal fails on master. Its other two cases, a matrix argument over a scalar and a written matrix that gets inverted, pass on both. The suite (18,293), the trio, F#, AOT and the eight harnesses pass locally. This is a separate change from #2288, which also edits TensorCompilation.cs, in a different part of the file.

Fixes #2287.

🤖 Generated with Claude Code

Compiled, x / A with a matrix argument A divided x by every element:
[[2, 1], [0.667, 0.5]] for 2 / [[1, 2], [3, 4]], where evaluation takes
a scalar over a matrix as the scalar times the inverse, [[-4, 2],
[3, -1]]. The inverse is not compiled, as a negative matrix power is
not, so the quotient is now refused with UncompilableNodeException. A
matrix written into the expression is inverted before it is compiled,
and that is unchanged. DivideFromScalar stays public, for what it says
it is, and the compiler no longer uses it.

AScalarOverAMatrixArgumentTest takes the refusal, which fails on
master, a matrix argument over a scalar and a written matrix inverted,
which pass on both. The suite, the trio, F#, AOT and the eight
harnesses pass.

Fixes #2287.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Rafael-SOWNet Rafael-SOWNet added this to the 2.7.0 milestone Oct 30, 2026
@Rafael-SOWNet Rafael-SOWNet moved this from Todo to In review in AngouriMath Oct 30, 2026
@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.71%. Comparing base (5110f4c) to head (ef0fb02).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2289      +/-   ##
==========================================
- Coverage   86.71%   86.71%   -0.01%     
==========================================
  Files         310      310              
  Lines       67852    67855       +3     
  Branches    19691    19691              
==========================================
+ Hits        58837    58838       +1     
- Misses       4895     4898       +3     
+ Partials     4120     4119       -1     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.26% <100.00%> (-0.01%) ⬇️
fsharp 32.97% <ø> (ø)
interactive 40.72% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...unctions/Compilation/IntoLinq/TensorCompilation.cs 51.38% <100.00%> (+3.50%) ⬆️

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Rafael-SOWNet
Rafael-SOWNet merged commit 0f3df21 into master Oct 31, 2026
36 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in AngouriMath Oct 31, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the a-scalar-over-a-matrix-argument-is-not-compiled-elementwise branch October 31, 2026 04:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Compiled, a scalar over a matrix argument divides by each entry, where evaluation inverts

1 participant