Skip to content

Commit 4e75a3f

Browse files
authored
[NDTensors] AllocateData library (#1276)
1 parent f78cd87 commit 4e75a3f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/diagonalarray/diagonalarray.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ function DiagonalArray{T}(
6868
return DiagonalArray{T,N}(undef, d, zero)
6969
end
7070

71+
# Axes version
72+
function DiagonalArray{T}(
73+
::UndefInitializer, axes::Tuple{Vararg{AbstractUnitRange,N}}, zero=Zero()
74+
) where {T,N}
75+
@assert all(isone, first.(axes))
76+
return DiagonalArray{T,N}(undef, length.(axes), zero)
77+
end
78+
7179
function DiagonalArray{T}(::UndefInitializer, d::Vararg{Int,N}) where {T,N}
7280
return DiagonalArray{T,N}(undef, d)
7381
end

0 commit comments

Comments
 (0)