diff --git a/src/tensors/factorizations.jl b/src/tensors/factorizations.jl index b6def372..1e37ee92 100644 --- a/src/tensors/factorizations.jl +++ b/src/tensors/factorizations.jl @@ -446,8 +446,8 @@ function _compute_svddata!(t::TensorMap, alg::Union{SVD,SDD}; Udata = SectorDict{I,A}() Vdata = SectorDict{I,A}() dims = SectorDict{I,Int}() - local Σdata - if numthreads == 1 + if numthreads == 1 || length(blocksectors(t)) == 1 + local Σdata for (c, b) in blocks(t) U, Σ, V = MatrixAlgebra.svd!(b, alg) Udata[c] = U @@ -481,8 +481,8 @@ function _compute_svddata!(t::TensorMap, alg::Union{SVD,SDD}; lsc = blocksectors(t) lsD3 = map(lsc) do c # O(D1^2D2) or O(D1D2^2) - return min(size(blocks(t)[c])[1]^2 * size(blocks(t)[c])[2], - size(blocks(t)[c])[1] * size(blocks(t)[c])[2]^2) + return min(size(block(t, c), 1)^2 * size(block(t, c), 2), + size(block(t, c), 1) * size(block(t, c), 2)^2) end lsc = lsc[sortperm(lsD3; rev=true)] @@ -509,13 +509,12 @@ function _compute_svddata!(t::TensorMap, alg::Union{SVD,SDD}; Σdata[c] = Σ dims[c] = length(Σ) unlock(Lock) - end - errormonitor(task) + end + return errormonitor(task) end wait.(tasks) wait(taskref[]) - end return Udata, Σdata, Vdata, dims end diff --git a/src/tensors/linalg.jl b/src/tensors/linalg.jl index 22288f35..e25f518c 100644 --- a/src/tensors/linalg.jl +++ b/src/tensors/linalg.jl @@ -246,7 +246,7 @@ function LinearAlgebra.mul!(tC::AbstractTensorMap, throw(SpaceMismatch("$(space(tC)) ≠ $(space(tA)) * $(space(tB))")) end - if numthreads == 1 + if numthreads == 1 || length(blocksectors(tC)) == 1 for c in blocksectors(tC) if hasblock(tA, c) # then also tB should have such a block A = block(tA, c) @@ -276,10 +276,10 @@ function LinearAlgebra.mul!(tC::AbstractTensorMap, lsc = blocksectors(tC) lsD3 = map(lsc) do c if hasblock(tA, c) - return size(blocks(tA)[c], 1) * size(blocks(tA)[c], 2) * - size(blocks(tB)[c], 2) + return size(block(tA, c), 1) * size(block(tA, c), 2) * + size(block(tA, c), 2) else - return size(blocks(tC)[c], 1) * size(blocks(tC)[c], 2) + return size(block(tC, c), 1) * size(block(tC, c), 2) end end lsc = lsc[sortperm(lsD3; rev=true)] diff --git a/src/tensors/vectorinterface.jl b/src/tensors/vectorinterface.jl index f4d8d873..257ec15f 100644 --- a/src/tensors/vectorinterface.jl +++ b/src/tensors/vectorinterface.jl @@ -61,7 +61,7 @@ function VectorInterface.add!(ty::AbstractTensorMap, tx::AbstractTensorMap, α::Number, β::Number; numthreads::Int64=1) space(ty) == space(tx) || throw(SpaceMismatch("$(space(ty)) ≠ $(space(tx))")) - if numthreads == 1 + if numthreads == 1 || length(blocksectors) == 1 for c in blocksectors(tx) VectorInterface.add!(block(ty, c), block(tx, c), α, β) end @@ -83,7 +83,7 @@ function VectorInterface.add!(ty::AbstractTensorMap, tx::AbstractTensorMap, c = take!(ch) VectorInterface.add!(block(ty, c), block(tx, c), α, β) end - return errormonitor(tast) + return errormonitor(task) end wait.(tasks) diff --git a/test/Project.toml b/test/Project.toml new file mode 100644 index 00000000..5e3ba6a9 --- /dev/null +++ b/test/Project.toml @@ -0,0 +1,10 @@ +[deps] +Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" +ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" +ChainRulesTestUtils = "cdddcdb0-9152-4a09-a978-84456f9df70a" +Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa" +FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000" +HalfIntegers = "f0d1745a-41c9-11e9-1dd9-e5d34d218721" +TensorKit = "07d1fe3e-3e46-537d-9eac-e9e13d0d4cec" +TestExtras = "5ed8adda-3752-4e41-b88a-e8b09835ee3a" +WignerSymbols = "9f57e263-0b3d-5e2e-b1be-24f2bb48858b"