Skip to content

Commit 751aa95

Browse files
committed
Merge branch 'NDTensors_avoid_threadid' of github.com:ITensor/ITensors.jl into NDTensors_avoid_threadid
2 parents 0a4341f + 9c78c55 commit 751aa95

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

NDTensors/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "NDTensors"
22
uuid = "23ae76d9-e61a-49c4-8f12-3f1a16adf9cf"
33
authors = ["Matthew Fishman <[email protected]>"]
4-
version = "0.4.6"
4+
version = "0.4.8"
55

66
[deps]
77
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"

NDTensors/src/abstractarray/diaginterface.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ function diagstride(a::AbstractArray)
1616
end
1717

1818
function diagindices(a::AbstractArray)
19-
maxdiag = LinearIndices(a)[CartesianIndex(ntuple(Returns(diaglength(a)), ndims(a)))]
19+
maxdiag = if isempty(a)
20+
0
21+
else
22+
LinearIndices(a)[CartesianIndex(ntuple(Returns(diaglength(a)), ndims(a)))]
23+
end
2024
return 1:diagstride(a):maxdiag
2125
end
2226

NDTensors/test/test_diag.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ using NDTensors:
1313
data,
1414
dense,
1515
diaglength,
16+
diagindices,
1617
matrix,
1718
randomTensor,
1819
tensor
@@ -79,6 +80,15 @@ using .NDTensorsTestUtils: devices_list, is_supported_eltype
7980
@test S[i, i] == 2 * D[i, i]
8081
end
8182

83+
a = dev(tensor(Dense(randn(elt, 3)), (3,)))
84+
@test diagindices(a) == 1:1:3
85+
a = dev(tensor(Dense(randn(elt, 9)), (3, 3)))
86+
@test diagindices(a) == 1:4:9
87+
a = dev(tensor(Dense(randn(elt, 36)), (3, 4, 3)))
88+
@test diagindices(a) == 1:16:33
89+
a = dev(tensor(Dense(randn(elt, 0)), (3, 0)))
90+
@test diagindices(a) == 1:1:0
91+
8292
# Regression test for https://github.com/ITensor/ITensors.jl/issues/1199
8393
S = dev(tensor(Diag(randn(elt, 2)), (2, 2)))
8494
## This was creating a `Dense{ReshapedArray{Adjoint{Matrix}}}` which, in mul!, was

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ITensors"
22
uuid = "9136182c-28ba-11e9-034c-db9fb085ebd5"
33
authors = ["Matthew Fishman <[email protected]>", "Miles Stoudenmire <[email protected]>"]
4-
version = "0.9.4"
4+
version = "0.9.5"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

src/itensor.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,16 @@ ITensor(::AliasStyle, args...; kwargs...)::ITensor = error(
148148
Create a `Tensor` that stores a copy of the storage and
149149
indices of the input `ITensor`.
150150
"""
151-
Tensor(T::ITensor)::Tensor = Tensor(NeverAlias(), T)
152-
Tensor(as::NeverAlias, T::ITensor)::Tensor = Tensor(AllowAlias(), copy(T))
151+
NDTensors.Tensor(T::ITensor)::Tensor = Tensor(NeverAlias(), T)
152+
NDTensors.Tensor(as::NeverAlias, T::ITensor)::Tensor = Tensor(AllowAlias(), copy(T))
153153

154154
"""
155155
tensor(::ITensor)
156156
157157
Convert the `ITensor` to a `Tensor` that shares the same
158158
storage and indices as the `ITensor`.
159159
"""
160-
Tensor(::AllowAlias, A::ITensor) = A.tensor
160+
NDTensors.Tensor(::AllowAlias, A::ITensor) = A.tensor
161161

162162
"""
163163
ITensor([::Type{ElT} = Float64, ]inds)

0 commit comments

Comments
 (0)