Skip to content

Commit 1523d0e

Browse files
committed
more dims
1 parent 3cc2c00 commit 1523d0e

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

src/spaces/homspace.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ function dim(W::HomSpace)
127127
return d
128128
end
129129

130+
dims(W::HomSpace) = (dims(codomain(W))..., dims(domain(W))...)
131+
130132
"""
131133
fusiontrees(W::HomSpace)
132134

src/spaces/productspace.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,14 @@ end
4848

4949
# Corresponding methods
5050
#-----------------------
51-
"""
51+
@doc """
5252
dims(::ProductSpace{S, N}) -> Dims{N} = NTuple{N, Int}
53+
dims(V::HomSpace) -> Dims{length(V)}
54+
dims(t::AbstractTensorMap) -> Dims{numind(t)}
55+
56+
Return the dimensions of the spaces in the tensor product space(s) as a tuple of integers.
57+
""" dims
5358

54-
Return the dimensions of the spaces in the tensor product space as a tuple of integers.
55-
"""
5659
dims(P::ProductSpace) = map(dim, P.spaces)
5760
dim(P::ProductSpace, n::Int) = dim(P.spaces[n])
5861
dim(P::ProductSpace) = prod(dims(P))

src/tensors/abstracttensor.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ symmetry. This is also the dimension of the `HomSpace` on which the `TensorMap`
195195
"""
196196
dim(t::AbstractTensorMap) = fusionblockstructure(t).totaldim
197197

198+
dims(t::AbstractTensorMap) = dims(space(t))
199+
198200
"""
199201
blocksectors(t::AbstractTensorMap)
200202
@@ -461,8 +463,7 @@ end
461463
Base.getindex(t::AbstractTensorMap)
462464
t[]
463465
464-
Return a view into the data of `t` as a `StridedViews.StridedView` of size
465-
`(dims(codomain(t))..., dims(domain(t))...)`.
466+
Return a view into the data of `t` as a `StridedViews.StridedView` of size `dims(t)`.
466467
"""
467468
@inline function Base.getindex(t::AbstractTensorMap)
468469
return t[trivial_fusiontree(t)...]
@@ -616,7 +617,7 @@ function Base.convert(::Type{Array}, t::AbstractTensorMap)
616617
dom = domain(t)
617618
T = sectorscalartype(I) <: Complex ? complex(scalartype(t)) :
618619
sectorscalartype(I) <: Integer ? scalartype(t) : float(scalartype(t))
619-
A = zeros(T, dims(cod)..., dims(dom)...)
620+
A = zeros(T, dims(t)...)
620621
for (f₁, f₂) in fusiontrees(t)
621622
F = convert(Array, (f₁, f₂))
622623
Aslice = StridedView(A)[axes(cod, f₁.uncoupled)..., axes(dom, f₂.uncoupled)...]

src/tensors/tensor.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ function TensorMap(
333333
# dimension check
334334
codom = codomain(V)
335335
dom = domain(V)
336-
arraysize = (dims(codom)..., dims(dom)...)
336+
arraysize = dims(V)
337337
matsize = (dim(codom), dim(dom))
338338

339339
if !(size(data) == arraysize || size(data) == matsize)
@@ -487,7 +487,7 @@ end
487487
@boundscheck begin
488488
sectortype(t) == Trivial || throw(SectorMismatch())
489489
end
490-
return sreshape(StridedView(t.data), (dims(codomain(t))..., dims(domain(t))...))
490+
return sreshape(StridedView(t.data), dims(t))
491491
end
492492

493493
# Show

0 commit comments

Comments
 (0)