From 185b176674b53a3f320a1571571736bd0b99ef59 Mon Sep 17 00:00:00 2001 From: Katharine Hyatt Date: Thu, 6 Aug 2026 13:59:18 +0200 Subject: [PATCH 1/3] Avoid undefined-reference errors for BigFloat/BigInt --- src/mapreduce.jl | 7 +++++++ test/othertests.jl | 31 +++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/mapreduce.jl b/src/mapreduce.jl index 45e3980..be02584 100644 --- a/src/mapreduce.jl +++ b/src/mapreduce.jl @@ -6,6 +6,13 @@ LinearAlgebra.adjoint!(dst::StridedView, src::StridedView) = copy!(dst, adjoint( LinearAlgebra.transpose!(C::StridedView, A::StridedView) = copy!(C, transpose(A)) Base.permutedims!(dst::StridedView, src::StridedView, p) = copy!(dst, permutedims(src, p)) Base.fill!(A::StridedView, val) = map!(Returns(val), A, A) +function Base.fill!( + A::StridedView{<:Union{BigFloat, Complex{BigFloat}, BigInt, Complex{BigInt}}}, val + ) + isempty(A) && return A + _mapreduce_order!(Returns(val), nothing, nothing, size(A), (A,)) + return A +end # This is a wrapper function intended to allow us to # intercept "conj" and rewrite it in cases where the diff --git a/test/othertests.jl b/test/othertests.jl index 556b860..12aa718 100644 --- a/test/othertests.jl +++ b/test/othertests.jl @@ -155,6 +155,37 @@ end end end +@testset "fill! and reductions with undef-initialized BigFloat/BigInt storage" begin + @testset for T in (BigFloat, Complex{BigFloat}, BigInt, Complex{BigInt}) + # test the specific path in src/mapreduce here that avoids undefined + # reference errors + @test collect(fill!(StridedView(Vector{T}(undef, 5)), one(T))) == ones(T, 5) + + A = StridedView(Vector{T}(undef, 12), (2, 3), (1, 4), 0) + @test collect(fill!(A, T(3))) == fill(T(3), 2, 3) + + B = StridedView(Vector{T}(undef, 6), (2, 3), (-1, 2), 1) + @test collect(fill!(B, T(5))) == fill(T(5), 2, 3) + + @test fill!(StridedView(Vector{T}(undef, 0), (0,), (1,), 0), one(T)) |> isempty + + S = StridedView(Vector{T}(undef, 1), (), (), 0) + @test fill!(S, T(7))[] == T(7) + + R = rand(T, 6) + V, M = StridedView(copy(R), (2, 3), (1, 2), 0), reshape(copy(R), 2, 3) + @test norm(V) == norm(M) + @test sum(V) == sum(M) + @test prod(V) == prod(M) + @test maximum(abs, V) == maximum(abs, M) + @test minimum(abs, V) == minimum(abs, M) + + # large enough to reach the threaded reduction path + L = StridedView(Vector{T}(undef, 1 << 17)) + @test sum(fill!(L, T(2))) == T(2) * (1 << 17) + end +end + @testset "0-dimensional (scalar) StridedView" begin @testset for T in (Float32, Float64, ComplexF32, ComplexF64) R = fill(rand(T)) # 0-dimensional Array From 0be5b8836340789e8b12fd2d3d9fb720b1e8b6b8 Mon Sep 17 00:00:00 2001 From: Katharine Hyatt Date: Thu, 6 Aug 2026 13:59:40 +0200 Subject: [PATCH 2/3] Bump patch version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index c483aaa..bba7c4f 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Strided" uuid = "5e0ebb24-38b0-5f93-81fe-25c709ecae67" -version = "2.6.4" +version = "2.6.5" authors = ["Lukas Devos ", "Maarten Van Damme ", "Jutho Haegeman "] [deps] From ad7ccacd03bb26642c3908c7b7949916297bea53 Mon Sep 17 00:00:00 2001 From: Katharine Hyatt Date: Thu, 6 Aug 2026 14:36:58 +0200 Subject: [PATCH 3/3] Don't use rand (BigInt hates it) --- test/othertests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/othertests.jl b/test/othertests.jl index 12aa718..ba873b1 100644 --- a/test/othertests.jl +++ b/test/othertests.jl @@ -172,7 +172,7 @@ end S = StridedView(Vector{T}(undef, 1), (), (), 0) @test fill!(S, T(7))[] == T(7) - R = rand(T, 6) + R = T[1, 4, 2, 3, 5, 6] V, M = StridedView(copy(R), (2, 3), (1, 2), 0), reshape(copy(R), 2, 3) @test norm(V) == norm(M) @test sum(V) == sum(M)