Skip to content

Support array eltypes in zeroeltype for Mul getindex - #280

Merged
dlfivefifty merged 1 commit into
masterfrom
zeroeltype-arrays
Sep 24, 2026
Merged

dlfivefifty merged 1 commit into
masterfrom
zeroeltype-arrays

Conversation

@dlfivefifty

Copy link
Copy Markdown
Member

Indexing a Mul (_getindex) starts from zeroeltype(M) = zero(eltype(M)). That fails when the entries are arrays without a type-level zero, e.g. Vector{Float64} or Matrix{Float64}:

julia> X = reshape([[1 2; 3 4], [5 6; 7 8]], 1, 2);

julia> ArrayLayouts.Mul(X, [1, 2])[1]
ERROR: MethodError: no method matching zero(::Type{Matrix{Int64}})

For Mul with an AbstractArray eltype, this PR takes the zero from the entries instead: zero(first(M.A) * first(M.B)). Other eltypes keep zero(eltype(M)), and existing specialisations of zeroeltype are unaffected.

This came up with sums of matrix-valued expansions in ClassicalOrthogonalPolynomials.jl, e.g. sum([exp(x) cos(x); sin(x) 1] for x in 0..1).

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
dlfivefifty added a commit to JuliaApproximation/ClassicalOrthogonalPolynomials.jl that referenced this pull request Sep 23, 2026
Requires FillArrays 1.17.1 (JuliaArrays/FillArrays.jl#452) and
ArrayLayouts 1.12.4 (JuliaLinearAlgebra/ArrayLayouts.jl#280).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Sep 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.23%. Comparing base (1e4fcc1) to head (39f4e97).
⚠️ Report is 11 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master     #280       +/-   ##
===========================================
+ Coverage    0.00%   90.23%   +90.23%     
===========================================
  Files          11       12        +1     
  Lines        1858     1966      +108     
===========================================
+ Hits            0     1774     +1774     
+ Misses       1858      192     -1666     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

@dlfivefifty
dlfivefifty merged commit 27c299f into master Sep 24, 2026
29 of 30 checks passed
@dlfivefifty
dlfivefifty deleted the zeroeltype-arrays branch September 24, 2026 09:25
dlfivefifty added a commit to JuliaApproximation/ClassicalOrthogonalPolynomials.jl that referenced this pull request Sep 24, 2026
* start supporting matrix/smatrix

* Support sums of vector/matrix-valued expansions; remove local [sources]

- sum_layout for SetindexInterlace expansions sums entrywise so Matrix entries work
- interlace_setindex so Vector/Matrix z work (Base.setindex only supports immutable arrays)
- test generator expand and matrix-valued sums, e.g. sum([exp(x) cos(x); sin(x) 1] for x in 0..1)
- require QuasiArrays 0.13.13 for correct generator eltypes

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Replace sum_layout overload with _sum(::SetindexInterlace, dims)

Requires FillArrays 1.17.1 (JuliaArrays/FillArrays.jl#452) and
ArrayLayouts 1.12.4 (JuliaLinearAlgebra/ArrayLayouts.jl#280).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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