We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8714abd commit 9ad40f8Copy full SHA for 9ad40f8
Project.toml
@@ -1,7 +1,7 @@
1
name = "GradedArrays"
2
uuid = "bc96ca6e-b7c8-4bb6-888e-c93f838762c2"
3
authors = ["ITensor developers <[email protected]> and contributors"]
4
-version = "0.2.2"
+version = "0.2.3"
5
6
[deps]
7
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
src/gradedarray.jl
@@ -87,6 +87,12 @@ function Base.similar(
87
return similar_blocksparse(a, elt, axes)
88
end
89
90
+function Base.zeros(
91
+ elt::Type, ax::Tuple{AbstractGradedUnitRange,Vararg{AbstractGradedUnitRange}}
92
+)
93
+ return BlockSparseArray{elt}(undef, ax)
94
+end
95
+
96
function getindex_blocksparse(a::AbstractArray, I::AbstractUnitRange...)
97
a′ = similar(a, only.(axes.(I))...)
98
a′ .= a
test/test_gradedarray.jl
@@ -57,9 +57,24 @@ const elts = (Float32, Float64, Complex{Float32}, Complex{Float64})
57
@test 2 * Array(a) == b
58
59
60
- d1 = gradedrange([U1(0) => 2, U1(1) => 2])
61
- d2 = gradedrange([U1(0) => 2, U1(1) => 2])
62
- a = randn_blockdiagonal(elt, (d1, d2, d1, d2))
+ r = gradedrange([U1(0) => 2, U1(1) => 2])
+ a = zeros(r, r, r, r)
+ @test a isa BlockSparseArray{Float64}
63
+ @test eltype(a) === Float64
64
+ @test size(a) == (4, 4, 4, 4)
65
+ @test iszero(a)
66
+ @test iszero(blockstoredlength(a))
67
68
69
+ a = zeros(elt, r, r, r, r)
70
+ @test a isa BlockSparseArray{elt}
71
+ @test eltype(a) === elt
72
73
74
75
76
77
+ a = randn_blockdiagonal(elt, (r, r, r, r))
78
b = similar(a, ComplexF64)
79
@test b isa BlockSparseArray{ComplexF64}
80
@test eltype(b) === ComplexF64
0 commit comments