From ea251017150a684ed0ebae364e2bddc7db7c9921 Mon Sep 17 00:00:00 2001 From: mtfishman Date: Wed, 11 Mar 2026 18:24:01 -0400 Subject: [PATCH 1/2] Use add in unmatricizeadd --- Project.toml | 2 +- src/matricize.jl | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index e506f0c..7d69092 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "TensorAlgebra" uuid = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a" -version = "0.7.18" +version = "0.7.19" authors = ["ITensor developers and contributors"] [workspace] diff --git a/src/matricize.jl b/src/matricize.jl index b41171e..dc2c6de 100644 --- a/src/matricize.jl +++ b/src/matricize.jl @@ -318,9 +318,8 @@ function unmatricizeadd!( invperm_codomain::Tuple{Vararg{Int}}, invperm_domain::Tuple{Vararg{Int}}, α::Number, β::Number ) - a12 = unmatricize(style, m, axes(a_dest), invperm_codomain, invperm_domain) - a_dest .= α .* a12 .+ β .* a_dest - return a_dest + a = unmatricize(style, m, axes(a_dest), invperm_codomain, invperm_domain) + return add!(a_dest, a, α, β) end function unmatricizeadd!( From 3074fa8c67c12f793149ff7ff57b1f755e6c73de Mon Sep 17 00:00:00 2001 From: mtfishman Date: Thu, 12 Mar 2026 13:27:34 -0400 Subject: [PATCH 2/2] Work around bug when broadcasting empty StridedViews --- src/permutedimsadd.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/permutedimsadd.jl b/src/permutedimsadd.jl index 51de2fc..e96bf32 100644 --- a/src/permutedimsadd.jl +++ b/src/permutedimsadd.jl @@ -30,6 +30,11 @@ end # Broadcasting implementation of add!. function add!_broadcast(dest::AbstractArray, src::AbstractArray, α::Number, β::Number) + # This works around a bug in Strided.jl v2.3.4 and below when broadcasting + # empty StridedViews: https://github.com/QuantumKitHub/Strided.jl/pull/50 + # TODO: Delete this and bump the version of Strided.jl once that is fixed. + isempty(dest) && return dest + if iszero(β) dest .= α .* src else