From c400d1fdaeec5de921a04630656a221b37332dbe Mon Sep 17 00:00:00 2001 From: lkdvos Date: Thu, 23 Jul 2026 14:30:09 -0400 Subject: [PATCH 1/3] fix `one!` implementation --- src/auxiliary/blockarrays.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/auxiliary/blockarrays.jl b/src/auxiliary/blockarrays.jl index ce5a44d..97ffd24 100644 --- a/src/auxiliary/blockarrays.jl +++ b/src/auxiliary/blockarrays.jl @@ -27,9 +27,13 @@ function MAK.zero!(A::BlockBlasMat) end function MAK.one!(A::BlockBlasMat) + rowaxis, colaxis = axes(A) for bj in blockaxes(A, 2), bi in blockaxes(A, 1) a = view(A, bi, bj) - bi == bj ? MAK.one!(a) : MAK.zero!(a) + MAK.zero!(a) + isempty(a) && continue + k = first(rowaxis[bi]) - first(colaxis[bj]) + view(a, MAK.diagind(a, k)) .= one(eltype(a)) end return A end From 8f58bfb55cf61398eede7fa029a075f83cd21342 Mon Sep 17 00:00:00 2001 From: lkdvos Date: Thu, 23 Jul 2026 14:30:18 -0400 Subject: [PATCH 2/3] add test --- test/abstracttensor/blocktensor.jl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/abstracttensor/blocktensor.jl b/test/abstracttensor/blocktensor.jl index b9ff596..2da67da 100644 --- a/test/abstracttensor/blocktensor.jl +++ b/test/abstracttensor/blocktensor.jl @@ -152,6 +152,24 @@ end end end +@testset "one!/isomorphism with mismatched block partitions" begin + # regression test: codomain and domain are isomorphic but partitioned differently + # (Vflat has a single block, Vsum decomposes into two), which used to confuse + # MAK.one!'s block-diagonal detection + W1 = Rep[U₁](0 => 2, 1 => 1) + W2 = Rep[U₁](0 => 2, 1 => 1) + Vsum = W1 ⊞ W2 + Vflat = oplus(Vsum) + + for T in (Float64, ComplexF64), A in (Vector{T}, JLVector{T}) + u = @constinferred unitary(A, Vflat, Vsum) + @test storagetype(u) == A + @test u' * u ≈ id(A, Vsum) + @test only(u * u') ≈ id(A, Vflat) + @test isunitary(u) + end +end + @testset "Basic linear algebra: test via conversion" begin W = V1 ⊗ V2 ⊗ V3 ← V4 ⊗ V5 for T in (Float32, ComplexF64) From 567b39dbed48afb885fa6a3b8236209f809d9af9 Mon Sep 17 00:00:00 2001 From: lkdvos Date: Thu, 23 Jul 2026 14:47:05 -0400 Subject: [PATCH 3/3] bump version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index dcb6c4c..30be82a 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "BlockTensorKit" uuid = "5f87ffc2-9cf1-4a46-8172-465d160bd8cd" -version = "0.3.14" +version = "0.3.15" authors = ["Lukas Devos and contributors"] [deps]