Repository navigation
Conversation
maleadt
added this pull request to stack #797
September 25, 2026 14:56
maleadt
force-pushed
the
tb/sparse-mapreduce
branch
from
September 25, 2026 15:24
9d6c826 to
48bb64d
Compare
maleadt
removed this pull request from stack #797
October 21, 2026 13:00
maleadt
added this pull request to stack #832
October 21, 2026 13:00
maleadt
force-pushed
the
tb/sparse-vector-broadcast
branch
from
October 22, 2026 10:46
243732e to
55a9018
Compare
maleadt
force-pushed
the
tb/sparse-mapreduce
branch
from
October 22, 2026 10:46
48bb64d to
05b2b7c
Compare
maleadt
force-pushed
the
tb/sparse-vector-broadcast
branch
from
October 22, 2026 10:54
55a9018 to
6d1f474
Compare
maleadt
force-pushed
the
tb/sparse-mapreduce
branch
from
October 22, 2026 10:54
05b2b7c to
f5a2181
Compare
maleadt
marked this pull request as ready for review
October 23, 2026 08:11
The row and column reduction kernels started from op(init, init) with init = zero(eltype), so maximum of a row whose stored entries are all negative returned zero, and they folded the implicit zeros in as nzeros * f(0), which is only right for +: mapreduce(x -> x + 1, max, A) counted the implicit zeros instead of taking their maximum. Reduce the stored values of each slice starting from the first one, and fold in the implicit zeros afterwards with op itself (by repeated squaring, or once for idempotent operators), as SparseArrays does. The full reduction now reduces the stored values and folds the zeros in on the host instead of reducing per-row results with a zero init. An explicit init is combined with each result, empty slices follow Base, and dims=2 returns an m×1 matrix like Base instead of a vector.
maleadt
force-pushed
the
tb/sparse-mapreduce
branch
from
October 23, 2026 08:17
f5a2181 to
725b64c
Compare
maleadt
removed this pull request from stack #832
October 23, 2026 08:18
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sparse
mapreducehad two bugs, both reproducible with JLArrays:op(init, init)withinit = zero(eltype), somaximumof a row whose stored entries are all negative returned0(also for the full reduction, which reduced the per-row results with the same zeroinit);nzeros * f(0), which is only right for+:mapreduce(x -> x + 1, max, A)for a 3×3 matrix with two stored entries gave3.0instead of1.0.Each slice now reduces its stored values starting from the first one and folds in its implicit zeros afterwards with
opitself (by repeated squaring, or once for idempotent operators such asmax), which is what SparseArrays does. The full reduction reduces the stored values with the densemapreduceand folds the zeros in on the host. An explicitinitis combined with each result, empty slices follow Base (init, or the reduction of an empty collection), anddims=2returns anm×1matrix like Base instead of a vector.Tests: all-negative matrices with and without implicit zeros (
maximum/minimumover everydims), non-zero-preserving functions with*,maxandmin,init, an operator without a known neutral element, result shapes, and empty dimensions.Stacked on #795, below the sparse redesign in #745; it can go into 11.x on its own.